code-styles


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.

Features

Code Style Rules

Naming Conventions

Formatting Rules

Import Rules

Code Quality

Note on Raw Types

Currently, 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.

Build Status


pages-build-deployment

How to set up


1. Clone the repository

git clone https://github.com/rslakra/code-styles.git
cd code-styles

2. Build the project

./buildMaven.sh

3. Run Checkstyle

Run Checkstyle validation with:

./checkStyles.sh

Or directly with Maven:

mvn checkstyle:checkstyle

Integration into Other Projects


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>

Built With


Reference


Author