-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started: CLI
java -jar <path to jar> <classdir> [<config>]
-
<path to jar>
: Path to the JAR file for the CLI application -
<classdir>
: Path to the directory containing the.class
files to be linted -
[<config>]
: Optional path to a JSON configuration file
Remember that this application only operates on Java bytecode (.class
files). It takes as input a directory of .class
files that have already been built by your IDE. If you try to pass a directory of source .java
files, nothing will happen!
If you're in the root directory of your project, along with the JAR called linter-v1.0-cli.jar
, and your Java class files are in a directory target/classes
, run the CLI like this:
java -jar ./linter-v1.0-cli.jar ./target/classes
By default, it will use an empty configuration (all default settings). If you have a configuration JSON file, add its path to then end of the command like this:
java -jar ./linter-v1.0-cli.jar ./target/classes ./config.json
A configuration is simply a JSON object mapping configuration property names to their configured values. Available configuration properties are listed on this wiki. There are a few global properties applicable to the check runner in general, and many properties used by specific checks (see each check's page on this wiki).
As described on the general configuration page, you can set the skipUnmarkedChecks
property to true
to ensure no checks run unless they are explicitly marked. Then, you can use the enable_namingConventions
property to ensure the Naming Conventions check runs. (Most checks' code names are just their English names in camelCase, but you can check the check's wiki page to be sure.) So, the following configuration will ensure only the Naming Conventions check runs:
{
"skipUnmarkedChecks": true,
"enable_namingConventions": true
}
You can customize check-specific properties in the exact same manner. For example, say you want the Naming Conventions check to validate a max length of 20 characters for names. The Naming Conventions reference establishes this as an integer property named convMaxLength
. So, you could add that property to your configuration like this:
{
"skipUnmarkedChecks": true,
"enable_namingConventions": true,
"convMaxLength": 20
}