Skip to content

Commit b7feedf

Browse files
committed
Add new rules
1 parent 33b2266 commit b7feedf

84 files changed

Lines changed: 1455 additions & 1450 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class AprilTag {
1616
/** The tag's ID. */
1717
@Json.Property("ID")
18-
@SuppressWarnings("MemberName")
18+
@SuppressWarnings("PMD.PublicFieldNamingConvention")
1919
public int ID;
2020

2121
/** The tag's pose. */

apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public enum OriginPosition {
5151
@Json.Ignore private final Map<Integer, AprilTag> m_apriltags = new HashMap<>();
5252

5353
@Json.Property("field")
54+
@SuppressWarnings("PMD.PublicFieldNamingConvention")
5455
FieldDimensions m_fieldDimensions;
5556

5657
@Json.Ignore private Pose3d m_origin;
@@ -216,19 +217,19 @@ public void serialize(Path path) throws IOException {
216217
* @throws UncheckedIOException If the layout does not exist.
217218
*/
218219
public static AprilTagFieldLayout loadField(AprilTagFields field) {
219-
if (field.m_fieldLayout == null) {
220+
if (field.fieldLayout == null) {
220221
try {
221-
field.m_fieldLayout = loadFromResource(field.resourceFile);
222+
field.fieldLayout = loadFromResource(field.resourceFile);
222223
} catch (IOException e) {
223224
throw new UncheckedIOException(
224225
"Could not load AprilTagFieldLayout from " + field.resourceFile, e);
225226
}
226227
}
227228
// Copy layout because the layout's origin is mutable
228229
return new AprilTagFieldLayout(
229-
field.m_fieldLayout.getTags(),
230-
field.m_fieldLayout.getFieldLength(),
231-
field.m_fieldLayout.getFieldWidth());
230+
field.fieldLayout.getTags(),
231+
field.fieldLayout.getFieldLength(),
232+
field.fieldLayout.getFieldWidth());
232233
}
233234

234235
/**
@@ -263,6 +264,7 @@ public int hashCode() {
263264
return Objects.hash(m_apriltags, m_origin);
264265
}
265266

267+
@SuppressWarnings("PMD.PublicMemberInNonPublicType")
266268
static class FieldDimensions {
267269
@Json.Property(value = "length")
268270
public final double fieldLength;

apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public enum AprilTagFields {
3030
/** Resource filename. */
3131
public final String resourceFile;
3232

33-
AprilTagFieldLayout m_fieldLayout;
33+
AprilTagFieldLayout fieldLayout;
3434

3535
AprilTagFields(String resourceFile) {
3636
this.resourceFile = kBaseResourceDir + resourceFile;

apriltag/src/test/java/org/wpilib/vision/apriltag/AprilTagDetectorTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.wpilib.util.runtime.RuntimeLoader;
2626

2727
class AprilTagDetectorTest {
28-
@SuppressWarnings("MemberName")
2928
AprilTagDetector detector;
3029

3130
@BeforeAll
@@ -110,7 +109,7 @@ void testRemoveFamily() {
110109
detector.removeFamily("tag16h5");
111110
}
112111

113-
public Mat loadImage(String resource) throws IOException {
112+
Mat loadImage(String resource) throws IOException {
114113
Mat encoded;
115114
try (InputStream is = getClass().getResource(resource).openStream()) {
116115
try (ByteArrayOutputStream os = new ByteArrayOutputStream(is.available())) {

cameraserver/src/main/java/org/wpilib/vision/stream/CameraServer.java

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,28 @@ private static final class PropertyPublisher implements AutoCloseable {
6060
try {
6161
switch (event.propertyKind) {
6262
case kBoolean:
63-
m_booleanValueEntry = table.getBooleanTopic(name).getEntry(false);
64-
m_booleanValueEntry.setDefault(event.value != 0);
63+
booleanValueEntry = table.getBooleanTopic(name).getEntry(false);
64+
booleanValueEntry.setDefault(event.value != 0);
6565
break;
6666
case kEnum:
67-
m_choicesTopic = table.getStringArrayTopic(infoName + "/choices");
67+
choicesTopic = table.getStringArrayTopic(infoName + "/choices");
6868
// fallthrough
6969
case kInteger:
70-
m_integerValueEntry = table.getIntegerTopic(name).getEntry(0);
71-
m_minPublisher = table.getIntegerTopic(infoName + "/min").publish();
72-
m_maxPublisher = table.getIntegerTopic(infoName + "/max").publish();
73-
m_stepPublisher = table.getIntegerTopic(infoName + "/step").publish();
74-
m_defaultPublisher = table.getIntegerTopic(infoName + "/default").publish();
75-
76-
m_integerValueEntry.setDefault(event.value);
77-
m_minPublisher.set(CameraServerJNI.getPropertyMin(event.propertyHandle));
78-
m_maxPublisher.set(CameraServerJNI.getPropertyMax(event.propertyHandle));
79-
m_stepPublisher.set(CameraServerJNI.getPropertyStep(event.propertyHandle));
80-
m_defaultPublisher.set(CameraServerJNI.getPropertyDefault(event.propertyHandle));
70+
integerValueEntry = table.getIntegerTopic(name).getEntry(0);
71+
minPublisher = table.getIntegerTopic(infoName + "/min").publish();
72+
maxPublisher = table.getIntegerTopic(infoName + "/max").publish();
73+
stepPublisher = table.getIntegerTopic(infoName + "/step").publish();
74+
defaultPublisher = table.getIntegerTopic(infoName + "/default").publish();
75+
76+
integerValueEntry.setDefault(event.value);
77+
minPublisher.set(CameraServerJNI.getPropertyMin(event.propertyHandle));
78+
maxPublisher.set(CameraServerJNI.getPropertyMax(event.propertyHandle));
79+
stepPublisher.set(CameraServerJNI.getPropertyStep(event.propertyHandle));
80+
defaultPublisher.set(CameraServerJNI.getPropertyDefault(event.propertyHandle));
8181
break;
8282
case kString:
83-
m_stringValueEntry = table.getStringTopic(name).getEntry("");
84-
m_stringValueEntry.setDefault(event.valueStr);
83+
stringValueEntry = table.getStringTopic(name).getEntry("");
84+
stringValueEntry.setDefault(event.valueStr);
8585
break;
8686
default:
8787
break;
@@ -94,18 +94,18 @@ private static final class PropertyPublisher implements AutoCloseable {
9494
void update(VideoEvent event) {
9595
switch (event.propertyKind) {
9696
case kBoolean -> {
97-
if (m_booleanValueEntry != null) {
98-
m_booleanValueEntry.set(event.value != 0);
97+
if (booleanValueEntry != null) {
98+
booleanValueEntry.set(event.value != 0);
9999
}
100100
}
101101
case kInteger, kEnum -> {
102-
if (m_integerValueEntry != null) {
103-
m_integerValueEntry.set(event.value);
102+
if (integerValueEntry != null) {
103+
integerValueEntry.set(event.value);
104104
}
105105
}
106106
case kString -> {
107-
if (m_stringValueEntry != null) {
108-
m_stringValueEntry.set(event.valueStr);
107+
if (stringValueEntry != null) {
108+
stringValueEntry.set(event.valueStr);
109109
}
110110
}
111111
default -> {
@@ -117,91 +117,91 @@ void update(VideoEvent event) {
117117
@Override
118118
public void close() {
119119
try {
120-
if (m_booleanValueEntry != null) {
121-
m_booleanValueEntry.close();
120+
if (booleanValueEntry != null) {
121+
booleanValueEntry.close();
122122
}
123-
if (m_integerValueEntry != null) {
124-
m_integerValueEntry.close();
123+
if (integerValueEntry != null) {
124+
integerValueEntry.close();
125125
}
126-
if (m_stringValueEntry != null) {
127-
m_stringValueEntry.close();
126+
if (stringValueEntry != null) {
127+
stringValueEntry.close();
128128
}
129-
if (m_minPublisher != null) {
130-
m_minPublisher.close();
129+
if (minPublisher != null) {
130+
minPublisher.close();
131131
}
132-
if (m_maxPublisher != null) {
133-
m_maxPublisher.close();
132+
if (maxPublisher != null) {
133+
maxPublisher.close();
134134
}
135-
if (m_stepPublisher != null) {
136-
m_stepPublisher.close();
135+
if (stepPublisher != null) {
136+
stepPublisher.close();
137137
}
138-
if (m_defaultPublisher != null) {
139-
m_defaultPublisher.close();
138+
if (defaultPublisher != null) {
139+
defaultPublisher.close();
140140
}
141-
if (m_choicesPublisher != null) {
142-
m_choicesPublisher.close();
141+
if (choicesPublisher != null) {
142+
choicesPublisher.close();
143143
}
144144
} finally {
145145
Reference.reachabilityFence(m_videoListener);
146146
}
147147
}
148148

149-
BooleanEntry m_booleanValueEntry;
150-
IntegerEntry m_integerValueEntry;
151-
StringEntry m_stringValueEntry;
152-
IntegerPublisher m_minPublisher;
153-
IntegerPublisher m_maxPublisher;
154-
IntegerPublisher m_stepPublisher;
155-
IntegerPublisher m_defaultPublisher;
156-
StringArrayTopic m_choicesTopic;
157-
StringArrayPublisher m_choicesPublisher;
149+
BooleanEntry booleanValueEntry;
150+
IntegerEntry integerValueEntry;
151+
StringEntry stringValueEntry;
152+
IntegerPublisher minPublisher;
153+
IntegerPublisher maxPublisher;
154+
IntegerPublisher stepPublisher;
155+
IntegerPublisher defaultPublisher;
156+
StringArrayTopic choicesTopic;
157+
StringArrayPublisher choicesPublisher;
158158
}
159159

160160
private static final class SourcePublisher implements AutoCloseable {
161161
SourcePublisher(NetworkTable table, int sourceHandle) {
162-
this.m_table = table;
163-
m_sourcePublisher = table.getStringTopic("source").publish();
164-
m_descriptionPublisher = table.getStringTopic("description").publish();
165-
m_connectedPublisher = table.getBooleanTopic("connected").publish();
166-
m_streamsPublisher = table.getStringArrayTopic("streams").publish();
167-
m_modeEntry = table.getStringTopic("mode").getEntry("");
168-
m_modesPublisher = table.getStringArrayTopic("modes").publish();
169-
170-
m_sourcePublisher.set(makeSourceValue(sourceHandle));
171-
m_descriptionPublisher.set(CameraServerJNI.getSourceDescription(sourceHandle));
172-
m_connectedPublisher.set(CameraServerJNI.isSourceConnected(sourceHandle));
173-
m_streamsPublisher.set(getSourceStreamValues(sourceHandle));
162+
this.table = table;
163+
sourceUriPublisher = table.getStringTopic("source").publish();
164+
descriptionPublisher = table.getStringTopic("description").publish();
165+
connectedPublisher = table.getBooleanTopic("connected").publish();
166+
streamsPublisher = table.getStringArrayTopic("streams").publish();
167+
modeEntry = table.getStringTopic("mode").getEntry("");
168+
modesPublisher = table.getStringArrayTopic("modes").publish();
169+
170+
sourceUriPublisher.set(makeSourceValue(sourceHandle));
171+
descriptionPublisher.set(CameraServerJNI.getSourceDescription(sourceHandle));
172+
connectedPublisher.set(CameraServerJNI.isSourceConnected(sourceHandle));
173+
streamsPublisher.set(getSourceStreamValues(sourceHandle));
174174

175175
try {
176176
VideoMode mode = CameraServerJNI.getSourceVideoMode(sourceHandle);
177-
m_modeEntry.setDefault(videoModeToString(mode));
178-
m_modesPublisher.set(getSourceModeValues(sourceHandle));
177+
modeEntry.setDefault(videoModeToString(mode));
178+
modesPublisher.set(getSourceModeValues(sourceHandle));
179179
} catch (VideoException ignored) {
180180
// Do nothing. Let the other event handlers update this if there is an error.
181181
}
182182
}
183183

184184
@Override
185185
public void close() throws Exception {
186-
m_sourcePublisher.close();
187-
m_descriptionPublisher.close();
188-
m_connectedPublisher.close();
189-
m_streamsPublisher.close();
190-
m_modeEntry.close();
191-
m_modesPublisher.close();
192-
for (PropertyPublisher pp : m_properties.values()) {
186+
sourceUriPublisher.close();
187+
descriptionPublisher.close();
188+
connectedPublisher.close();
189+
streamsPublisher.close();
190+
modeEntry.close();
191+
modesPublisher.close();
192+
for (PropertyPublisher pp : properties.values()) {
193193
pp.close();
194194
}
195195
}
196196

197-
final NetworkTable m_table;
198-
final StringPublisher m_sourcePublisher;
199-
final StringPublisher m_descriptionPublisher;
200-
final BooleanPublisher m_connectedPublisher;
201-
final StringArrayPublisher m_streamsPublisher;
202-
final StringEntry m_modeEntry;
203-
final StringArrayPublisher m_modesPublisher;
204-
final Map<Integer, PropertyPublisher> m_properties = new HashMap<>();
197+
final NetworkTable table;
198+
final StringPublisher sourceUriPublisher;
199+
final StringPublisher descriptionPublisher;
200+
final BooleanPublisher connectedPublisher;
201+
final StringArrayPublisher streamsPublisher;
202+
final StringEntry modeEntry;
203+
final StringArrayPublisher modesPublisher;
204+
final Map<Integer, PropertyPublisher> properties = new HashMap<>();
205205
}
206206

207207
private static final AtomicInteger m_defaultUsbDevice = new AtomicInteger();
@@ -253,40 +253,40 @@ public void close() throws Exception {
253253
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
254254
if (publisher != null) {
255255
// update the description too (as it may have changed)
256-
publisher.m_descriptionPublisher.set(
256+
publisher.descriptionPublisher.set(
257257
CameraServerJNI.getSourceDescription(event.sourceHandle));
258-
publisher.m_connectedPublisher.set(true);
258+
publisher.connectedPublisher.set(true);
259259
}
260260
}
261261
case kSourceDisconnected -> {
262262
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
263263
if (publisher != null) {
264-
publisher.m_connectedPublisher.set(false);
264+
publisher.connectedPublisher.set(false);
265265
}
266266
}
267267
case kSourceVideoModesUpdated -> {
268268
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
269269
if (publisher != null) {
270-
publisher.m_modesPublisher.set(getSourceModeValues(event.sourceHandle));
270+
publisher.modesPublisher.set(getSourceModeValues(event.sourceHandle));
271271
}
272272
}
273273
case kSourceVideoModeChanged -> {
274274
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
275275
if (publisher != null) {
276-
publisher.m_modeEntry.set(videoModeToString(event.mode));
276+
publisher.modeEntry.set(videoModeToString(event.mode));
277277
}
278278
}
279279
case kSourcePropertyCreated -> {
280280
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
281281
if (publisher != null) {
282-
publisher.m_properties.put(
283-
event.propertyHandle, new PropertyPublisher(publisher.m_table, event));
282+
publisher.properties.put(
283+
event.propertyHandle, new PropertyPublisher(publisher.table, event));
284284
}
285285
}
286286
case kSourcePropertyValueUpdated -> {
287287
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
288288
if (publisher != null) {
289-
PropertyPublisher pp = publisher.m_properties.get(event.propertyHandle);
289+
PropertyPublisher pp = publisher.properties.get(event.propertyHandle);
290290
if (pp != null) {
291291
pp.update(event);
292292
}
@@ -295,15 +295,15 @@ public void close() throws Exception {
295295
case kSourcePropertyChoicesUpdated -> {
296296
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
297297
if (publisher != null) {
298-
PropertyPublisher pp = publisher.m_properties.get(event.propertyHandle);
299-
if (pp != null && pp.m_choicesTopic != null) {
298+
PropertyPublisher pp = publisher.properties.get(event.propertyHandle);
299+
if (pp != null && pp.choicesTopic != null) {
300300
try {
301301
String[] choices =
302302
CameraServerJNI.getEnumPropertyChoices(event.propertyHandle);
303-
if (pp.m_choicesPublisher == null) {
304-
pp.m_choicesPublisher = pp.m_choicesTopic.publish();
303+
if (pp.choicesPublisher == null) {
304+
pp.choicesPublisher = pp.choicesTopic.publish();
305305
}
306-
pp.m_choicesPublisher.set(choices);
306+
pp.choicesPublisher.set(choices);
307307
} catch (VideoException ignored) {
308308
// ignore (just don't publish choices if we can't get them)
309309
}
@@ -459,7 +459,7 @@ private static synchronized void updateStreamValues() {
459459
// Set table value
460460
String[] values = getSinkStreamValues(sink);
461461
if (values.length > 0) {
462-
publisher.m_streamsPublisher.set(values);
462+
publisher.streamsPublisher.set(values);
463463
}
464464
}
465465
}
@@ -474,7 +474,7 @@ private static synchronized void updateStreamValues() {
474474
// Set table value
475475
String[] values = getSourceStreamValues(source);
476476
if (values.length > 0) {
477-
publisher.m_streamsPublisher.set(values);
477+
publisher.streamsPublisher.set(values);
478478
}
479479
}
480480
}

commandsv2/src/main/java/org/wpilib/command2/button/Trigger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public Trigger debounce(double seconds, Debouncer.DebounceType type) {
280280
return new Trigger(
281281
m_loop,
282282
new BooleanSupplier() {
283-
final Debouncer m_debouncer = new Debouncer(seconds, type);
283+
private final Debouncer m_debouncer = new Debouncer(seconds, type);
284284

285285
@Override
286286
public boolean getAsBoolean() {

0 commit comments

Comments
 (0)