Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

source code my one of JavaWorld articles "Automated code reviews with Checkstyle, Part 1" (http://www.javaworld.com/javaworld/jw-11-2008/jw-11-checkstyle1.html)

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 samples
Octocat-spinner-32 src
Octocat-spinner-32 .classpath
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .project
Octocat-spinner-32 README.md
Octocat-spinner-32 build.bat
Octocat-spinner-32 build.properties
Octocat-spinner-32 build.xml
Octocat-spinner-32 custom_check.xml
Octocat-spinner-32 pom.xml
Octocat-spinner-32 run.bat
Octocat-spinner-32 run.sh
README.md

Checkstyle Samples application

In this application a lot of custom Checkstyle rules have been created. For some, test conditions have been prepared. This document provides the details about them and also on how to run them.

Build

To build the application simply run build.bat on Windows platform or run build.sh on UNIX/LINUX platform. You need to have ANT available to build the application. As part of build, it will create classes in bin directory and will create a Jar file inside target directory.

Run the samples

Please note to run the below mentioned checks, please comment other Checks in the custom_check.xml and uncomment the one you want to execute.

MethodCallWithoutObjectCreation Check

This Check provides the instances where a method has been called on an uninitialized variable. To run the test condition use: run.bat samples\InterfaceServiceImpl.java

MethodLimitCheck Check

This Check checks the number of methods inside a class. If it exceeds from a pre-determined number, it gives the error. To run the test condition use: run.bat samples\Test.java

TraceMessagesCheck Check

This Check checks if for a specific pattern of classes, trace messages for method enter and exit are there or not. To run the test condition use: run.bat samples\TraceEnterSample.java

NoStateVariables Check

This Check validates if a pattern of classes contains state variables when those classes are supposed to be stateless. To run the test condition use: run.bat samples\SingletonSample.java

IllegalMethodCallInLoopCheck Check

This Check checks if a method call has been used in a loop condition. To run the test condition use: run.bat samples\SingletonSample.java

IllegalExceptionCatchCheck and IllegalExceptionThrowsCheck Check

These two checks focuses on catching instances where something illegal exception type is caught or thrown in methods. To run the test conditions use: run.bat samples\Test.java

Something went wrong with that request. Please try again.