Skip to content

Issue #12164: Enable Checker Framework#12194

Merged
nrmancuso merged 1 commit into
checkstyle:masterfrom
Vyom-Yadav:enableCheckerFramework
Sep 17, 2022
Merged

Issue #12164: Enable Checker Framework#12194
nrmancuso merged 1 commit into
checkstyle:masterfrom
Vyom-Yadav:enableCheckerFramework

Conversation

@Vyom-Yadav

@Vyom-Yadav Vyom-Yadav commented Sep 12, 2022

Copy link
Copy Markdown
Member

Resolves #12164

@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch 2 times, most recently from 422f9de to 8e5c196 Compare September 12, 2022 11:09
Comment thread pom.xml
@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch 2 times, most recently from 86bfbfc to aced8ac Compare September 12, 2022 11:28
@nrmancuso

nrmancuso commented Sep 12, 2022

Copy link
Copy Markdown
Contributor

Please apply:

➜  checkstyle git:(issue-12164-1) ✗ git diff | cat
diff --git a/pom.xml b/pom.xml
index 858d95227..1db2387f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -257,6 +257,12 @@
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
       <version>31.1-jre</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.checkerframework</groupId>
+          <artifactId>checker-qual</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.ant</groupId>

For issue in hibernate, we will need to send a PR to do something similar. We can exclude enforcer run temporarily for them in our CI.

mvn clean verify passes for hibernate with:

➜  hibernate-search git:(main) ✗ git diff | cat
diff --git a/pom.xml b/pom.xml
index 651f9e8334..7ec032b53a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -405,7 +405,7 @@
         <version.scripting.plugin>3.0.0</version.scripting.plugin>
         <version.gpg.plugin>3.0.1</version.gpg.plugin>
         <version.org.codehaus.groovy-jsr223>3.0.12</version.org.codehaus.groovy-jsr223>
-        <version.com.puppycrawl.tools.checkstyle>10.3.3</version.com.puppycrawl.tools.checkstyle>
+        <version.com.puppycrawl.tools.checkstyle>10.3.4-SNAPSHOT</version.com.puppycrawl.tools.checkstyle>
         <version.versions.plugin>2.12.0</version.versions.plugin>
 
         <!-- Asciidoctor -->
@@ -1326,6 +1326,12 @@
                 <artifactId>guava</artifactId>
                 <version>${version.org.google.guava}</version>
                 <scope>compile</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.checkerframework</groupId>
+                        <artifactId>checker-qual</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.jberet</groupId>

@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch 2 times, most recently from 327a395 to 2bb2df4 Compare September 13, 2022 18:33
@Vyom-Yadav

Vyom-Yadav commented Sep 15, 2022

Copy link
Copy Markdown
Member Author

Error from https://github.com/checkstyle/checkstyle/actions/runs/3047499328/jobs/4911550442

Error: /home/runner/work/checkstyle/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/api/AbstractCheck.java:[40,16] error: [type.checking.not.run] OptionalChecker did not run because of a previous error issued by javac

Running checker framework without -Awarns issues a lots of warnings like these.
From SO Answer (By creator of Checker Framework)

The Checker Framework runs as a plugin to javac. When javac issues an error in one class (including any Checker Framework error), javac may or may not process other classes. Unfortunately, there is no good way for a user to predict how far javac will get.

Creating a different profile for each checker will also not work. If a checker fails then new warnings from that checker can also be like did not run because of a previous error issued by javac.

Using -Awarns will simply convert errors to warnings.

@romani

romani commented Sep 16, 2022

Copy link
Copy Markdown
Member

Usage of warns might help only to not let maven execution fail with error code. So it will help us to analyze results and do failure based on some other reasons.

Do we have problems to get stable output from Checker execution ? I try to understand what blocks it us to merge this PR

@Vyom-Yadav

Copy link
Copy Markdown
Member Author

Usage of warns might help only to not let maven execution fail with error code.

That is not the main purpose of using -Awarns, not failing on error can be done by
<failOnError>false</failOnError>.

We are using -Awarns because many errors are there due to the checker not running due to
a previous error issued by javac. Using -Awarns only shows the error we need, without the errors of type did not run because of a previous error issued by javac.

@romani

romani commented Sep 16, 2022

Copy link
Copy Markdown
Member

Good to know.

Can you briefly answer my other question ?

@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch 4 times, most recently from 03106b0 to 0da7afe Compare September 17, 2022 09:35
@Vyom-Yadav

Vyom-Yadav commented Sep 17, 2022

Copy link
Copy Markdown
Member Author

Do we have problems to get stable output from Checker execution ? I try to understand what blocks it us to merge this PR

I executed it locally a couple of times, and new violations pop up in the CI, trying once more.

Update: It is stable now.

@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch 3 times, most recently from ea5a8cd to e34f1a6 Compare September 17, 2022 10:43
Comment on lines -362 to -364
SystemExit {
doNotApplyToFileNames = 'pitest-survival-check-xml.groovy,error-prone-check.groovy'
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We suppress every groovy script, removal of this is better, we will most probably use groovy only for writing scripts.

@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch 4 times, most recently from fc18676 to 6f66617 Compare September 17, 2022 13:36
@romani

romani commented Sep 17, 2022

Copy link
Copy Markdown
Member

@Vyom-Yadav , please put in commit proper issue number - #12164

please fix codenarc

@Vyom-Yadav Vyom-Yadav force-pushed the enableCheckerFramework branch from 6f66617 to ca2a030 Compare September 17, 2022 14:19
Comment on lines +2963 to +2973
<!-- Unstable as 'capture#' keeps changing in different runs. -->
<checkerFrameworkError unstable="true">
<fileName>checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java</fileName>
<specifier>argument</specifier>
<message>incompatible argument for parameter constructor of invokeConstructor.</message>
<lineContent>handlerCtor, indentCheck, ast, parent);</lineContent>
<details>
found : @Initialized @Nullable Constructor&lt;capture#788 extends @Initialized @Nullable Object&gt;
required: @Initialized @NonNull Constructor&lt;capture#788 extends @Initialized @Nullable Object&gt;
</details>
</checkerFrameworkError>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unstable violation

Comment on lines +3404 to +3414
<!-- Unstable as 'capture#' keeps changing in different runs. -->
<checkerFrameworkError unstable="true">
<fileName>checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java</fileName>
<specifier>type.argument</specifier>
<message>incompatible type argument for type parameter T extends Object of invokeConstructor.</message>
<lineContent>resultHandler = (AbstractExpressionHandler) CommonUtil.invokeConstructor(</lineContent>
<details>
found : capture#788[ extends @UnknownKeyFor Object super @KeyForBottom Void]
required: [extends @UnknownKeyFor Object super @UnknownKeyFor NullType]
</details>
</checkerFrameworkError>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unstable violation.

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's try this Checker in read day to day coding

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of nuances to understand with each checker, let’s merge this and live with it in order to learn. @Vyom-Yadav please create an issue to resolve checker suppressions, and in it please explain details of unstable suppressions.

@nrmancuso nrmancuso merged commit 6335dd8 into checkstyle:master Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Checker Framework

3 participants