Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/checkstyle/checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav-Punjabi committed Mar 24, 2020
2 parents 01743ae + 611a963 commit 0427f9f
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,50 @@
* <pre>
* &lt;module name=&quot;InnerAssignment"/&gt;
* </pre>
* <p>Example:</p>
* <pre>
* class MyClass {
*
* void foo() {
* int a, b;
* a = b = 5; // violation, assignment to each variable should be in a separate statement
* a = b += 5; // violation
*
* a = 5; // OK
* b = 5; // OK
* a = 5; b = 5; // OK
*
* double myDouble;
* double[] doubleArray = new double[] {myDouble = 4.5, 15.5}; // violation
*
* String nameOne;
* List&lt;String&gt; myList = new ArrayList&lt;String&gt;();
* myList.add(nameOne = "tom"); // violation
* for (int k = 0; k &lt; 10; k = k + 2) { // OK
* // some code
* }
*
* boolean someVal;
* if (someVal = true) { // violation
* // some code
* }
*
* while (someVal = false) {} // violation
*
* InputStream is = new FileInputStream("textFile.txt");
* while ((b = is.read()) != -1) { // OK, this is a common idiom
* // some code
* }
*
* }
*
* boolean testMethod() {
* boolean val;
* return val = true; // violation
* }
* }
* </pre>
*
* @since 3.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,40 @@
* <pre>
* &lt;module name="InterfaceIsType"/&gt;
* </pre>
* <p>Example:</p>
* <pre>
* public interface Test1 { // violation
* int a = 3;
*
* }
*
* public interface Test2 { // OK
*
* }
*
* public interface Test3 { // OK
* int a = 3;
* void test();
* }
* </pre>
* <p>
* To configure the check to report violation so that it doesn't allow Marker Interfaces:
* </p>
* <pre>
* &lt;module name=&quot;InterfaceIsType&quot;&gt;
* &lt;property name=&quot;allowMarkerInterfaces&quot; value=&quot;false&quot;/&gt;
* &lt;/module&gt;
* </pre>
* <p>Example:</p>
* <pre>
* public interface Test1 { // violation
* int a = 3;
* }
*
* public interface Test2 { // violation
*
* }
* </pre>
* @since 3.1
*/
@StatelessCheck
Expand Down
43 changes: 43 additions & 0 deletions src/xdocs/config_coding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,49 @@ while ((line = bufferedReader.readLine()) != null) {
<source>
&lt;module name=&quot;InnerAssignment&quot;/&gt;
</source>
<p>Example:</p>
<source>
class MyClass {

void foo() {
int a, b;
a = b = 5; // violation, assignment to each variable should be in a separate statement
a = b += 5; // violation

a = 5; // OK
b = 5; // OK
a = 5; b = 5; // OK

double myDouble;
double[] doubleArray = new double[] {myDouble = 4.5, 15.5}; // violation

String nameOne;
List&lt;String&gt; myList = new ArrayList&lt;String&gt;();
myList.add(nameOne = "tom"); // violation

for (int k = 0; k &lt; 10; k = k + 2) { // OK
// some code
}

boolean someVal;
if (someVal = true) { // violation
// some code
}

while (someVal = false) {} // violation

InputStream is = new FileInputStream("textFile.txt");
while ((b = is.read()) != -1) { // OK, this is a common idiom
// some code
}
}

boolean testMethod() {
boolean val;
return val = true; // violation
}
}
</source>
</subsection>

<subsection name="Example of Usage" id="InnerAssignment_Example_of_Usage">
Expand Down
33 changes: 33 additions & 0 deletions src/xdocs/config_design.xml
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,39 @@ public class StringUtils // not final to allow subclassing
<source>
&lt;module name=&quot;InterfaceIsType&quot;/&gt;
</source>
<p>Example:</p>
<source>
public interface Test1 { // violation
int a = 3;
}

public interface Test2 { // OK

}

public interface Test3 { // OK
int a = 3;
void test();
}
</source>
<p>
To configure the check to report violation so that it doesn't allow Marker Interfaces:
</p>
<source>
&lt;module name=&quot;InterfaceIsType&quot;&gt;
&lt;property name=&quot;allowMarkerInterfaces&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
</source>
<p>Example:</p>
<source>
public interface Test1 { // violation
int a = 3;
}

public interface Test2 { // violation

}
</source>
</subsection>

<subsection name="Example of Usage" id="InterfaceIsType_Example_of_Usage">
Expand Down

0 comments on commit 0427f9f

Please sign in to comment.