Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit 604da69

Browse files
committed
Code cleanup
1 parent 950e2f2 commit 604da69

12 files changed

+16
-17
lines changed

core/src/main/java/dev/bannmann/mandor/core/Nodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static <T> Optional<T> findAncestor(HasParentNode<Node> node, Class<T> an
3636
return node.findAncestor(predicate, ancestorClass);
3737
}
3838

39-
public String getEnclosingTypeName(Node startingNode)
39+
public String obtainEnclosingTopLevelTypeName(Node startingNode)
4040
{
4141
String topmostTypeName = null;
4242
Node node = startingNode;

core/src/main/java/dev/bannmann/mandor/core/SourceRule.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ private void runTracked(AnnotationExpr annotationExpr, Runnable action)
4747

4848
if (!suppression.wasHit())
4949
{
50-
violations.add("%s needlessly suppresses %s in %s".formatted(Nodes.getEnclosingTypeName(annotationExpr),
51-
getClass().getSimpleName(),
52-
getContext().getCodeLocation(annotationExpr)));
50+
violations.add("%s needlessly suppresses %s in %s".formatted(Nodes.obtainEnclosingTopLevelTypeName(
51+
annotationExpr), getClass().getSimpleName(), getContext().getCodeLocation(annotationExpr)));
5352
}
5453
}
5554
}

core/src/main/java/dev/bannmann/mandor/core/rules/AssertStatementUsage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void visit(AssertStmt node, Void arg)
2323
super.visit(node, arg);
2424

2525
addViolation("%s contains an assert statement in %s",
26-
Nodes.getEnclosingTypeName(node),
26+
Nodes.obtainEnclosingTopLevelTypeName(node),
2727
getContext().getCodeLocation(node));
2828
}
2929

core/src/main/java/dev/bannmann/mandor/core/rules/BitwiseOperatorUsage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private void process(Expression expression)
5555
expression)));
5656

5757
addViolation("%s uses bitwise operator in %s",
58-
Nodes.getEnclosingTypeName(node),
58+
Nodes.obtainEnclosingTopLevelTypeName(node),
5959
getContext().getCodeLocation(node));
6060
}
6161

core/src/main/java/dev/bannmann/mandor/core/rules/MalformedExhaustiveSwitch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void process(AnnotationExpr annotation)
4747
if (!isUsedCorrectly(annotation))
4848
{
4949
addViolation("%s uses @ExhaustiveSwitch incorrectly in %s",
50-
Nodes.getEnclosingTypeName(annotation),
50+
Nodes.obtainEnclosingTopLevelTypeName(annotation),
5151
getContext().getCodeLocation(annotation));
5252
}
5353
}

core/src/main/java/dev/bannmann/mandor/core/rules/MissingSuppressionRationale.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private void verifyRationalePresent(SingleMemberAnnotationExpr suppressionAnnota
107107
: "warning";
108108

109109
addViolation("%s suppresses %s %s without giving rationale in %s",
110-
Nodes.getEnclosingTypeName(suppressionAnnotation),
110+
Nodes.obtainEnclosingTopLevelTypeName(suppressionAnnotation),
111111
what,
112112
suppressedWithoutRationale.stream()
113113
.sorted()

core/src/main/java/dev/bannmann/mandor/core/rules/NullabilityAnnotationOutsideNullMarkedCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private void process(AnnotationExpr annotation)
5353
}
5454

5555
addViolation("%s is not NullMarked but uses a jSpecify nullability annotation in %s",
56-
Nodes.getEnclosingTypeName(annotation),
56+
Nodes.obtainEnclosingTopLevelTypeName(annotation),
5757
getContext().getCodeLocation(annotation));
5858
}
5959

core/src/main/java/dev/bannmann/mandor/core/rules/OctalNumberUsage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void process(LiteralStringValueExpr node)
3333
if (octalDetector.isOctal(node.getValue()))
3434
{
3535
addViolation("%s contains an octal number literal in %s",
36-
Nodes.getEnclosingTypeName(node),
36+
Nodes.obtainEnclosingTopLevelTypeName(node),
3737
getContext().getCodeLocation(node));
3838
}
3939
}

core/src/main/java/dev/bannmann/mandor/core/rules/OrphanedSuppressionRationale.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void validateSuppressionExists(AnnotationExpr annotation)
6262
if (suppressionAnnotationOptional.isEmpty())
6363
{
6464
addViolation("%s gives a rationale without suppressing a warning in %s",
65-
Nodes.getEnclosingTypeName(annotation),
65+
Nodes.obtainEnclosingTopLevelTypeName(annotation),
6666
getContext().getCodeLocation(annotation));
6767
}
6868
}

core/src/main/java/dev/bannmann/mandor/core/rules/OvercomplicatedSuppressionRationale.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private void processAnnotation(NormalAnnotationExpr annotation)
4545
if (shouldUseSingleMemberForm(annotation))
4646
{
4747
addViolation("%s needlessly uses the full `value=\"\"` syntax for a rationale in %s",
48-
Nodes.getEnclosingTypeName(annotation),
48+
Nodes.obtainEnclosingTopLevelTypeName(annotation),
4949
getContext().getCodeLocation(annotation));
5050
}
5151
}
@@ -86,7 +86,7 @@ private void validateMultipleSuppressionsExist(NormalAnnotationExpr annotation)
8686
.isEmpty())
8787
{
8888
addViolation("%s needlessly specifies a suppression name for a rationale in %s",
89-
Nodes.getEnclosingTypeName(annotation),
89+
Nodes.obtainEnclosingTopLevelTypeName(annotation),
9090
getContext().getCodeLocation(annotation));
9191
}
9292
}

0 commit comments

Comments
 (0)