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 #3702: Allow single character names in local variables, method and catch-blocks parameters names in accordance with Google Style Guide #3774
Conversation
diff report on guava is required. please remove fix for Abbreviation, as 0 value lead to unclear violation message. See #3721 . |
9393a7f
to
b898f2e
Compare
Done. See http://mezk.github.io/i3702-google-config/diff
Diff reports looks OK as for me.
Done I don't know why codecov is failing. |
Codecov Report@@ Coverage Diff @@
## master #3774 +/- ##
======================================
Coverage 100% 100%
======================================
Files 275 275
Lines 13618 13618
Branches 3066 3066
======================================
Hits 13618 13618 Continue to review full report at Codecov.
|
6fef764
to
c1d9ad5
Compare
@romani |
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.
@MEZk , please address my requests
@@ -21,7 +21,7 @@ | |||
} catch (Exception noWorries) { // ok | |||
} | |||
try { | |||
} catch (Throwable t) { // warn | |||
} catch (Throwable t) { |
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 put "// ok" instead, not sure why we did this .... but lets keep this.
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
Done.
src/main/resources/google_checks.xml
Outdated
<property name="accessModifiers" value="protected, package, private"/> | ||
<message key="name.invalidPattern" | ||
value="Parameter name ''{0}'' must match pattern ''{1}''."/> | ||
</module> | ||
<module name="ParameterName"> | ||
<property name="id" value="ParameterNamePublic"/> | ||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/> | ||
<property name="format" value="^[a-z]([a-z0-9][A-Z]?)+$"/> |
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 not sure why non-public and public regexps are different. Google confirmed two times in issue on google style that checkstyle rule should be relaxed. It is their style - so we follow it. If smb do not like this (I hope most of projects) they will change this in their configuration.
accessModifiers
should be removed from google style config.
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
Google Style Guide prohibits one-character parameter names for public methods and allows them for non-public methods.
See https://google.github.io/styleguide/javaguide.html#s5.2.6-parameter-names (the second sentence).
That is why we have 2 different regexpses. I read the thread and I don't know whether it is OK that they do not follow their own guide.
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 read the issue discussion on Google style guide google/styleguide#214 (comment)
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 Should we re-open issue and request the documentation be changed to prevent any more confusion?
We have said before we only go by that documentation like when they requested us to validate against another tool.
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.
Reopen will not work, let's do reopen and PR to propose the fix
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 @rnveach
I opened the issue: google/styleguide#226
PR: google/styleguide#227
c1d9ad5
to
ba0f8da
Compare
"47:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "iException", format), | ||
"50:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "x", format), |
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.
One example of a violation isn't much. Can we change or add more examples?
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
Done.
ba0f8da
to
770cfb9
Compare
|
Done. CIs are gree. |
770cfb9
to
bf88b0f
Compare
bf88b0f
to
ab5529f
Compare
If we merge this we will be out of sync with the google document on purpose for this one item as style team has not responded to Issue or PR. |
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 regenerate reports to make sure that my last request do not have affect validation.
src/main/resources/google_checks.xml
Outdated
<message key="name.invalidPattern" | ||
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/> | ||
</module> | ||
<module name="LocalVariableName"> | ||
<property name="tokens" value="VARIABLE_DEF"/> | ||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/> | ||
<property name="format" value="^[a-z]([a-z0-9]+[A-Z]?)*$"/> | ||
<property name="allowOneCharVarInForLoop" value="true"/> |
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.
looks like we do not need this property allowOneCharVarInForLoop
anymore , please remove
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
Done
ab5529f
to
32c1fc7
Compare
DIff reports: |
@MEZk , reports are ok, but they are show that you change config in the way that is not requested in issue.
|
32c1fc7
to
cfb94be
Compare
Done. Config was changed to allow one-characters names. ParameterNameCheck, LocalVariableCheck and CatchParameterCheck should not validate abbreviations in identifiers names. Abbreviations should be validated by special check AbbreviationAsWordInName. I created separate issue to fix this: #3812
|
…s, method and catch-blocks parameters names in accordance with Google Style Guide
cfb94be
to
bb49c2f
Compare
I canceled MacOS build manually (performance reason), it is ok to skip it for this PR. @rnveach , please review one more time and do merge if all is fine to your mind. |
#3702