Skip to content

Commit b2a52ef

Browse files
committed
Fix some lint names (file -> path, ruleId -> shortCode)
1 parent 2ce9803 commit b2a52ef

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

lib/src/main/java/com/diffplug/spotless/Lint.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ public static Lint atLine(int line, String ruleId, String detail) {
3737
return new Lint(line, ruleId, detail);
3838
}
3939

40-
public static Lint atLineRange(int lineStart, int lineEnd, String ruleId, String detail) {
41-
return new Lint(lineStart, lineEnd, ruleId, detail);
40+
public static Lint atLineRange(int lineStart, int lineEnd, String shortCode, String detail) {
41+
return new Lint(lineStart, lineEnd, shortCode, detail);
4242
}
4343

4444
private static final long serialVersionUID = 1L;
4545

4646
private int lineStart, lineEnd; // 1-indexed, inclusive
47-
private String ruleId; // e.g. CN_IDIOM https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#cn-class-implements-cloneable-but-does-not-define-or-use-clone-method-cn-idiom
47+
private String shortCode; // e.g. CN_IDIOM https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#cn-class-implements-cloneable-but-does-not-define-or-use-clone-method-cn-idiom
4848
private String detail;
4949

50-
private Lint(int lineStart, int lineEnd, String ruleId, String detail) {
50+
private Lint(int lineStart, int lineEnd, String shortCode, String detail) {
5151
if (lineEnd < lineStart) {
5252
throw new IllegalArgumentException("lineEnd must be >= lineStart: lineStart=" + lineStart + " lineEnd=" + lineEnd);
5353
}
5454
this.lineStart = lineStart;
5555
this.lineEnd = lineEnd;
56-
this.ruleId = LineEnding.toUnix(ruleId);
56+
this.shortCode = LineEnding.toUnix(shortCode);
5757
this.detail = LineEnding.toUnix(detail);
5858
}
5959

60-
private Lint(int line, String ruleId, String detail) {
61-
this(line, line, ruleId, detail);
60+
private Lint(int line, String shortCode, String detail) {
61+
this(line, line, shortCode, detail);
6262
}
6363

6464
public int getLineStart() {
@@ -69,8 +69,8 @@ public int getLineEnd() {
6969
return lineEnd;
7070
}
7171

72-
public String getRuleId() {
73-
return ruleId;
72+
public String getShortCode() {
73+
return shortCode;
7474
}
7575

7676
public String getDetail() {
@@ -115,12 +115,12 @@ public RuntimeException shortcut() {
115115
public String toString() {
116116
if (lineStart == lineEnd) {
117117
if (lineStart == LINE_UNDEFINED) {
118-
return "LINE_UNDEFINED: (" + ruleId + ") " + detail;
118+
return "LINE_UNDEFINED: (" + shortCode + ") " + detail;
119119
} else {
120-
return "L" + lineStart + ": (" + ruleId + ") " + detail;
120+
return "L" + lineStart + ": (" + shortCode + ") " + detail;
121121
}
122122
} else {
123-
return "L" + lineStart + "-" + lineEnd + ": (" + ruleId + ") " + detail;
123+
return "L" + lineStart + "-" + lineEnd + ": (" + shortCode + ") " + detail;
124124
}
125125
}
126126

@@ -131,12 +131,12 @@ public boolean equals(Object o) {
131131
if (o == null || getClass() != o.getClass())
132132
return false;
133133
Lint lint = (Lint) o;
134-
return lineStart == lint.lineStart && lineEnd == lint.lineEnd && Objects.equals(ruleId, lint.ruleId) && Objects.equals(detail, lint.detail);
134+
return lineStart == lint.lineStart && lineEnd == lint.lineEnd && Objects.equals(shortCode, lint.shortCode) && Objects.equals(detail, lint.detail);
135135
}
136136

137137
@Override
138138
public int hashCode() {
139-
return Objects.hash(lineStart, lineEnd, ruleId, detail);
139+
return Objects.hash(lineStart, lineEnd, shortCode, detail);
140140
}
141141

142142
/** Attempts to parse a line number from the given exception. */
@@ -201,7 +201,7 @@ public void addWarningMessageTo(StringBuilder buffer, String stepName, boolean o
201201
}
202202
}
203203
buffer.append(" ");
204-
buffer.append(stepName).append("(").append(ruleId).append(") ");
204+
buffer.append(stepName).append("(").append(shortCode).append(") ");
205205

206206
int firstNewline = detail.indexOf('\n');
207207
if (firstNewline == -1) {

lib/src/main/java/com/diffplug/spotless/LintSuppression.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ public class LintSuppression implements java.io.Serializable {
2121
private static final long serialVersionUID = 1L;
2222

2323
private static final String ALL = "*";
24-
private String file = ALL;
24+
private String path = ALL;
2525
private String step = ALL;
2626
private String shortCode = ALL;
2727

28-
public String getFile() {
29-
return file;
28+
public String getPath() {
29+
return path;
3030
}
3131

32-
public void setFile(String file) {
33-
this.file = Objects.requireNonNull(file);
32+
public void setPath(String path) {
33+
this.path = Objects.requireNonNull(path);
3434
}
3535

3636
public String getStep() {
@@ -50,9 +50,9 @@ public void setShortCode(String shortCode) {
5050
}
5151

5252
public boolean suppresses(String relativePath, FormatterStep formatterStep, Lint lint) {
53-
if (file.equals(ALL) || file.equals(relativePath)) {
53+
if (path.equals(ALL) || path.equals(relativePath)) {
5454
if (step.equals(ALL) || formatterStep.getName().equals(this.step)) {
55-
if (shortCode.equals(ALL) || lint.getRuleId().equals(this.shortCode)) {
55+
if (shortCode.equals(ALL) || lint.getShortCode().equals(this.shortCode)) {
5656
return true;
5757
}
5858
}
@@ -61,7 +61,7 @@ public boolean suppresses(String relativePath, FormatterStep formatterStep, Lint
6161
}
6262

6363
public void ensureDoesNotSuppressAll() {
64-
boolean suppressAll = file.equals(ALL) && step.equals(ALL) && shortCode.equals(ALL);
64+
boolean suppressAll = path.equals(ALL) && step.equals(ALL) && shortCode.equals(ALL);
6565
if (suppressAll) {
6666
throw new IllegalArgumentException("You must specify a specific `file`, `step`, or `shortCode`.");
6767
}
@@ -74,18 +74,18 @@ public boolean equals(Object o) {
7474
if (o == null || getClass() != o.getClass())
7575
return false;
7676
LintSuppression that = (LintSuppression) o;
77-
return Objects.equals(file, that.file) && Objects.equals(step, that.step) && Objects.equals(shortCode, that.shortCode);
77+
return Objects.equals(path, that.path) && Objects.equals(step, that.step) && Objects.equals(shortCode, that.shortCode);
7878
}
7979

8080
@Override
8181
public int hashCode() {
82-
return Objects.hash(file, step, shortCode);
82+
return Objects.hash(path, step, shortCode);
8383
}
8484

8585
@Override
8686
public String toString() {
8787
return "LintSuppression{" +
88-
"file='" + file + '\'' +
88+
"file='" + path + '\'' +
8989
", step='" + step + '\'' +
9090
", code='" + shortCode + '\'' +
9191
'}';

lib/src/test/java/com/diffplug/spotless/LintSuppressionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public void testMatchSingle() {
5050
assertThat(noSuppressions.isHasLints()).isTrue();
5151
removesLint(s -> s.setStep("blah")).isFalse();
5252
removesLint(s -> s.setStep("endWithNewline")).isTrue();
53-
removesLint(s -> s.setFile("blah")).isFalse();
54-
removesLint(s -> s.setFile("testFile")).isTrue();
53+
removesLint(s -> s.setPath("blah")).isFalse();
54+
removesLint(s -> s.setPath("testFile")).isTrue();
5555
removesLint(s -> s.setShortCode("blah")).isFalse();
5656
removesLint(s -> s.setShortCode("66")).isTrue();
5757
}

0 commit comments

Comments
 (0)