-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Issue #8965: fix false-negative on new keyword's children's Indentation #17181
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
Conversation
SecondClassLongNam7(getString(100000, "Long" //indent:48 exp:48 | ||
+ "Foo><"))) || conNoArg() //indent:52 exp:52 | ||
|| conNoArg() || //indent:56 exp:56 | ||
conNoArg() || conNoArg()) {} //indent:60 exp:60 |
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.
@Zopsss these two files go out of length limit.
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.
is there way to change variables to be shorter and less crazy ?
if all such long names matters, we can add Input to suppression, but I think we should try shortening of Input, such creazy Input code is not readable and nobody can say what is reasonable indentation should be. It might be copy pasted from other Input.
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.
Yup I also think this is very crazy input
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. and it was not easy. 🥲
@mohitsatr any update on this? |
ffd119e
to
493aa59
Compare
Github, generate report |
@mohitsatr , can we make progress on this ? |
@romani |
@Zopsss should I exclude and make InputFormatted.. file in this case too. ? |
Yes. If we need violation and formatter complains for it then we need to exclude that file and make InputFormatted file for it so formatter can be happy. |
8895496
to
7b9aecd
Compare
@Zopsss I fixed it pgjdbc/pgjdbc#3682. |
@romani can you restart CI? |
No need to restart, it is CS violations:
and
I think all of them are false positives. |
I have added both the cases to the inputs. for sevntu case,
but it is getting tested on
checkstyle/config/checkstyle-checks.xml Lines 813 to 818 in 512dfb4
|
Github, generate report |
Github, generate report for Indentation/all-examples-in-one |
no change in report. |
Report for Indentation/all-examples-in-one: |
Please add this simple code snippet to input. |
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.
Minor test extension is required, but in general ready for merge
f1aedea
to
ec79307
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.
@romani was my reasoning right at #17181 (comment) ? |
public Object foo() { | ||
return Optional.empty() | ||
.orElseThrow( | ||
() -> | ||
new IllegalArgumentException( | ||
"Something wrong 1, something wrong 2, something wrong 3")); | ||
} |
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.
Can you also add a similar case like following:
public Object foo() {
return Optional.empty()
.orElseThrow(
() -> new IllegalArgumentException(
"Something wrong 1, something wrong 2, something wrong 3"));
}
Sorry I'm commenting from phone so indentation might be wrong.
Also try to add a violation case with incorrect indentation for the last line.
https://google.github.io/styleguide/javaguide.html#s4.5.1-line-wrapping-where-to-break
A line is never broken adjacent to the arrow in a lambda or a switch rule, except that a break may come immediately after the arrow if the text following it consists of a single unbraced expression
It says a break "may" come
, so I think it is not compulsory to have a break after ->
so my suggested case should not give violation.
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.
Also we should add this case to main indentation inputs too
f187405
to
ffeeb06
Compare
() -> new IllegalArgumentException( | ||
"something wrong 1, something wrong 2, something wrong 3")); |
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.
Is the Indentation wrong here? "Something wrong 1....
shouldn't have 2 more spaces?
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, it is correct. lineWrappingIndentation
is 4.
line 65 has indentation of 12, so line 66 have indentation of 16
/** some data. */ | ||
public Object foo4(int data) { | ||
return Optional.empty() | ||
.orElseThrow( | ||
() -> new IllegalArgumentException( | ||
"something wrong 1, something wrong 2, something wrong 3")); | ||
} | ||
|
||
/** some data. */ | ||
public Object foo5(int data) { | ||
return Optional.empty() | ||
.orElseThrow( | ||
() -> new IllegalArgumentException( | ||
"something wrong 1, something wrong 2, something wrong 3")); | ||
// violation above '.* incorrect indentation level 8, expected .* 16.' | ||
} |
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 add these cases to src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationNewChildren.java
as well
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.
already did:
Line 47 in ffeeb06
public Object foo4(int data) { //indent:2 exp:2 |
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 add correct case also
@romani ok to merge if ci passes |
fixes #8965
Diff Regression config: https://gist.githubusercontent.com/mohitsatr/60d8725143067033c0ee8c8b8c6902c0/raw/e585f76bf1fe45a3eab04329b4f3ae01766aa394/google_checks_codeblock.xml
Diff Regression projects: https://gist.githubusercontent.com/mohitsatr/68b0817ac52ff7773d35585ee12fc1cc/raw/f9c7774ca78df1f48f34bf30799bd3952abd9e2a/list-of-projects.properties