Table of contents

Patterns & Style Guides

Lint your Ruby code with govuk-lint

The govuk-lint gem uses Rubocop to enforce consistency with the GOV.UK style guide.

Rubocop is an open-source gem that performs static analysis of Ruby code according to rules that can be granularly configured. Each validation, or rule, is called a “cop”. Some of those cops come with the ability to auto-correct issues.

How to use govuk-lint

  • Add govuk-lint to your Gemfile
  • Run govuk-lint-ruby in your project root folder

Existing projects

If you have an existing Ruby project that has a number of violations of the GOV.UK style guide, a way of addressing those issues is:

  1. Run govuk-lint-ruby --auto-correct in your project root folder, check that you are happy with those changes and commit.
  2. For the remainder of the violations, manually fix the issues before committing the code containing those fixes.

Jenkins builds

The default Jenkins build script will detect if you are using govuk-lint and will run it automatically.

This page was last reviewed on 22 January 2019. It needs to be reviewed again on 22 July 2019 by the page owner #govuk-developers .
This page was set to be reviewed before 22 July 2019 by the page owner #govuk-developers. This might mean the content is out of date.