Skip to content

Commit 7dd24c8

Browse files
committed
fix for Findbugs violations NM_CONFUSING. Issue #912
1 parent e1d0e7f commit 7dd24c8

6 files changed

Lines changed: 21 additions & 15 deletions

File tree

config/findbugs-exclude.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@
3434
<Class name="com.puppycrawl.tools.checkstyle.checks.indentation.LineWrappingHandler" />
3535
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
3636
</Match>
37+
<Match>
38+
<!-- till #922 -->
39+
<Class name="com.puppycrawl.tools.checkstyle.Checker" />
40+
<Method name="setClassloader" />
41+
<Bug pattern="NM_CONFUSING" />
42+
</Match>
3743
</FindBugsFilter>

src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public static DetailAST parse(FileContents contents)
467467
final String fullText = contents.getText().getFullText().toString();
468468
final Reader sr = new StringReader(fullText);
469469
final GeneratedJavaLexer lexer = new GeneratedJavaLexer(sr);
470-
lexer.setFilename(contents.getFilename());
470+
lexer.setFilename(contents.getFileName());
471471
lexer.setCommentListener(contents);
472472
lexer.setTreatAssertAsKeyword(true);
473473
lexer.setTreatEnumAsKeyword(true);
@@ -480,7 +480,7 @@ public static DetailAST parse(FileContents contents)
480480

481481
final GeneratedJavaRecognizer parser =
482482
new GeneratedJavaRecognizer(filter);
483-
parser.setFilename(contents.getFilename());
483+
parser.setFilename(contents.getFileName());
484484
parser.setASTNodeClass(DetailAST.class.getName());
485485
parser.compilationUnit();
486486

src/main/java/com/puppycrawl/tools/checkstyle/api/FileContents.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public final class FileContents implements CommentListener
4747
.compile(MATCH_SINGLELINE_COMMENT_PAT);
4848

4949
/** the file name */
50-
private final String filename;
50+
private final String fileName;
5151

5252
/** the text */
5353
private final FileText text;
@@ -76,7 +76,7 @@ public final class FileContents implements CommentListener
7676
*/
7777
@Deprecated public FileContents(String filename, String[] lines)
7878
{
79-
this.filename = filename;
79+
this.fileName = filename;
8080
text = FileText.fromLines(new File(filename), Arrays.asList(lines));
8181
}
8282

@@ -87,7 +87,7 @@ public final class FileContents implements CommentListener
8787
*/
8888
public FileContents(FileText text)
8989
{
90-
filename = text.getFile().toString();
90+
fileName = text.getFile().toString();
9191
this.text = text;
9292
}
9393

@@ -261,9 +261,9 @@ public String getLine(int index)
261261
}
262262

263263
/** @return the name of the file */
264-
public String getFilename()
264+
public String getFileName()
265265
{
266-
return filename;
266+
return fileName;
267267
}
268268

269269
/**
@@ -332,6 +332,6 @@ public boolean hasIntersectionWithComment(int startLineNo,
332332
*/
333333
public boolean inPackageInfo()
334334
{
335-
return this.getFilename().endsWith("package-info.java");
335+
return this.getFileName().endsWith("package-info.java");
336336
}
337337
}

src/main/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void finishTree(DetailAST rootAST)
111111
*/
112112
private String getFileName()
113113
{
114-
String fname = getFileContents().getFilename();
114+
String fname = getFileContents().getFileName();
115115
fname = fname.substring(fname.lastIndexOf(File.separatorChar) + 1);
116116
fname = fname.replaceAll("\\.[^\\.]*$", "");
117117
return fname;

src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public boolean isIncompleteTag()
111111
* Used for displaying a Checkstyle error.
112112
* @return an int line number.
113113
*/
114-
public int getLineno()
114+
public int getLineNo()
115115
{
116116
return lineNo;
117117
}

src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ private void checkHtml(final DetailAST ast, final TextBlock comment)
371371
final HtmlTag tag = parser.nextTag();
372372

373373
if (tag.isIncompleteTag()) {
374-
log(tag.getLineno(), INCOMPLETE_TAG,
375-
text[tag.getLineno() - lineno]);
374+
log(tag.getLineNo(), INCOMPLETE_TAG,
375+
text[tag.getLineNo() - lineno]);
376376
return;
377377
}
378378
if (tag.isClosedTag()) {
@@ -389,7 +389,7 @@ private void checkHtml(final DetailAST ast, final TextBlock comment)
389389
// We have found a close tag.
390390
if (isExtraHtml(tag.getId(), htmlStack)) {
391391
// No corresponding open tag was found on the stack.
392-
log(tag.getLineno(),
392+
log(tag.getLineNo(),
393393
tag.getPosition(),
394394
EXTRA_HTML,
395395
tag);
@@ -409,7 +409,7 @@ private void checkHtml(final DetailAST ast, final TextBlock comment)
409409
&& !htag.getId().equals(lastFound)
410410
&& !typeParameters.contains(htag.getId()))
411411
{
412-
log(htag.getLineno(), htag.getPosition(), UNCLOSED_HTML, htag);
412+
log(htag.getLineNo(), htag.getPosition(), UNCLOSED_HTML, htag);
413413
lastFound = htag.getId();
414414
}
415415
}
@@ -448,7 +448,7 @@ private void checkUnclosedTags(Deque<HtmlTag> htmlStack, String token)
448448
continue;
449449
}
450450
lastFound = lastOpenTag.getId();
451-
log(lastOpenTag.getLineno(),
451+
log(lastOpenTag.getLineNo(),
452452
lastOpenTag.getPosition(),
453453
UNCLOSED_HTML,
454454
lastOpenTag);

0 commit comments

Comments
 (0)