Skip to content

Commit aca30c5

Browse files
committed
Avoid potential NPEs for String.equals() calls
1 parent 1536aa3 commit aca30c5

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

gradle/config/checkstyle/checkstyleMain.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
</module>
3737
<module name="HideUtilityClassConstructor"/>
3838
<module name="ModifierOrder"/>
39+
<module name="EqualsAvoidNull"/>
3940
</module>
4041

4142
<module name="JavadocPackage" />

junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationNameFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static ParameterizedInvocationNameFormatter create(ExtensionContext extensionCon
5757
ParameterizedDeclarationContext<?> declarationContext) {
5858

5959
String name = declarationContext.getDisplayNamePattern();
60-
String pattern = name.equals(DEFAULT_DISPLAY_NAME)
60+
String pattern = DEFAULT_DISPLAY_NAME.equals(name)
6161
? extensionContext.getConfigurationParameter(DISPLAY_NAME_PATTERN_KEY) //
6262
.orElse(DEFAULT_DISPLAY_NAME_PATTERN)
6363
: name;

junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private static boolean isRepeatableAnnotationContainer(Class<? extends Annotatio
381381
return repeatableAnnotationContainerCache.computeIfAbsent(candidateContainerType, candidate -> {
382382
// @formatter:off
383383
Repeatable repeatable = Arrays.stream(candidate.getMethods())
384-
.filter(attribute -> attribute.getName().equals("value") && attribute.getReturnType().isArray())
384+
.filter(attribute -> "value".equals(attribute.getName()) && attribute.getReturnType().isArray())
385385
.findFirst()
386386
.map(attribute -> attribute.getReturnType().getComponentType().getAnnotation(Repeatable.class))
387387
.orElse(null);

junit-platform-commons/src/main/java/org/junit/platform/commons/util/ModuleUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ List<Class<?>> scan(ModuleReference reference) {
223223
// @formatter:off
224224
return names.filter(name -> name.endsWith(".class"))
225225
.map(this::className)
226-
.filter(name -> !name.equals("module-info"))
226+
.filter(name -> !"module-info".equals(name))
227227
.filter(classFilter::match)
228228
.<Class<?>> map(this::loadClassUnchecked)
229229
.filter(classFilter::match)

platform-tooling-support-tests/src/main/java/platform/tooling/support/Helper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public static List<String> loadModuleDirectoryNames() {
5151
.filter(Matcher::matches) //
5252
.map(matcher -> matcher.group(1)) //
5353
.filter(name -> name.startsWith("junit-")) //
54-
.filter(name -> !name.equals("junit-bom")) //
55-
.filter(name -> !name.equals("junit-platform-console-standalone")).toList();
54+
.filter(name -> !"junit-bom".equals(name)) //
55+
.filter(name -> !"junit-platform-console-standalone".equals(name)).toList();
5656
}
5757
catch (Exception e) {
5858
throw new AssertionError("loading module directory names failed: " + SETTINGS_GRADLE);

0 commit comments

Comments
 (0)