-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minor: update checks(related to checkstyle issue#10100) #851
Conversation
This means this PR is dependent on 4 things before it can be merged:
|
0f60cbe
to
ab6c95e
Compare
final String parameterName = | ||
getIdentifier(arrayDeclaratorAST); | ||
parameterTypeAST.getFirstChild().getText(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter type is always first child now, it is no longer nested.
@@ -585,22 +586,17 @@ private static boolean isPrimitiveType(DetailAST ast) { | |||
/** | |||
* Checks whether token is array or elipsis. | |||
* | |||
* @param identToken | |||
* @param typeToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously named identToken
, this DetailAST was actually never an IDENT. In every UT we have, this method is passed a TYPE
ast.
private static boolean isArrayOrElipsis(final DetailAST typeToken) { | ||
final DetailAST next = typeToken.getNextSibling(); | ||
final boolean isArrayDeclarator = | ||
typeToken.findFirstToken(TokenTypes.ARRAY_DECLARATOR) != null; | ||
final boolean hasArrayOrEllipses = | ||
TokenUtil.isOfType(next, TokenTypes.ARRAY_DECLARATOR, TokenTypes.ELLIPSIS); | ||
return hasArrayOrEllipses || isArrayDeclarator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch was overkill for two branches, refactored this and modified logic a bit for new type
ast.
@@ -167,9 +167,7 @@ private static DetailAST getLastNode(final DetailAST node) { | |||
while (child != null) { | |||
final DetailAST newNode = getLastNode(child); | |||
if (newNode.getLineNo() > currentNode.getLineNo() | |||
|| newNode.getLineNo() | |||
== currentNode.getLineNo() && newNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After main repo PR, this line was not covered, and no cases to cover it were discovered in regression testing.
result = ident != null && name.equals(ident.getText()); | ||
} | ||
else if (nestedDecl != null && expr == null) { | ||
result = isArgUsedInArrayInit(nestedDecl, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for recursion here anymore, we can just iterate through the sequential ARRAY_DECLARATOR
brackets and check if they have an EXPR
child (i.e. [2]
), then simply check the first [a]
to make sure that the lambda parameter and expression match.
final String parameterName = | ||
getIdentifier(arrayDeclaratorAST); | ||
parameterTypeAST.getFirstChild().getText(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, type is always the first child.
createModuleConfig(ForbidWildcardAsReturnTypeCheck.class); | ||
|
||
final String[] expected = { | ||
"4:5: " + getCheckMessage(MSG_KEY), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New violation found in regression testing.
ab6c95e
to
8d4fd06
Compare
Added blocked label because of #851 (comment) to prevent accidental merging. Label can be removed when this PR can be safely merged. |
Hi, I am a beginner at this issue can you help me. How to start it? |
8d4fd06
to
850a091
Compare
Related to checkstyle/checkstyle#10104
Original reports from Checkstyle PR showing regression:
https://nmancus1.github.io/issue-10100_check_diff_reports_2021_06_11/diff_sevntu-check-regression_part_1/index.html
NoMainMethodInAbstractClassCheck
- new NPEForbidWildcardAsReturnType
- lots of new legit violations, we were missing violations on methods likepublic Class<?>[] getClasses() {}
InnerClass
- symmetrical column changesStaticMethodCandidate
- new violations, we were missing violations previously on methods withString
return typehttps://nmancus1.github.io/issue-10100_check_diff_reports_2021_06_11/diff_sevntu-check-regression_part_2/index.html
MoveVariableInsideIf
- symmetrical column number changesSimpleAccessorNameNotation
- symmetrical column number changesCustomDeclarationOrder
- symmetrical column number changesNew reports showing no regression:
https://nmancus1.github.io/issue-10100_check_diff_reports_2021_06_16/diff_sevntu-check-regression_part_1/index.html
Symmetric column changes and new legitimate violations
NoMainMethodInAbstractClassCheck
- NPE is gonehttps://nmancus1.github.io/issue-10100_check_diff_reports_2021_06_16/diff_sevntu-check-regression_part_2/index.html
Symmetric column changes only
All other changes were because of failing existing unit tests (found via
mvn clean verify
).I will let the build fail to show that the changes in this PR are dependent on the changes at checkstyle/checkstyle#10104, then I will change the Checkstyle repo to my PR to show that all pass.
Failed build (I had to add
mvn clean verify
to CI):Full log at https://app.wercker.com/checkstyle/sevntu.checkstyle/runs/build/60c9e32c237ec900086455fa?step=60c9e3678ea84100087595c9
mvn clean verify
is passing with Checkstyle version from checkstyle/checkstyle#10104