• Simplifies performing static code analysis for ruby
  • Creates line-based violation reports on Github

Copperizer

Setup

  1. Add the following to Gemfile:

      gem 'copperizer'
    
  2. Generate configuration files:

      bundle exec rails generate copperizer:config
    

    This will create two files:

    • .rubocop.localch.yml - with master configuration
    • .rubocop.yml - for your specific tweaks per project

    Keep in mind that .rubocop.localch.yml will always be overwritten and should never be modified.

  3. If needed, tweak the configuration in .rubocop.yml

  4. You're good to go

Use Rubocop

After configuration is generated you can run rubocop.

Useful options:

  • rubocop --format offenses

    This will generate a list of offenses sorted by number of occurrences - useful for tweaking configuration

  • rubocop --auto-gen-config

    Generates .rubocop_todo.yml with a configuration that disables all offended cops. This way you can enable & fix them step by step.

    If you want to use this approach remember to add rubocop_todo.yml to inherit_from list in the configuration

  • rubocop --auto-correct

Tries to automatically fix some of the offenses. Might be a good starting point for fixing code style. Use with caution as it's marked as experimental.

Run checkstyle

Simply run the following rake task:

    GIT_REPOSITORY=https://github.com/local-ch/copperizer GITHUB_TOKEN=your_github_token rake checkstyle

Exit code determines if static code analysis was successful or if any violations was found.

The GIT_REPOSITORY takes the link to the Github repo.

You can define the RESULT_PATH (e.g. RESULT_PATH='tmp/checkstyle.json') to define where violation reports are stored.

The GITHUB_TOKEN is required to make line-based violation comments on Github.