Checkstyle Rules

The Checkstyle Rules project

License

License

Categories

Categories

Checkstyle Application Testing & Monitoring Code Analysis
GroupId

GroupId

com.github.nhojpatrick.qa
ArtifactId

ArtifactId

nhojpatrick-checkstyle-rules
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Checkstyle Rules
The Checkstyle Rules project
Project URL

Project URL

https://github.com/nhojpatrick/nhojpatrick-checkstyle-rules
Source Code Management

Source Code Management

http://github.com/nhojpatrick/nhojpatrick-checkstyle-rules/tree/master

Download nhojpatrick-checkstyle-rules

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.nhojpatrick.qa/nhojpatrick-checkstyle-rules/ -->
<dependency>
    <groupId>com.github.nhojpatrick.qa</groupId>
    <artifactId>nhojpatrick-checkstyle-rules</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.nhojpatrick.qa/nhojpatrick-checkstyle-rules/
implementation 'com.github.nhojpatrick.qa:nhojpatrick-checkstyle-rules:1.0.1'
// https://jarcasting.com/artifacts/com.github.nhojpatrick.qa/nhojpatrick-checkstyle-rules/
implementation ("com.github.nhojpatrick.qa:nhojpatrick-checkstyle-rules:1.0.1")
'com.github.nhojpatrick.qa:nhojpatrick-checkstyle-rules:jar:1.0.1'
<dependency org="com.github.nhojpatrick.qa" name="nhojpatrick-checkstyle-rules" rev="1.0.1">
  <artifact name="nhojpatrick-checkstyle-rules" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.nhojpatrick.qa', module='nhojpatrick-checkstyle-rules', version='1.0.1')
)
libraryDependencies += "com.github.nhojpatrick.qa" % "nhojpatrick-checkstyle-rules" % "1.0.1"
[com.github.nhojpatrick.qa/nhojpatrick-checkstyle-rules "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Checkstyle Custom Configuration

Maven Central CircleCI coveralls Known Vulnerabilities GitHub

Checkstyle is a static code analysis tool to see if code adheres to 'your' coding standing. This project contains custom checkstyle rules.

The initial version just does checks for line length and tabs.

To use checkstyle the following best practice is suggested, with these notes;

  • Put into your parent pom so to simplify your projects.
  • Configure the plugin via pluginManagement, as tools like versions-maven-plugin can detect available updates.
  • Configure version range of this i.e. <version>[1.0.0,1.0.999)</version>, so latest 1.0.x will automatically be used.
  • Execution is done via a profile.
  • Execution is as simple as;
    • fail at 1st violation, use ./mvnw -Pqa_checkstyle.
    • find all violations (i.e. jenkins report), use ./mvnw -Pqa_checkstyle -Dcheckstyle.maxAllowedViolations=999999.
<project>
	...
	<build>
		...
		<pluginManagement>
			<plugins>
				...
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-checkstyle-plugin</artifactId>
					<version>${plugins.maven.maven-checkstyle-plugin}</version>
					<configuration>
						<consoleOutput>true</consoleOutput>
						<failsOnError>true</failsOnError>
					</configuration>
					<dependencies>
						<dependency>
							<groupId>com.puppycrawl.tools</groupId>
							<artifactId>checkstyle</artifactId>
							<version>${version.com.puppycrawl.tools.checkstyle}</version>
						</dependency>
						<dependency>
							<groupId>com.github.nhojpatrick.qa</groupId>
							<artifactId>nhojpatrick-qa-ruleset-checkstyle</artifactId>
							<version>[1.0.0,1.0.999)</version>
						</dependency>
					</dependencies>
				</plugin>
				...
			<plugins>
		<pluginManagement>
		...
	<build>
	...
	<profiles>
		...
			<id>qa_checkstyle</id>
			<build>
				<defaultGoal>verify</defaultGoal>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-checkstyle-plugin</artifactId>
						<executions>
							<execution>
								<id>checkstyle-check</id>
								<phase>validate</phase>
								<goals>
									<goal>check</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<properties>
				<skipTests>true</skipTests>
				<sort.skip>true</sort.skip>
			</properties>
		</profile>
		...
	</profiles>
	...
	<properties>
		<checkstyle.config.location>com/github/nhojpatrick/qa/ruleset/checkstyle/rules.xml</checkstyle.config.location>
		<checkstyle.maxAllowedViolations>0</checkstyle.maxAllowedViolations>
		<plugins.maven.maven-checkstyle-plugin>3.1.1</plugins.maven.maven-checkstyle-plugin>
		<version.com.puppycrawl.tools.checkstyle>8.30</version.com.puppycrawl.tools.checkstyle>
	</properties>
</project>

Versions

Version
1.0.1
1.0.0