Skip to content

Issue #14981: Add new property to skip FinalLocalVariable violations …#14983

Merged
rnveach merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:finallocalvariable
Jun 18, 2024
Merged

Issue #14981: Add new property to skip FinalLocalVariable violations …#14983
rnveach merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:finallocalvariable

Conversation

@mahfouz72

@mahfouz72 mahfouz72 commented Jun 13, 2024

Copy link
Copy Markdown
Member

@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch from d5ab5a4 to 54869e0 Compare June 13, 2024 14:37
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate report

@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch from 54869e0 to aff88c0 Compare June 13, 2024 14:48
@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch from aff88c0 to 5237ebb Compare June 13, 2024 15:00
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/9501765801

@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate report

@github-actions

Copy link
Copy Markdown
Contributor

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/9502032213

@mahfouz72

Copy link
Copy Markdown
Member Author

@rnveach @nrmancuso pitest-utils is red because FinalLocalVariableTest is not in in targetTests of utils profile. I can add it and I can move isUnamed() to LocalVariableCheck itself and I can make a junit test in TokenUtilTest but @romani said that pure junit should be avoided

I would go for adding this test class to the targetTest. I think all check tests should be there
also, please help why report generation is failing configuration looks good to me

@rnveach

rnveach commented Jun 13, 2024

Copy link
Copy Markdown
Contributor

FinalLocalVariableTest is not in in targetTests of utils profile
I would go for adding this test class to the targetTest. I think all check tests should be there
also, please help why report generation is failing configuration looks good to me

I am not seeing any updates to the POM in this PR, so I am not sure how you say configuration is good. It sounds like POM should add FinalLocalVariableTest to the pitest-utils part of the POM.

@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.

I am good to merge this after one item, and successful diff report:

Comment on lines +366 to +368
public static boolean isUnnamed(DetailAST identifierAst) {
return "_".equals(identifierAst.getText());
}

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.

Let's wait for utility until we need this in more than one place

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.

This condition is no simple, I am not even sure it is worthy of having a utility method

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.

ok, yes it is very simple I just put it there because we will need to use it a lot instead of putting it in the checks classes

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.

@nrmancuso done

@mahfouz72

Copy link
Copy Markdown
Member Author

I am not seeing any updates to the POM in this PR, so I am not sure how you say configuration is good. It sounds like POM should add FinalLocalVariableTest to the pitest-utils part of the POM.

@rnveach here I was talking about the report generation and the regression config

Error: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project sample: Error during page generation: Error rendering Maven report: Failed during checkstyle execution: Failed during checkstyle configuration: unable to parse configuration stream - The markup in the document following the root element must be well-formed.:45:6 -> [Help 1]

@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch from 5237ebb to 5689f7d Compare June 13, 2024 16:45
Comment on lines +139 to +143
/**
* Control whether to check
* <a href="https://docs.oracle.com/javase/specs/jls/se21/preview/specs/unnamed-jls.html">
* unnamed variables </a>.
*/

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.

JLS doesn't have a separate section for this I just went to (https://docs.oracle.com/javase/specs/index.html) and copied the link of the last review for this feature is this ok?

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.

Is there some way we can use a non-preview JLS? Nothing we are doing is preview only, right?

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.

Is there some way we can use a non-preview JLS?

I don't think so. All items listed here are previews. we can use a non-perview from here if the feature has a separate new section

@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch from 5689f7d to 222b855 Compare June 13, 2024 16:49
@rnveach

rnveach commented Jun 13, 2024

Copy link
Copy Markdown
Contributor

https://gist.githubusercontent.com/mahfouz72/afd57aa6e51ca161b7927acd959e5211/raw/545956596861401a2bb555f7c7a08b8421247f2c/check.xml
Line 26. There is an extra </module>.

@mahfouz72

Copy link
Copy Markdown
Member Author

ohh, Thank you

@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.

Noticed a few more:

}
final int _ = sideEffect();
int _ = sideEffect();
int _result = sideEffect(); // violation

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.

Please add violation messages, always

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.

done

<tr>
<td>validateUnnamedVariables</td>
<td>Control whether to check <a href="https://docs.oracle.com/javase/specs/jls/se21/preview/specs/unnamed-jls.html">
unnamed variables </a>.</td>

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.

Why do we always have a space between s and </a>?

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.

nothing, removed

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.

@nrmancuso I noticed that the spaces come again when I made mvn verify I don't why is it something related to the xml files generation or something?

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.

Remove it from the setter in the javadoc.

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.

is it generated from the setter? I thought from the Javadoc on class field

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.

The javadoc on the class is derived from the others as it is an accumulation of multiple pieces, mostly from the xdoc.

@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch 2 times, most recently from 3502ae0 to 0788aad Compare June 13, 2024 17:55
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate report

@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

@mahfouz72 mahfouz72 force-pushed the finallocalvariable branch from 0788aad to 9e0fd51 Compare June 13, 2024 22:18
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

@nrmancuso nrmancuso assigned rnveach and unassigned nrmancuso Jun 14, 2024
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

@rnveach rnveach merged commit 104cf77 into checkstyle:master Jun 18, 2024
@mahfouz72 mahfouz72 deleted the finallocalvariable branch July 4, 2024 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

False positive in FinalLocalVariable check on unnamed variables

4 participants