Skip to content

Latest commit

 

History

History
21 lines (11 loc) · 2.35 KB

DEVELOPER_GUIDE.md

File metadata and controls

21 lines (11 loc) · 2.35 KB

How It Works

The project itself is a derivative of finstyle, but starts with all cops (rules) disabled. Cookstyle has a direct dependency on one specific version of RuboCop (at a time), and patches it to load the upstream configuration and custom set of cop updates. When a new RuboCop release comes out, this library can bump the pinned RuboCop version dependency.

NOTE CAREFULLY ABOUT UPDATING COOKSTYLE

Cookstyle is designed to allow bumping the RuboCop engine while keeping backwards compatibility with the config and not requiring all the cookbooks to update. This isn't always possible since many bugfixes catch new issues in cookbooks, but we do our best to prevent constantly linting of large codebases.

Enabling or disabling any new cops in this file must be accompanied by comments demonstrating why the change should be made. Keep in mind anything you add here causes Chef users significant work, so make sure it's worth it.

Cookstyle Configuration File

cookstyle.yml

The cookstyle.yml config file is the enabled.yml file from RuboCop 0.37.2 combined with a sprinkling of cops released in the dozens of RuboCop releases since then as well as configs for all our own Chef cops. All cops enabled since 0.37.2 include a comment or link to a PR so you can see the justification for adding the cop. The file takes an allowlist approach to cops, with AllCops having DisabledByDefault as true. If a rule is not explicitly enabled, it will not run.

NOTE: The cookstyle.yml file was generated by hand and it may be necessary to edit that file (again by hand) to resolve issues with later RuboCop engines changing cop names or behavior.

Updating the RuboCop Engine

Before updating the engine, save a copy of the current engine's rule output with cookstyle --show-cops. Start by updating the RuboCop version in the lib/cookstyle/version.rb file. Then run bundle update to update the RuboCop gem. Confirm the engine is updated with cookstyle --version. Then save the output from another run of cookstyle --show-cops and compare the older output to the new output using diff and shasum to confirm that there are no new/unexplained rules being added or removed between the engine releases.