- « Go back
- Source code quality
Logisim-evolution uses Google Java Style code style as provided with the Checkstyle
static analyzer tool, with a few checks disabled as specified in the checkstyle-suppressions.xml
config file located in project root directory (from where it should be automatically picked
by Checkstyle).
As we use a suppression config file, you can set up IntelliJ's Checkstyle plugin in
two ways: one adds our suppressions to the built-in "Google Checks" config, the other
creates a completely new config using a copy from the Checkstyle source archive.
Either way, you need to install the CheckStyle-IDEA plugin first:
- Go to
Settings -> Plugins. - Install CheckStyle-IDEA plugin (by Jamie Shiell) from the JetBrains' Marketplace repository.
Edit the existing Google Checks configuration:
- Open the
Tools -> Checkstyleplugin settings. - Activate the
Google Checksconfiguration. - Some rules should be disabled, so we also ship a
checkstyle-suppressions.xmlconfig file. It lives in the project's root directory and should be picked up automatically. It should not be necessary to do anything else with it for it to be used. - You can now run Checkstyle using the
Checkstylecommand or directly from the CheckStyle tab. - Ensure
Rules:, shown in the scan result window, readsGoogle Checks.
You can configure InteliJ's CheckStyle plugin to behave exactly as we configure it:
- Open the
Tools -> Checkstyleplugin settings. - Set the
Checkstyle versionto your liking. - Go to the Checkstyle GitHub page and look
for a release matching the selected
Checkstyle versionand download the source archive. - Unpack it and copy out the
src/main/resources/google_checks.xmlfile to project root directory. - Go back to the plugin configuration and add a new "Configuration file":
- Click the
+icon. - Set the description to
Logisim-evolution. - Select
Use a local Checkstyle file. - Click
Browseand point to thegoogle_checks.xmlfile. - Enable
Store relative to project locationand clickNext. - Some rules should be disabled, so we also ship a
checkstyle-suppressions.xmlconfig file. It lives in the project's root directory and should be picked up automatically. It should not be necessary to do anything else with it for it to be used. If for any reason you need that changed, edit configuration and look for a property namedorg.checkstyle.google.suppressionfilter.config, then set its value tochecksyle-suppressions.xmland click `Next. - Click "Finish".
- Click the
- You can now run Checkstyle using the
Checkstylecommand or directly from the CheckStyle tab. - Ensure
Rules:, shown in the scan result window, readsLogisim-evolution.
Checkstyle is also plugged into the project's Gradle build system and provides the checkstyleMain
and checkstyleTest tasks:
$ ./gradlew checkstyleMainThis should kick in automatically for some build tasks but if for any reason you want Checkstyle
to not be run during your builds, exclude these tasks with -x, i.e:
$ ./gradlew build -x checkstyleMain -x checkstyleTestTo improve quality of your commit, it's recommended to use pre-commit hooks, that will block
your commits unless all pre-commit tests pass. Logisim-evolution comes with predefined .pre-commit-config.yaml
config file for your convenience.
Brief installation instruction (see pre-commit official installation docs too):
- Ensure you got Python installed
- Install pre-commit:
pip install pre-commit - Go to your Logisim-evolution source code root directory
- Copy provided config file template:
cp .pre-commit-config.yaml.dist .pre-commit-config.yaml - Plug hooks into Git pipeline:
pre-commit install
Not all hooks are perfect, so sometimes you may need to skip execution of one or more (or even all) hooks.
pre-commit solves this in two ways. To disable pre-commit completely, pass --no-verify to git:
$ git commit -a --no-verifyAlternatively, you may disable specific hooks only by using a SKIP environment variable, that is holds a comma separated
list of hook IDs to be omitted:
$ SKIP=checkstyle-jar git commit -a -m "Some changes"
Please remember to keep used hooks up to date, by periodically running
$ pre-commit autoupdate