File tree Expand file tree Collapse file tree 3 files changed +5
-18
lines changed
main/java/org/sonar/java/checks Expand file tree Collapse file tree 3 files changed +5
-18
lines changed Original file line number Diff line number Diff line change 1
1
java-frontend /src /test /files /highlighter /SonarSymTable.java eol =lf
2
+ java-checks /src /test /files /checks /NonEmptyFile.java eol =cr
Original file line number Diff line number Diff line change 21
21
22
22
import org .sonar .check .Rule ;
23
23
import org .sonar .java .RspecKey ;
24
- import org .sonar .plugins .java .api .IssuableSubscriptionVisitor ;
24
+ import org .sonar .plugins .java .api .JavaFileScanner ;
25
25
import org .sonar .plugins .java .api .JavaFileScannerContext ;
26
- import org .sonar .plugins .java .api .tree .Tree ;
27
-
28
- import java .util .Collections ;
29
- import java .util .List ;
30
26
31
27
@ Rule (key = "S00113" )
32
28
@ RspecKey ("S113" )
33
- public class MissingNewLineAtEndOfFileCheck extends IssuableSubscriptionVisitor {
29
+ public class MissingNewLineAtEndOfFileCheck implements JavaFileScanner {
34
30
35
- @ Override
36
- public List <Tree .Kind > nodesToVisit () {
37
- return Collections .emptyList ();
38
- }
39
31
40
32
@ Override
41
33
public void scanFile (JavaFileScannerContext context ) {
42
- super .context = context ;
43
34
String content = context .getFileContent ();
44
- if (content .isEmpty ()) {
45
- return ;
46
- }
47
-
48
35
char lastChar = content .charAt (content .length () - 1 );
49
36
if ( lastChar != '\n' && lastChar != '\r' ) {
50
- addIssueOnFile ("Add a new line at the end of this file." );
37
+ context . addIssueOnFile (this , "Add a new line at the end of this file." );
51
38
}
52
39
}
53
40
}
Original file line number Diff line number Diff line change 1
- class NonEmptyFile {
2
- }
1
+ class NonEmptyFile { }
You can’t perform that action at this time.
0 commit comments