Parse checkstyle comments
Automatically parse the output of a checkstyle test and display the comments on your students' code.
Checkstyle is a popular code quality tool for Java. Using the cg checkstyle
command, you can easily install, run and parse the output to display the generated comments on your students' code.
The cg checkstyle
command is automatically installed in AutoTest v2. You can also download the command for local testing via the following links:
Arguments
The cg checkstyle
suite provides the following commands and command line arguments:
install
This command downloads the JAR file for the specified version of checkstyle. The command uses$CG_INSTALL_DIR
to determine where to install checkstyle. The command relies on "/installs" as a fallback if the above is not set. Usecg checkstyle install --help
for more information about this command.get-jar
Returns the file path to the checkstyle runnable JAR if installed with the --install flag. Usecg checkstyle get-jar --help
for more information about this command.parse
A parser for checkstyle that produces comments from XML reports. Usecg checkstyle parse --help
for more information about this command.run
A reporter for checkstyle. Automatically runs and parses the XML output of a checkstyle test. Usecg checkstyle run --help
for more information about this command.--help or -h
Help for thecg checkstyle
command.
cg checkstyle install
must be run before using any other cg checkstyle
command and must be run with internet enabled.
Examples
Installing checkstyle
At the time of writing, the cg checkstyle
command is not available in the setup portion of the AutoTest configuration. It is therefore important to use an Allow Internet block when running "cg checkstyle install" in your Tests configuration.
Navigate to the Tests portion of your AutoTest.
Create an Allow Internet block
Create a Script block and nest it within the Allow internet block.
Use the following command to install checkstyle version
10.12.3
:
Running checkstyle with the default Sun style guide
Navigate to the setup portion of your AutoTest and create an Upload Files block.
Navigate back to the tests portion of your AutoTest and create a Custom Test block.
Run checkstyle on
MySubmission.java
using the command:
Running checkstyle with a custom configuration or custom checkstyle flags
Navigate to the Setup portion of your AutoTest and create a Upload Files Block.
Upload your prefered xml configuration file for checkstyle.
Navigate back to the Tests portion of your AutoTest configuration and create a Script block.
Run checkstyle on
MySubmission.java
with your own custom flag options using the following command:Underneath, create a Custom Test block.
Parse the XML output file generated by checkstyle and set the percentage of points deducted for comments with the "error" severity to 1% using the following command:
Last updated