All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.IndentationCheck.html Maven / Gradle / Ivy

The newest version!

Proper indentation is a simple and effective way to improve the code's readability. Consistent indentation among the developers on a team also reduces the differences that are committed to source control systems, making code reviews easier.

By default this rule checks that each block of code is indented but not the size of this indent. The parameter "indentSize" allows the expected indent size to be defined. Only the first line of a badly indented section is reported.

The following code illustrates this rule when the expected indent size is set to 2:

Noncompliant Code Example

class Foo {
  public int a; 
   public int b;   // Noncompliant, expected to start at column 4

...

  public void doSomething() {
    if(something) {
          doSomethingElse();  // Noncompliant, expected to start at column 6
  }   // Noncompliant, expected to start at column 4
  }
}

Compliant Solution

class Foo {
  public int a; 
  public int b; 

...

  public void doSomething() {
    if(something) {
        doSomethingElse();
    } 
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy