mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Don't force public variables to use Hungarian notation (#8774)
People generally have expressed a dislike for the Hungarian notation used in member variables, especially in examples/templates, and our styleguide shouldn't be forced on downstream consumers, so this removes all Hungarian notation from the examples/templates. There are _some_ benefits to Hungarian for private member variables (like knowing what's a member vs. local in a PR review) so we'll keep private member variables the same for now, but public variables should no longer use Hungarian notation, since it looks much worse. A new PMD XPath rule has been added to accomplish this goal. Some other non-compliant variables were fixed for the new rule.
This commit is contained in:
@@ -7,12 +7,12 @@ suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||
<suppress files=".*wpilibjIntegrationTests.*"
|
||||
checks="MissingJavadocMethod" />
|
||||
<suppress files="wpimath.*"
|
||||
checks="(LocalVariableName|MemberName|MethodName|MethodTypeParameterName|ParameterName)" />
|
||||
checks="(LocalVariableName|MethodName|MethodTypeParameterName|ParameterName)" />
|
||||
<suppress files=".*JNI.*"
|
||||
checks="(EmptyLineSeparator|LineLength|MissingJavadocMethod|ParameterName)" />
|
||||
<!-- Disable checks for generated protobuf files -->
|
||||
<suppress files=".*generated[/\\].*[/\\]proto[/\\].*"
|
||||
checks="(CustomImportOrder|EmptyLineSeparator|LeftCurly|LineLength|JavadocParagraph|MemberName|MissingJavadocMethod|OverloadMethodsDeclarationOrder|SummaryJavadoc|UnnecessaryParentheses|OperatorWrap|JavadocMethod|JavadocTagContinuationIndentation)" />
|
||||
checks="(CustomImportOrder|EmptyLineSeparator|LeftCurly|LineLength|JavadocParagraph|MissingJavadocMethod|OverloadMethodsDeclarationOrder|SummaryJavadoc|UnnecessaryParentheses|OperatorWrap|JavadocMethod|JavadocTagContinuationIndentation)" />
|
||||
<suppress files="wpilibj[/\\]src[/\\]generated.*"
|
||||
checks="MethodName" />
|
||||
<!-- Disable checkstyle for generated unit files -->
|
||||
|
||||
@@ -168,12 +168,6 @@ module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
<message key="name.invalidPattern"
|
||||
value="Type name ''{0}'' must match pattern ''{1}''." />
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format"
|
||||
value="^(m_([a-zA-Z]|[a-z][a-zA-Z0-9]+)|value)$" />
|
||||
<message key="name.invalidPattern"
|
||||
value="Member name ''{0}'' must match pattern ''{1}''." />
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format"
|
||||
value="^([a-zA-Z]|[a-z][a-zA-Z0-9]+)$" />
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<exclude-pattern>.*/Timestamped.*\.java</exclude-pattern>
|
||||
<exclude-pattern>.*/units/measure/.*\.java</exclude-pattern>
|
||||
|
||||
<exclude-pattern>.*/*IntegrationTests.*</exclude-pattern>
|
||||
<exclude-pattern>.*/*Examples.*</exclude-pattern>
|
||||
<exclude-pattern>.*/*JNI.*</exclude-pattern>
|
||||
<exclude-pattern>.*/math/proto.*</exclude-pattern>
|
||||
<exclude-pattern>.*/command3/proto.*</exclude-pattern>
|
||||
@@ -143,4 +143,22 @@
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
<rule name="PublicFieldNamingConvention"
|
||||
language="java"
|
||||
message="Public fields must follow lowerCamelCase."
|
||||
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
|
||||
<description>
|
||||
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ClassDeclaration[not(matches(@PackageName, "org.wpilib.math"))]/ClassBody/FieldDeclaration[@Visibility = 'public' and @Static = false()]/VariableDeclarator[not(matches(@Name, "^[a-z][a-zA-Z0-9]*$"))]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
||||
@@ -150,6 +150,10 @@
|
||||
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD" />
|
||||
<Class name="org.wpilib.epilogue.EpilogueConfiguration" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="URF_UNREAD_FIELD" />
|
||||
<Class name="org.wpilib.driverstation.internal.DriverStationBackend$HALJoystickAxesRaw" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- PMD will skip variables named `ignore`, but spotbugs isn't as smart -->
|
||||
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
|
||||
|
||||
Reference in New Issue
Block a user