The code-styles project defines the company code-styles applied in all repos. This project provides a standardized Checkstyle configuration for Java projects to ensure consistent code quality and formatting across all repositories.
UPPER_CASE_WITH_UNDERSCORES (e.g., MAX_SIZE)PascalCase (e.g., MyClass)camelCase (e.g., myMethod, myVariable)lowercase.with.dots (e.g., com.example.package)else, try, and catchCurrently, the configuration does not include explicit detection for raw type usage (e.g., List instead of List<String>). Consider using compiler warnings (-Xlint:rawtypes) or additional static analysis tools for raw type detection.
git clone https://github.com/rslakra/code-styles.git
cd code-styles
./buildMaven.sh
Run Checkstyle validation with:
./checkStyles.sh
Or directly with Maven:
mvn checkstyle:checkstyle
To use this code style configuration in your Maven project, add the following to your pom.xml:
<properties>
<code-styles.dir>https://raw.githubusercontent.com/rslakra/code-styles/master</code-styles.dir>
<checkstyle.threshold>0</checkstyle.threshold>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>default</id>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<configLocation>${code-styles.dir}/styles.xml</configLocation>
<propertiesLocation>${code-styles.dir}/checkstyle.properties</propertiesLocation>
<logViolationsToConsole>true</logViolationsToConsole>
<maxAllowedViolations>${checkstyle.threshold}</maxAllowedViolations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>