Skip to content
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

Merged
merged 1 commit into from Feb 9, 2017

Conversation

MEZk
Copy link
Contributor

@MEZk MEZk commented Jan 28, 2017

@romani
Copy link
Member

romani commented Jan 28, 2017

diff report on guava is required.

please remove fix for Abbreviation, as 0 value lead to unclear violation message. See #3721 .

@MEZk
Copy link
Contributor Author

MEZk commented Jan 30, 2017

@romani

diff report on guava is required.

Done. See http://mezk.github.io/i3702-google-config/diff
There are two types of differences:

  1. Due to the new regexp format (the meaning of the violations is the same)
  2. Due to allowance of one-character names.

Diff reports looks OK as for me.

please remove fix for Abbreviation, as 0 value lead to unclear violation message.

Done

I don't know why codecov is failing.

@codecov-io
Copy link

codecov-io commented Jan 30, 2017

Codecov Report

Merging #3774 into master will not change coverage.

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dab7a9a...bb49c2f. Read the comment docs.

@MEZk MEZk force-pushed the i3702-google-style-naming branch 2 times, most recently from 6fef764 to c1d9ad5 Compare January 31, 2017 04:53
@MEZk
Copy link
Contributor Author

MEZk commented Jan 31, 2017

@romani
CIs are green.

Copy link
Member

@romani romani left a 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) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romani
Done.

<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]?)+$"/>
Copy link
Member

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.

Copy link
Contributor Author

@MEZk MEZk Feb 2, 2017

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.

Copy link
Member

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)

Copy link
Member

@rnveach rnveach Feb 2, 2017

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.

Copy link
Member

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

Copy link
Contributor Author

@MEZk MEZk Feb 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"47:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "iException", format),
"50:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "x", format),
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rnveach
Done.

@romani
Copy link
Member

romani commented Feb 2, 2017

accessModifiers usage has to be removed.

@MEZk
Copy link
Contributor Author

MEZk commented Feb 3, 2017

@romani

accessModifiers usage has to be removed.

Done. CIs are gree.
New diff report: http://mezk.github.io/i3702-google-config/diff
Issue: google/styleguide#226
PR: google/styleguide#227

@MEZk
Copy link
Contributor Author

MEZk commented Feb 6, 2017

@romani @rnveach
Are you OK with the changes?

@rnveach
Copy link
Member

rnveach commented Feb 6, 2017

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.

Copy link
Member

@romani romani left a 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.

<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"/>
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romani
Done

@MEZk
Copy link
Contributor Author

MEZk commented Feb 7, 2017

@romani

please regenerate reports to make sure that my last request do not have affect validation.

DIff reports:

  1. ParameterNameCheck
  2. LocalVariableNameCheck
  3. CatchParameterNameCheck

@romani
Copy link
Member

romani commented Feb 9, 2017

@MEZk , reports are ok, but they are show that you change config in the way that is not requested in issue.
You changed a format to address abbreviations, that was not requested in issue.
If you think it also should be done - please create separate issue on this. Do not mix all fixes together!

  1. config regexps should be fixed
  2. reports need to be regenerated

@MEZk
Copy link
Contributor Author

MEZk commented Feb 9, 2017

@romani

  1. config regexps should be fixed

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

  1. reports need to be regenerated

Done. See http://mezk.github.io/i3702-google-config/diff/

…s, method and catch-blocks parameters names in accordance with Google Style Guide
@romani
Copy link
Member

romani commented Feb 9, 2017

I canceled MacOS build manually (performance reason), it is ok to skip it for this PR.
code changes is ok, config changes is ok.
report is good.

@rnveach , please review one more time and do merge if all is fine to your mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants