-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Issue #13930: Migrate magicnumber.xml.template to use properties template #13971
Issue #13930: Migrate magicnumber.xml.template to use properties template #13971
Conversation
11b597f
to
f3edc23
Compare
@relentless-pursuit , please rebase. |
f3edc23
to
de517e5
Compare
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.
Items
de517e5
to
05799b6
Compare
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.
I am good to merge if this works, but last question:
src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java
Outdated
Show resolved
Hide resolved
05799b6
to
468bf1e
Compare
10ff602
to
9d404cd
Compare
src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java
Outdated
Show resolved
Hide resolved
9d404cd
to
efc43af
Compare
@relentless-pursuit , looks good to me, please make CI green. |
efc43af
to
3be4878
Compare
@romani, can you help me with any insights why CI is failing? |
This is weird I don't see what can be wrong with code I don't see open issues on this Check https://github.com/sevntu-checkstyle/sevntu.checkstyle/issues?q=is%3Aissue+is%3Aopen+SimpleAccessorNameNotatio No previous suppressions https://github.com/search?q=repo%3Acheckstyle%2Fcheckstyle%20SimpleAccessorNameNotation&type=code |
@relentless-pursuit , please report issue on this Check to sevntu issue tracker. |
@romani Why do you think this a bug?
According to the code, if a method is a getter, has no parameters, only is a return statement with an expression, and we identify some type of field in the expression, then that field must have the same name (ignoring casing) as the method. Why isn't |
Yes.
It is unnatural to have getter with |
d8c98bf
to
dce5087
Compare
Circle CI:
Ok, please name it isSpecialTokenProp |
0867b15
to
72bb03c
Compare
done |
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.
Ok to merge if ci pass
@@ -1037,7 +1037,8 @@ private static void validatePropertySectionPropertyEx(String fileName, String se | |||
if (expectedValue != null) { | |||
final String actualValue = columns.get(3).getTextContent().trim() | |||
.replaceAll("\\s+", " ") | |||
.replaceAll("\\s,", ","); | |||
.replaceAll("\\s,", ",") | |||
.replaceAll("\\s*\\.$", ""); |
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.
Why was this changed?
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.
actual value: ARRAY_INIT, ASSIGN, DIV, ELIST, EXPR, LITERAL_NEW, METHOD_CALL, MINUS, PLUS, STAR, TYPECAST, UNARY_MINUS, UNARY_PLUS .
expect value: ARRAY_INIT, ASSIGN, DIV, ELIST, EXPR, LITERAL_NEW, METHOD_CALL, MINUS, PLUS, STAR, TYPECAST, UNARY_MINUS, UNARY_PLUS
i had to trim any period at the end.
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.
Why was this an issue in your PR? We have periods in other places.
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.
Below is the xml for atclauseorder for target
property
<tr>
<td>target</td>
<td>Specify block tags targeted.</td>
<td>subset of tokens
<a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">
TokenTypes
</a>
</td>
<td>
<a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">
CLASS_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COMPACT_CTOR_DEF">
COMPACT_CTOR_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
CTOR_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
ENUM_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">
INTERFACE_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
METHOD_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_DEF">
RECORD_DEF</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">
VARIABLE_DEF</a>
</td>
<td>6.0</td>
</tr>
Below is the xml for magicnumber for property constantWaiverParentToken
<tr>
<td>constantWaiverParentToken</td>
<td>Specify tokens that are allowed in the AST path from the number literal to the enclosing constant definition.</td>
<td>subset of tokens <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a></td>
<td>
<a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ARRAY_INIT">
ARRAY_INIT</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ASSIGN">
ASSIGN</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV">
DIV</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ELIST">
ELIST</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#EXPR">
EXPR</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_NEW">
LITERAL_NEW</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_CALL">
METHOD_CALL</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS">
MINUS</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS">
PLUS</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR">
STAR</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#TYPECAST">
TYPECAST</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_MINUS">
UNARY_MINUS</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_PLUS">
UNARY_PLUS</a>
.
</td>
<td>6.11</td>
</tr>
I think period is not uniform.
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.
It was reported in this PR because as far as i have observed in the files which had issues with migration in properties section, the PropertiesMacro.java has some code which adds period based on conditionals.
private static void writeTokensList(Sink sink, List<String> tokens, String tokenTypesLink)
throws MacroExecutionException {
for (int index = 0; index < tokens.size(); index++) {
final String token = tokens.get(index);
sink.rawText(INDENT_LEVEL_16);
if (index != 0) {
sink.text(SiteUtil.COMMA_SPACE);
}
writeLinkToToken(sink, tokenTypesLink, token);
}
if (tokens.isEmpty()) {
sink.rawText(CODE_START);
sink.text("empty");
sink.rawText(CODE_END);
}
else {
sink.rawText(INDENT_LEVEL_18);
sink.rawText(SiteUtil.DOT);
sink.rawText(INDENT_LEVEL_14);
}
}
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.
Please share output on how they are failing. We need to show such details with @rnveach to let him understand issue
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.
Please share output on how they are failing. We need to show such details with @rnveach to let him understand issue
I have already shared the failures. Re-sharing it again and adding some context to it.
for magicnumber.xml
,
actual value: ARRAY_INIT, ASSIGN, DIV, ELIST, EXPR, LITERAL_NEW, METHOD_CALL, MINUS, PLUS, STAR, TYPECAST, UNARY_MINUS, UNARY_PLUS .
expect value: ARRAY_INIT, ASSIGN, DIV, ELIST, EXPR, LITERAL_NEW, METHOD_CALL, MINUS, PLUS, STAR, TYPECAST, UNARY_MINUS, UNARY_PLUS
for multiplestringliterals.xml
multiplestringliterals.xml section 'MultipleStringLiterals' should have the value for ignoreOccurrenceContext
expected: ANNOTATION
but was : ANNOTATION .
Expected :ANNOTATION
Actual :ANNOTATION .
This is primarily happening because we add a .
in the below code:
private static void writeTokensList(Sink sink, List<String> tokens, String tokenTypesLink)
throws MacroExecutionException {
for (int index = 0; index < tokens.size(); index++) {
final String token = tokens.get(index);
sink.rawText(INDENT_LEVEL_16);
if (index != 0) {
sink.text(SiteUtil.COMMA_SPACE);
}
writeLinkToToken(sink, tokenTypesLink, token);
}
if (tokens.isEmpty()) {
sink.rawText(CODE_START);
sink.text("empty");
sink.rawText(CODE_END);
}
else {
sink.rawText(INDENT_LEVEL_18);
sink.rawText(SiteUtil.DOT);
sink.rawText(INDENT_LEVEL_14);
}
}
And, this particular piece of code from XdocsPagesTest.java
gets the content by of a node and all its descendants added by PropertiesMacro.java
in form of XML.
if (expectedValue != null) {
final String actualValue = columns.get(3).getTextContent().trim()
.replaceAll("\\s+", " ")
.replaceAll("\\s,", ",");
To illustrate further, when actualValue
is retrieved it sees a .
and registers it while expectedValue
doesn't, giving assertion error.
<tr>
<td>constantWaiverParentToken</td>
<td>Specify tokens that are allowed in the AST path from the number literal to the enclosing constant definition.</td>
<td>subset of tokens <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a></td>
<td>
<a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ARRAY_INIT">
ARRAY_INIT</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ASSIGN">
ASSIGN</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV">
DIV</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ELIST">
ELIST</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#EXPR">
EXPR</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_NEW">
LITERAL_NEW</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_CALL">
METHOD_CALL</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS">
MINUS</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS">
PLUS</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR">
STAR</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#TYPECAST">
TYPECAST</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_MINUS">
UNARY_MINUS</a>
, <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_PLUS">
UNARY_PLUS</a>
.
</td>
<td>6.11</td>
</tr>
Finally, this pattern holds true for all xml for any specific property as such:
<td>subset of tokens <a href="../../apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a></td>
<td>
// some links
.
</td>
As a proof of concept, you can try migrating atclauseordr.xml
and find this failure too. Currently, atclauseorder.xml
isn't migrated.
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.
@rnveach i have pushed a new patchset which removes the need to trim .
. Infact, it removes .
from the xml.
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.
The latest difference doesn't have a removed .
and I see an added .
in the old version now, so it seems this PR was adding a period that was never being made before. That is what was different and required the extra change in the test.
this pattern holds true for all xml for any specific property as such
This is not correct, as we don't see a bigger difference in the new PR. I now see there is a difference between tokens
property, while the areas without a period are not tokens
properties, but are properties that specify a list of tokens.
Now this is making more sense to me.
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.
This is now done, I do see 1 more change.
src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java
Outdated
Show resolved
Hide resolved
9afdda0
to
e4d8302
Compare
Semaphore is restarted |
e4d8302
to
bac4564
Compare
src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java
Outdated
Show resolved
Hide resolved
1a934ee
to
5d858d9
Compare
if (isSpecialTokenProp && !CURLY_BRACKET.equals(defaultValue)) { | ||
final List<String> defaultValuesList = | ||
Arrays.asList(COMMA_SPACE_PATTERN.split(defaultValue)); | ||
writeTokensListDotLess(sink, defaultValuesList, SiteUtil.PATH_TO_TOKEN_TYPES); |
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.
writeTokensListDotLess(sink, defaultValuesList, SiteUtil.PATH_TO_TOKEN_TYPES); | |
writeTokensList(sink, defaultValuesList, SiteUtil.PATH_TO_TOKEN_TYPES, false); |
Add a boolean onto the end of writeTokensList
, and use that to control the period. Other writeTokensList
calls should use true
. Remove writeTokensListDotLess
.
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.
done.
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.
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.
@relentless-pursuit I am against duplicating chunks of code if we can achieve what we need with simple changes.
5d858d9
to
b0609eb
Compare
b0609eb
to
49b7ed9
Compare
Rebased one more time to fix problem caused by non compliant releasenotes |
@rnveach , CI is green, please finish review. |
Resolves #13930