mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -11,7 +11,6 @@ import java.util.Objects;
|
||||
*
|
||||
* <p>Limited to 12 bits of precision.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public class Color {
|
||||
/** Red component (0-1). */
|
||||
public final double red;
|
||||
|
||||
@@ -7,7 +7,6 @@ package org.wpilib.util;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Represents colors with 8 bits of precision. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class Color8Bit {
|
||||
/** Red component (0-255). */
|
||||
public final int red;
|
||||
|
||||
@@ -34,19 +34,15 @@ public enum StructFieldType {
|
||||
STRUCT("struct", false, false, 0);
|
||||
|
||||
/** The name of the data type. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String name;
|
||||
|
||||
/** Indicates if the data type is a signed integer. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final boolean isInt;
|
||||
|
||||
/** Indicates if the data type is an unsigned integer. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final boolean isUint;
|
||||
|
||||
/** The size (in bytes) of the data type. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int size;
|
||||
|
||||
StructFieldType(String name, boolean isInt, boolean isUint, int size) {
|
||||
|
||||
@@ -9,23 +9,18 @@ import java.util.Map;
|
||||
/** Raw struct schema declaration. */
|
||||
public class ParsedDeclaration {
|
||||
/** Type string. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String typeString;
|
||||
|
||||
/** Name. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String name;
|
||||
|
||||
/** Enum values. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public Map<String, Long> enumValues;
|
||||
|
||||
/** Array size. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int arraySize = 1;
|
||||
|
||||
/** Bit width. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int bitWidth;
|
||||
|
||||
/** Default constructor. */
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.util.List;
|
||||
/** Raw struct schema. */
|
||||
public class ParsedSchema {
|
||||
/** Declarations. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public List<ParsedDeclaration> declarations = new ArrayList<>();
|
||||
|
||||
/** Default constructor. */
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class CleanupPoolTest {
|
||||
@SuppressWarnings("PMD.PublicFieldNamingConvention")
|
||||
static class AutoCloseableObject implements AutoCloseable {
|
||||
public boolean m_closed;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ReflectionCleanupTest {
|
||||
@SuppressWarnings("PMD.PublicFieldNamingConvention")
|
||||
static class CleanupClass implements AutoCloseable {
|
||||
public boolean m_closed;
|
||||
|
||||
@@ -19,7 +20,7 @@ class ReflectionCleanupTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.TestClassWithoutTestCases")
|
||||
@SuppressWarnings({"PMD.TestClassWithoutTestCases", "PMD.PublicFieldNamingConvention"})
|
||||
static class CleanupTest implements ReflectionCleanup {
|
||||
public CleanupClass m_class1 = new CleanupClass();
|
||||
public CleanupClass m_class2 = new CleanupClass();
|
||||
@@ -32,6 +33,7 @@ class ReflectionCleanupTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.PublicFieldNamingConvention")
|
||||
static class CleanupTest2 extends CleanupTest {
|
||||
@SkipCleanup public CleanupClass m_class3 = new CleanupClass();
|
||||
public CleanupClass m_class4 = new CleanupClass();
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@SuppressWarnings("AvoidEscapedUnicodeCharacters")
|
||||
class DynamicStructTest {
|
||||
@SuppressWarnings("MemberName")
|
||||
private StructDescriptorDatabase db;
|
||||
|
||||
@BeforeEach
|
||||
|
||||
Reference in New Issue
Block a user