rspec/rules/S1120/java/rule.adoc

86 lines
1.7 KiB
Plaintext

include::../introduction.adoc[]
== Why is this an issue?
include::../why.adoc[]
The rule behaves consistently when the indentation settings of the IDE use _spaces_ instead of _tabs_.
Using _tabs_ can lead to inconsistent indentation because the width of a _tab_ can be configured differently in different environments.
=== What is the potential impact?
include::../impact.adoc[]
== How to fix it
include::../how-to-fix.adoc[]
=== Code examples
==== Noncompliant code example
With an indent size of 2:
[source,java,diff-id=1,diff-type=noncompliant]
----
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
[source,java,diff-id=1,diff-type=compliant]
----
class Foo {
public int a;
public int b;
...
public void doSomething() {
if(something) {
doSomethingElse();
}
}
}
----
=== Going the extra mile
include::../extra-mile.adoc[]
== Resources
=== External coding guidelines
* https://google.github.io/styleguide/javaguide.html[Google Java Style Guide]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
=== on 18 Nov 2016, 08:38:56 Tibor Blenessy wrote:
The parameter key is called ``++indentationLevel++`` in the current implementation. Changing the key would be a breaking change, so I am changing the RSPEC to match the implementation.
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]