Skip to content

Commit 3e2fecc

Browse files
authored
Merge pull request #113 from harshsennnn/checkstyle-workflow
add workflow, checkstyle and configurations
2 parents c0f27fe + 0dadfc0 commit 3e2fecc

4 files changed

Lines changed: 115 additions & 6 deletions

File tree

.github/workflows/checkstyle.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Call Checkstyle
2+
3+
on:
4+
pull_request:
5+
branches: ["master", "develop"]
6+
paths:
7+
- '**/*.java'
8+
9+
jobs:
10+
style-check:
11+
uses: PSMRI/.github/.github/workflows/checkstyle.yml@main
12+
with:
13+
java-version: '17'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/out-tsc
77
/target
88
/logs
9+
command_output.log
910

1011
.factorypath
1112

checkstyle.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
<property name="severity" value="error"/>
8+
<property name="fileExtensions" value="java"/>
9+
10+
<!-- Checks for Size Violations -->
11+
<module name="FileLength">
12+
<property name="max" value="500"/>
13+
</module>
14+
<module name="LineLength">
15+
<property name="max" value="120"/>
16+
</module>
17+
18+
<module name="TreeWalker">
19+
<!-- Checks for Naming Conventions -->
20+
<module name="MethodName"/>
21+
<module name="PackageName"/>
22+
<module name="TypeName"/>
23+
<module name="ParameterName"/>
24+
<module name="LocalVariableName"/>
25+
<module name="MemberName"/>
26+
27+
<!-- Checks for imports -->
28+
<module name="AvoidStarImport"/>
29+
<module name="IllegalImport"/>
30+
<module name="RedundantImport"/>
31+
<module name="UnusedImports"/>
32+
33+
<!-- Checks for Size Violations -->
34+
<module name="MethodLength">
35+
<property name="max" value="50"/>
36+
</module>
37+
38+
<!-- Checks for whitespace -->
39+
<module name="EmptyLineSeparator"/>
40+
<module name="GenericWhitespace"/>
41+
<module name="MethodParamPad"/>
42+
<module name="NoWhitespaceAfter"/>
43+
<module name="NoWhitespaceBefore"/>
44+
<module name="ParenPad"/>
45+
<module name="TypecastParenPad"/>
46+
<module name="WhitespaceAfter"/>
47+
<module name="WhitespaceAround"/>
48+
49+
<!-- Modifier Checks -->
50+
<module name="ModifierOrder"/>
51+
<module name="RedundantModifier"/>
52+
53+
<!-- Checks for blocks -->
54+
<module name="EmptyBlock"/>
55+
<module name="LeftCurly"/>
56+
<module name="RightCurly"/>
57+
<module name="NeedBraces"/>
58+
59+
<!-- Checks for common coding problems -->
60+
<module name="EmptyStatement"/>
61+
<module name="EqualsHashCode"/>
62+
<module name="IllegalInstantiation"/>
63+
<module name="MissingSwitchDefault"/>
64+
<module name="SimplifyBooleanExpression"/>
65+
<module name="SimplifyBooleanReturn"/>
66+
</module>
67+
</module>

pom.xml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
<groupId>org.springframework.boot</groupId>
5050
<artifactId>spring-boot-starter</artifactId>
5151
</dependency>
52-
<dependency>
53-
<groupId>co.elastic.logging</groupId>
54-
<artifactId>logback-ecs-encoder</artifactId>
55-
<version>1.3.2</version>
52+
<dependency>
53+
<groupId>co.elastic.logging</groupId>
54+
<artifactId>logback-ecs-encoder</artifactId>
55+
<version>1.3.2</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>org.springframework.boot</groupId>
@@ -273,7 +273,7 @@
273273
<artifactId>jacoco-maven-plugin</artifactId>
274274
<version>0.8.11</version>
275275
</dependency>
276-
<dependency>
276+
<dependency>
277277
<groupId>org.springframework</groupId>
278278
<artifactId>spring-web</artifactId>
279279
<version>6.1.12</version>
@@ -435,7 +435,35 @@
435435
</webResources>
436436
</configuration>
437437
</plugin>
438+
<plugin>
439+
<groupId>org.apache.maven.plugins</groupId>
440+
<artifactId>maven-checkstyle-plugin</artifactId>
441+
<version>3.3.1</version>
442+
<dependencies>
443+
<dependency>
444+
<groupId>com.puppycrawl.tools</groupId>
445+
<artifactId>checkstyle</artifactId>
446+
<version>10.12.7</version>
447+
</dependency>
448+
</dependencies>
449+
<configuration>
450+
<configLocation>checkstyle.xml</configLocation>
451+
<encoding>UTF-8</encoding>
452+
<consoleOutput>true</consoleOutput>
453+
<failsOnError>true</failsOnError>
454+
<linkXRef>false</linkXRef>
455+
</configuration>
456+
<executions>
457+
<execution>
458+
<id>validate</id>
459+
<phase>validate</phase>
460+
<goals>
461+
<goal>check</goal>
462+
</goals>
463+
</execution>
464+
</executions>
465+
</plugin>
438466
</plugins>
439467
</build>
440468

441-
</project>
469+
</project>

0 commit comments

Comments
 (0)