Skip to content

Commit

Permalink
Merge pull request #3001 from mapfish/rm-violations
Browse files Browse the repository at this point in the history
Upgrade Checkstyle to be aligned with gradle.
  • Loading branch information
sebr72 authored Aug 17, 2023
2 parents a62d1a5 + 3fab775 commit d28b35f
Show file tree
Hide file tree
Showing 32 changed files with 532 additions and 453 deletions.
12 changes: 4 additions & 8 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,18 @@
groupName: 'batik',
automerge: true,
},
/** Use dependencyDashboardApproval of the Checkstyle, SpotBugs and Gradle */
/** Use dependencyDashboardApproval of the SpotBugs and Gradle */
{
matchPackageNames: ['checkstyle', 'spotbugs', 'gradle'],
matchPackageNames: ['spotbugs', 'gradle'],
matchUpdateTypes: ['major', 'minor'],
dependencyDashboardApproval: true,
},
{
matchPackagePrefixes: ['com.puppycrawl.tools:checkstyle', 'com.github.spotbugs:spotbugs-'],
matchPackagePrefixes: ['com.github.spotbugs:spotbugs-'],
matchUpdateTypes: ['major', 'minor'],
dependencyDashboardApproval: true,
},
/** Group the checkstyle and spotbugs */
{
matchPackagePrefixes: ['com.puppycrawl.tools:checkstyle', 'checkstyle'],
groupName: 'checkstyle',
},
/** Group spotbugs */
{
matchPackagePrefixes: ['com.github.spotbugs:spotbugs-', 'spotbugs'],
groupName: 'spotbugs',
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ENV GIT_HEAD=${GIT_HEAD}
# Exclude the tasks that will run out of the docker build (in a docker run)
RUN --mount=type=cache,target=/home/gradle/.gradle \
gradle --parallel --exclude-task=:core:test \
--exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain --exclude-task=:core:violations \
--exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain \
--exclude-task=:core:spotbugsTest --exclude-task=:core:checkstyleTest --exclude-task=:core:testCLI \
:core:build :core:explodedWar :publish:build :examples:build :docs:buildDocs

Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ build-builder:
.PHONY: checks
checks: build-builder
mkdir --parent reports
mkdir --parent core/build/resources/
docker run --rm --user=$(shell id -u):$(shell id -g) \
--volume=$(PWD)/core/src/:/src/core/src/:ro \
--volume=$(PWD)/reports/:/src/core/build/reports/ \
--volume=$(PWD)/core/build/resources/:/src/core/build/resources/ \
mapfish_print_builder \
gradle --parallel :core:spotbugsMain :core:checkstyleMain :core:violations
gradle --parallel spotbugsMain checkstyleMain spotbugsTest checkstyleTest

.PHONY: tests
tests: build-builder
Expand All @@ -36,7 +38,7 @@ tests: build-builder
--volume=$(PWD)/core/build/scripts/:/src/core/build/scripts/ \
--volume=$(PWD)/core/src/test/:/src/core/src/test/ \
mapfish_print_builder \
gradle --parallel --exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain --exclude-task=:core:violations \
gradle --parallel --exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain \
--exclude-task=:core:spotbugsTest --exclude-task=:core:checkstyleTest \
:core:test :core:testCli

Expand All @@ -58,7 +60,7 @@ acceptance-tests-up: build .env
.PHONY: acceptance-tests-run
acceptance-tests-run: .env
docker-compose exec -T tests gradle \
--exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain --exclude-task=:core:violations \
--exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain \
--exclude-task=:core:spotbugsTest --exclude-task=:core:checkstyleTest --exclude-task=:core:testCLI \
:examples:integrationTest
ci/check-fonts
Expand Down
23 changes: 2 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import se.bjurr.violations.gradle.plugin.ViolationsTask

buildscript {
repositories {
mavenCentral()
Expand All @@ -8,7 +6,6 @@ buildscript {

dependencies {
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.5"
classpath "se.bjurr.violations:violations-gradle-plugin:1.52.6"
}
}

Expand Down Expand Up @@ -37,39 +34,23 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) {
apply plugin: 'idea'
apply plugin: 'project-report'
apply plugin: 'checkstyle'
apply plugin: 'se.bjurr.violations.violations-gradle-plugin'

jar.dependsOn(checkstyleMain)

checkstyle {
toolVersion = "6.19" // com.puppycrawl.tools:checkstyle
// Use the default version from Gradle
// https://github.com/gradle/gradle/blob/v6.7.1/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CheckstylePlugin.java#L37
configFile = file("$rootProject.rootDir/checkstyle_checks.xml")
configProperties = ['basedir': project.rootDir.path]
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/checkstyleReports")
}
checkstyleTest.enabled = false

spotbugs {
toolVersion = "4.4.2" // com.github.spotbugs:spotbugs-annotations
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/spotbugsReports")
effort = "max"
reportLevel = "high"
}
spotbugsTest.enabled = true

tasks.register('violations', ViolationsTask) {
minSeverity = 'INFO'
detailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
maxViolations = 1066
printViolations = true
violations = [
["FINDBUGS", ".", ".*/reports/spotbugsReports/.*\\.xml", "Spotbugs"],
["CHECKSTYLE", ".", ".*/reports/checkstyleReports/.*\\.xml", "Checkstyle"]
]
}
check.finalizedBy violations

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down
12 changes: 6 additions & 6 deletions checkstyle_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<module name="SuppressWarningsFilter"/>
<module name="TreeWalker">
<module name="SuppressWarningsHolder"/>
<module name="SuppressionCommentFilter"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CSOFF\:\s*([\w\|]+)"/>
<property name="onCommentFormat" value="CSON\:\s*([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="JavadocMethod">
<property name="allowedAnnotations" value="Override, Autowired"/>
<property name="allowMissingParamTags" value="true"/>
Expand Down Expand Up @@ -71,12 +77,6 @@
</module>
<module name="UpperEll"/>
</module>
<module name="SuppressionCommentFilter"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CSOFF\:\s*([\w\|]+)"/>
<property name="onCommentFormat" value="CSON\:\s*([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="JavadocPackage"/>
<module name="Translation"/>
<module name="FileLength"/>
Expand Down
7 changes: 4 additions & 3 deletions checkstyle_suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
"-//Puppy Crawl//DTD Suppressions 1.2//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_2.dtd">

<suppressions>
<suppress files=".*Test\.java" checks="[a-zA-Z0-9]*"/>
<suppress files=".*/Test.*\.java" checks=".*"/>
<suppress files=".*Test\.java" checks=".*"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public MapfishMapContext(
* @param forceLongitudeFirst If true then force longitude coordinates as the first coordinate.
* @param dpiSensitiveStyle Scale the vector styles?
*/
// CSOFF: ParameterNumber
public MapfishMapContext(
final MapfishMapContext parent,
final MapBounds bounds,
Expand All @@ -94,7 +93,6 @@ public MapfishMapContext(
* @param forceLongitudeFirst If true then force longitude coordinates as the first coordinate.
* @param dpiSensitiveStyle Scale the vector styles?
*/
// CSOFF: ParameterNumber
public MapfishMapContext(
final MapfishMapContext parent,
final MapBounds bounds,
Expand All @@ -103,7 +101,6 @@ public MapfishMapContext(
final double dpi,
final Boolean forceLongitudeFirst,
final boolean dpiSensitiveStyle) {
// CSON: ParameterNumber
this.parent = parent;
this.bounds = bounds;
this.mapSize = mapSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Stack;

/** Used to convert an integer index to an alpha index. Index in: A..Z,AA..ZZ,AAA... */
public class HumanAlphaSerie {
public final class HumanAlphaSerie {

private HumanAlphaSerie() {
// Raise exception because the class should not be instantiated
Expand All @@ -13,16 +13,16 @@ private HumanAlphaSerie() {
/**
* Convert an integer to an alpha index.
*
* @param number the number to convert
* @param nbr the number to convert
* @return the alpha index
*/
public static String toString(int number) {
if (number <= 0) {
public static String toString(final int nbr) {
if (nbr <= 0) {
return "";
}

// We want to start with A (1)
number += 1;
int number = nbr + 1;

Stack<Integer> stack = new Stack<>();
while (number > 26) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** Json wrappers, errors and utilities. */
package org.mapfish.print.jasperreports;
Loading

0 comments on commit d28b35f

Please sign in to comment.