- « Go back
- Source code quality
Logisim-evolution uses Google Java Style code style as provided with the CodeStyle
static anaylyzer tool, with a few checks disabled as specified in the suppressions.xml
config file.
-As we use a suppression config file, you can set up InteliJ'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 Marketplace.
Edit the existing Google Checks configuration:
- Open the
Tools -> Checkstyleplugin settings. - Activate the
Google Checksconfiguration. - Highlight the
Google Checksrow and click thePenicon above the list to edit it. - Look for the
org.checkstyle.google.suppressionfilter.confignamed property and set its value toconfig/checkstyle/suppressions.xml. - Click
Finish. - 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 Logisim'sconfig/checkstyle/. - 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 theconfig/checkstyle/google_checks.xmlfile. - Enable
Store relative to project locationand clickNext. - On the
Propertytable, look for a property namedorg.checkstyle.google.suppressionfilter.config. Set the value toconfig/checkstyle/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 checkstyleMainTo 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 ommited:
$ SKIP=checkstyle-jar git commit -a -m "Some changes"
Please remember to keep used hooks up to date, by periodically running
$ pre-commit autoupdate