Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
// SONARJAVA-6028: FPs ahead. Only the line with "Too much." should be noncompliant.

void main() { // Noncompliant
System.out.println("Just right."); // Noncompliant
void main() {
System.out.println("Just right.");
if (true) {
System.out.println("Too much."); // Noncompliant
}
}

class MyClass { // Noncompliant
class MyClass {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some more stuff in this test file, some local fields, nested class, some more methods.

void myMethod() {
System.err.println("Error message");
}

static private class MyNestedClass {
private final static int VALUE = 42;
public float pi = 3.14f;
public String badlyIndentedField = "Oops"; // Noncompliant
public String secondBadlyIndentedField = "Oops x 2"; // Compliant, raised on previous line


void anotherMethod() {
System.out.println("Nested class output");
}
}
}

int i = 0;
public String badlyIndentedField = "Oops"; // Noncompliant
public String secondBadlyIndentedField = "Oops x 2"; // Compliant, raised on previous line
int j = 0;
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public void visitClass(ClassTree tree) {
excludeIssueAtLine = LineUtils.startLine(tree.openBraceToken());
expectedLevel = Position.startOf(tree.closeBraceToken()).columnOffset();
}
newBlock();
if (!tree.is(Kind.IMPLICIT_CLASS)) {
newBlock();
}
checkIndentation(tree.members());
super.visitClass(tree);
leaveNode(tree);
Expand Down
Loading