Skip to content

Commit

Permalink
feat: set checkstyle max warnings 0 by default (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt authored Feb 22, 2024
1 parent 1d3a0dd commit b50809c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
4 changes: 2 additions & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ maven/mavencentral/com.google.j2objc/j2objc-annotations/1.1, Apache-2.0, approve
maven/mavencentral/com.google.j2objc/j2objc-annotations/1.3, Apache-2.0, approved, CQ21195
maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.googlecode.libphonenumber/libphonenumber/8.0.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.puppycrawl.tools/checkstyle/10.12.3, LGPL-2.1+, restricted, clearlydefined
maven/mavencentral/com.puppycrawl.tools/checkstyle/10.12.3, LGPL-2.1-only AND Apache-2.0 AND LGPL-2.1-or-later AND ANTLR-PD AND GPL-2.0-or-later AND LGPL-2.0-or-later AND (Apache-2.0 AND LGPL-2.1-or-later) AND LicenseRef-scancode-proprietary-license, restricted, #13190
maven/mavencentral/com.rameshkp/openapi-merger-app/1.0.5, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.rameshkp/openapi-merger-gradle-plugin/1.0.5, Apache-2.0, approved, #9669
maven/mavencentral/commons-beanutils/commons-beanutils/1.9.4, Apache-2.0, approved, CQ12654
Expand Down Expand Up @@ -80,7 +80,7 @@ maven/mavencentral/joda-time/joda-time/2.9.7, Apache-2.0, approved, CQ11988
maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.14.11, Apache-2.0, approved, #7164
maven/mavencentral/net.bytebuddy/byte-buddy/1.14.11, Apache-2.0 AND BSD-3-Clause, approved, #7163
maven/mavencentral/net.sf.jopt-simple/jopt-simple/5.0.3, MIT, approved, CQ13174
maven/mavencentral/net.sf.saxon/Saxon-HE/12.3, NOASSERTION, restricted, clearlydefined
maven/mavencentral/net.sf.saxon/Saxon-HE/12.3, MPL-2.0-no-copyleft-exception AND (LicenseRef-scancode-proprietary-license AND MPL-2.0-no-copyleft-exception) AND (MPL-2.0-no-copyleft-exception AND X11) AND (MIT AND MPL-2.0-no-copyleft-exception) AND (MPL-1.0 AND MPL-2.0-no-copyleft-exception) AND (Apache-2.0 AND MPL-2.0-no-copyleft-exception) AND MPL-1.0, restricted, #13191
maven/mavencentral/net.steppschuh.markdowngenerator/markdowngenerator/1.3.1.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.antlr/antlr4-runtime/4.11.1, BSD-3-Clause, approved, clearlydefined
maven/mavencentral/org.apache.commons/commons-lang3/3.12.0, Apache-2.0, approved, clearlydefined
Expand Down
19 changes: 18 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.nio.file.Files
import java.time.LocalDateTime

plugins {
`java-gradle-plugin`
Expand Down Expand Up @@ -71,7 +72,23 @@ val createVersions = tasks.register("createVersions") {
doLast {
versionCatalogs.find("libs")
.ifPresent { catalog ->
val head = "package org.eclipse.edc.plugins.edcbuild;\npublic interface Versions {\n"
val copyright = """
/*
* Copyright (c) ${LocalDateTime.now().year} Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Contributors to the Eclipse Foundation - initial API and implementation
*
*/
""".trimIndent()

val head = "$copyright\n\npackage org.eclipse.edc.plugins.edcbuild;\npublic interface Versions {\n"
val tail = "\n}";

val constants = listOf("assertj", "checkstyle", "jupiter", "mockito")
Expand Down
3 changes: 1 addition & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
<module name="RegexpHeader">
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java"/>
<property name="header"
value="^/\*$\n^ \* Copyright \(c\) 20\d\d((,| -) 20\d{2})? [A-Za-z].+\S$\n^ \*$\n^ \* This program and the accompanying materials are made available under the$\n^ \* terms of the Apache License, Version 2\.0 which is available at$\n^ \* https://www\.apache\.org/licenses/LICENSE-2\.0$\n^ \*$\n^ \* SPDX-License-Identifier: Apache-2\.0$\n^ \*$\n^ \* Contributors:$\n^ \* \S.*\S$\n^ \*$\n^ \*/$\n^$\n^package"/>
<property name="headerFile" value="${config_loc}/java.header"/>
<property name="multiLines" value="11"/>
</module>

Expand Down
15 changes: 15 additions & 0 deletions config/checkstyle/java.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
^/\*$
^ \* Copyright \(c\) 20\d\d((,| -) 20\d{2})? [A-Za-z].+\S$
^ \*$
^ \* This program and the accompanying materials are made available under the$
^ \* terms of the Apache License, Version 2\.0 which is available at$
^ \* https://www\.apache\.org/licenses/LICENSE-2\.0$
^ \*$
^ \* SPDX-License-Identifier: Apache-2\.0$
^ \*$
^ \* Contributors:$
^ \* \S.*\S$
^ \*$
^ \*/$
^$
^package
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class CheckstyleConvention implements EdcConvention {

@Override
public void apply(Project target) {
var cse = requireExtension(target, CheckstyleExtension.class);
var extension = requireExtension(target, CheckstyleExtension.class);

cse.setToolVersion(Versions.CHECKSTYLE);
cse.setMaxErrors(0);
target.getTasks().withType(Checkstyle.class, cs -> cs.reports(r -> {
extension.setToolVersion(Versions.CHECKSTYLE);
extension.setMaxErrors(0);
extension.setMaxWarnings(0);

target.getTasks().withType(Checkstyle.class, checkstyle -> checkstyle.reports(r -> {
r.getHtml().getRequired().set(false);
r.getXml().getRequired().set(true);
}));
Expand Down

0 comments on commit b50809c

Please sign in to comment.