-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
approvedbugfalse positiveissues where check places violations on code, but should notissues where check places violations on code, but should notgoogle style
Milestone
Description
From: https://google.github.io/styleguide/javaguide.html#s5.3-camel-case
In very rare circumstances (for example, multipart version numbers), you may need to use underscores to separate adjacent numbers, since numbers do not have upper and lower case variants.
Correct version: guave33_4_6
incorrect version: guava3346
Code:
/** some javadoc. */
public class Test {
String guava33_4_6 = "Guava 33.4.6"; // False-positive
String guava3346 = "Guava 33.4.6"; // False-negative
String jdk8_0_392 = "Jdk 8.0.392"; // False-positive
String jdk80392 = "Jdk 8.0.392"; // False-negative
String kotlin1_9_24 = "Kotlin 1.9.24"; // False-positive
String kotlin1924 = "Kotlin 1.9.24"; // False-negative
String gradle8_5_1 = "Gradle 8.5.1"; // False-positive
String gradle851 = "Gradle 8.5.1"; // False-negative
}Cli:
$ java -jar checkstyle-10.26.1-all.jar -c google_checks.xml Test.java
Starting audit...
[WARN] /mnt/5D92528E6B945467/test/testing/Test.java:4:10: Member name 'guava33_4_6' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [MemberName]
[WARN] /mnt/5D92528E6B945467/test/testing/Test.java:7:10: Member name 'jdk8_0_392' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [MemberName]
[WARN] /mnt/5D92528E6B945467/test/testing/Test.java:10:10: Member name 'kotlin1_9_24' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [MemberName]
[WARN] /mnt/5D92528E6B945467/test/testing/Test.java:13:10: Member name 'gradle8_5_1' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [MemberName]
Audit done.
The style guide doesn't mention this explicitly, and we can have a discussion about it, but I think it's reasonable to assume that such naming conventions are likely intended only for member names.
After adding support for underscores between digits, coverage table should be updated.
Metadata
Metadata
Assignees
Labels
approvedbugfalse positiveissues where check places violations on code, but should notissues where check places violations on code, but should notgoogle style