-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Suppression for long identifiers for 4.4 Column Limit: 100
rule of google java style guide
#15233
Comments
@Zopsss , please make PR with Input that shows shows long identifiers wrapped by formatter as he can AND how checkstyle violate them. Long variable, method, type name, ... Give a bit more examples. Keep it formatted by formatter. |
it is not that easy, LineLength become not Java Check, so it does not know anything about methods and variables. points of attention The only solution I see is to allow users to use suppressions to mark suppression in comment and explain reason https://checkstyle.org/google_style.html#Google_Suppressions, please play with this and lets choose what we would recomment for users to use if they run into this. |
4.4 Column Limit: 100
rule of google java style guide4.4 Column Limit: 100
rule of google java style guide
Umm creating a separate PR won't help much, I think it will be better to show the code here with the output, I guess this will be a more efficient way. Original code: /** some javadoc. */
public class TestingColumnLimit {
public static int GLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOBBBBBBBBAAAAAAAAALLLLLLLLLLL_______VARRRRRRRIIIIIIIABLEEEEEEEEE = 99;
final int abccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc = 99;
void fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo() {
boolean xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = true;
if (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) {
// some code
} else {
// some code
}
switch (GLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOBBBBBBBBAAAAAAAAALLLLLLLLLLL_______VARRRRRRRIIIIIIIABLEEEEEEEEE) {
case abccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc:
fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo();
break;
default:
break;
}
System.out.println("Helllllllllllllllllllllllllllllllllllllllllllllllllllllllllloooooooooooooooooooooooooooooooooo");
}
class Innnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrrrrrr {}
} Formatted code: /** some javadoc. */
public class TestingColumnLimit {
public static int
GLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOBBBBBBBBAAAAAAAAALLLLLLLLLLL_______VARRRRRRRIIIIIIIABLEEEEEEEEE =
99;
final int
abccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc =
99;
void
fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo() {
boolean
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx =
true;
if (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) {
// some code
} else {
// some code
}
switch (GLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOBBBBBBBBAAAAAAAAALLLLLLLLLLL_______VARRRRRRRIIIIIIIABLEEEEEEEEE) {
case abccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc:
fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo();
break;
default:
break;
}
System.out.println(
"Helllllllllllllllllllllllllllllllllllllllllllllllllllllllllloooooooooooooooooooooooooooooooooo");
}
class Innnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrrrrrr {}
} Output:
Formatter tries to shrink down the line size but it still crosses the limit of 100. |
I think the SuppressWarningsFilter would be a good choice to recommend it to users, users' will just need to use
Edit: PR sent regarding this: #15426 |
@rdiachenko , do you agree with suppression? |
@Zopsss , while we are waiting for @rdiachenko , please send PR with update of Inputs annotations to show how it will looks like for user. |
…to show usage of suppression for long identifiers
I missed this point. Makes sense. I'm good with using suppression. |
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…to show usage of suppression for long identifiers
…age of suppression for long identifiers
I have read check documentation: https://checkstyle.org/checks/sizes/linelength.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
Detected at: #14901 (comment)
The 4.4 Column Limit: 100 rule of google java style guide has some exceptions cases in which this rule does not apply, one of them is:
style guide says that long identifiers which crosses the column limit of 100 are allowed, so we should not give violation due to such identifiers.
Current behavior of Checkstyle:
Output:
google-java-format behavior:
The formatter formats and tries to wrap the long identifier to make it under column limit but this still crosses the limit of 100. And in case of CS, we give violation for such type of code.
Describe what you expect in detail.
As @rdiachenko suggested here: #14901 (comment), we should revisit the working of LineLength module and add a new property to ignore long identifiers, this will also require to update the google_checks.xml accordingly.
Or
We can discuss another way to solve the problem here in this issue.
The text was updated successfully, but these errors were encountered: