-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Guava library violates Google Java Style guide #1891
Comments
This is awesome! Our hacked-up version of checkstyle that we use inside Google misses a ton of things -- well, as I guess you can see -- because we're hyper-averse to false positives, and because we've never put quite enough effort into it. That said, the state of Guava is not quite as bad as this report initially makes it look. :-) These seem to be the top findings: 926 ParameterName 740 JavadocMethod 512 EmptyLineSeparator 307 Indentation 263 LocalVariableName 185 SingleLineJavadoc 185 EmptyBlock (empty catch block) 157 JavadocParagraph 92 OverloadMethodsDeclarationOrder 80 WhitespaceAround |
Colin: as all this github migration stuff is settling down, maybe looking at checkstyle convergence might be possible? :-) :-) (What do you want for Christmas?) |
Why not to contribute Google's fixes over Checkstyle to Checkstyle ? :)
Pelase update a Google Style Guide.
from style guide "The single-line form may be substituted when there are no at-clauses present," . So all one line javadocs that have atclauses are not allowed.
Googe Style Guide need to updated to clearly state under what names and comments inside it will be allowed to have empty block. After that we could update Rules to cover them. |
Re: SingleLineJavadoc, I will try to fix the bit about "no at-clauses present", as it seems totally unnecessary. We never intended for this to require
over
Also, we used this term "at-clauses" without defining it, which was bad of us. It refers to the separate sections that start with @param, @return, @throws, etc. It does not refer to inline usages of @code, @link, etc., so even regardless of the above, this line shouldn't be warning anyway:
Again, I will try to fix this. Re: EmptyBlock, (a) the current guide says this: "Exception: In tests, a caught exception may be ignored without comment if it is named |
For EmptyBlock, we're also just allowing any exception named |
Google’s Java Style Guide should be updated
Some exceptions for general rules will always be. You can use suppressions specific to Guava project:
checkstyle_suppression.xml :
JavadocMethod Check have option “minLineCount”="2", we could extend it to value you think in general mean “self explanatory method”. If that is not an option please confirm switching off that Check.
checkstyle_suppression.xml :
ok, it is matter of your code standard, just change style guide.
completely reasonable, but guide is not exact - so guide have to extended to be more precise.
We could create special Check to do validation base on comment inside and base on name of variable. Checkstyle could not distinguish test code and production code so that allowance by name will be applied to all code.
Checkstyle have ability to change message in configuration, example - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml#L40, so we could make it like: |
EmptyBlock: yes, that's what we do too. The guide may not say you can name it 'expected' and skip the comment in production code, but checkstyle will let you. WhitespaceAround: agreed. Most of the rest of your comment looks like just echoing what we already know needs to be fixed. I can't promise a fixed version of the document will be coming soon though. |
@kevinb9n , it will also bee good to clarify what code is preferable (discussion at checkstyle/checkstyle#533):
vs
will be good to put that in style document to resolve any further discussions. |
That one is addressed here: https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.6.2-horizontal-whitespace "Beyond where required by the language or other style rules, and apart from literals, comments and Javadoc, a single ASCII space also appears in the following places only ." |
Empty Catch Block is implemented and released in Checkstyle 6.4, report was updated - "Last Published: 2015-02-28 | Version: 19.0-SNAPSHOT" in case you need to regenerate report please use that simple steps: https://github.com/checkstyle/checkstyle/wiki/How-to-generate-Checkstyle-report-for-Google-Guava-project FYI: |
New options "ignoreInlineTags" and "ignoredTags" for Single Line Javadoc were added and released in Checkstyle 6.8. |
CommentsIndentationCheck was introduced and reliased in Checkstyle 6.12. The Check covers the section 4.8.6.1 Block comment style from Google Java Style Guide. Report generated with Checkstyle 6.12 over Guava 19.0-SNAPSHOT with CommentsIndentationCheck shows 11 violations. |
guide is updated - https://google.github.io/styleguide/javaguide.html#s5.2.6-parameter-names
Clarification issue request was created to style project - google/styleguide#214
confirmation request - google/styleguide#215 |
I think this issue doesn't constitute a Guava bug (anymore), right? |
Affected Files:796
Violations: 4071
Google Java Style guide (version of March 21, 2014):
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html
Checkstyle Maven plugin report for Guava 17.0:
http://checkstyle.sourceforge.net/reports/google-style/guava/
All violations are thoroughly rechecked, but some very occasional false-positives could be present.
Detailed report (match of each Google Java Style rule to Checkstyle):
http://checkstyle.sourceforge.net/google_style.html
How to run (command line):
PS: all work was done during Google Summer of Code 2014
The text was updated successfully, but these errors were encountered: