-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse inline checkstyle config from maven-checkstyle-plugin (#768)
* Parse inline checkstyle config from maven-checkstyle-plugin * Flatten nesting a bit by using if/else if --------- Co-authored-by: Tim te Beek <[email protected]>
- Loading branch information
Showing
4 changed files
with
128 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/test/resources-its/org/openrewrite/maven/RewriteRunIT/checkstyle_inline_rules/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.openrewrite.maven</groupId> | ||
<artifactId>checkstyle_inline_rules</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
<name>RewriteRunIT#checkstyle_inline_rules</name> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<activeRecipes> | ||
<recipe>org.openrewrite.java.format.AutoFormat</recipe> | ||
</activeRecipes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<version>3.3.1</version> | ||
<executions> | ||
<execution> | ||
<id>verify-style</id> | ||
<phase>process-classes</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<failsOnError>false</failsOnError> | ||
<checkstyleRules> | ||
<module name="Checker"> | ||
<module name="FileLength"> | ||
<property name="max" value="3500" /> | ||
<property name="fileExtensions" value="java"/> | ||
</module> | ||
<module name="FileTabCharacter"/> | ||
<module name="TreeWalker"> | ||
<module name="StaticVariableName"/> | ||
<module name="TypeName"> | ||
<property name="format" value="^_?[A-Z][a-zA-Z0-9]*$"/> | ||
</module> | ||
</module> | ||
</module> | ||
</checkstyleRules> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
...aven/RewriteRunIT/checkstyle_inline_rules/src/main/java/sample/SimplifyBooleanSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package sample; | ||
|
||
public class SimplifyBooleanSample { | ||
boolean ifNoElse() { | ||
if (isOddMillis()) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
static boolean isOddMillis() { | ||
boolean even = System.currentTimeMillis() % 2 == 0; | ||
if (even == true) { | ||
return false; | ||
} | ||
else { | ||
return true; | ||
} | ||
} | ||
} |