├── .ruby-version ├── config ├── rake.yml ├── capybara.yml ├── default.yml ├── naming.yml ├── rspec.yml ├── metrics.yml ├── layout.yml ├── rails.yml └── style.yml ├── .gitignore ├── Gemfile ├── .govuk_dependabot_merger.yml ├── .github ├── dependabot.yml ├── workflows │ ├── gem-bump-checker.yml │ ├── autorelease.yml │ ├── actionlint.yml │ ├── ci.yml │ └── run-against-project.yml └── pull_request_template.md ├── .rubocop.yml ├── Rakefile ├── rubocop-govuk.gemspec ├── LICENCE ├── README.md ├── CONTRIBUTING.md └── CHANGELOG.md /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.1.5 2 | -------------------------------------------------------------------------------- /config/rake.yml: -------------------------------------------------------------------------------- 1 | plugins: rubocop-rake 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | 4 | Gemfile.lock 5 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /.govuk_dependabot_merger.yml: -------------------------------------------------------------------------------- 1 | api_version: 2 2 | defaults: 3 | auto_merge: true 4 | update_external_dependencies: true 5 | -------------------------------------------------------------------------------- /config/capybara.yml: -------------------------------------------------------------------------------- 1 | plugins: rubocop-capybara 2 | 3 | # Within GOV.UK we use Capybara test method syntax of feature, 4 | # scenario. 5 | Capybara: 6 | Enabled: true 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: daily 11 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # Run with all config to check it's valid 2 | inherit_from: 3 | - ./config/default.yml 4 | - ./config/rails.yml 5 | - ./config/rspec.yml 6 | 7 | inherit_mode: 8 | merge: 9 | - Exclude 10 | 11 | Rails: 12 | Enabled: false 13 | -------------------------------------------------------------------------------- /.github/workflows/gem-bump-checker.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: {} 3 | pull_request: {} 4 | 5 | jobs: 6 | gem-bump-checker: 7 | uses: alphagov/govuk-infrastructure/.github/workflows/gem-bump-checker.yml@main 8 | secrets: 9 | GH_TOKEN: ${{ secrets.GOVUK_CI_GITHUB_API_TOKEN }} 10 | -------------------------------------------------------------------------------- /.github/workflows/autorelease.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: {} 3 | schedule: 4 | - cron: '30 10 * * 1-5' # 10:30am UTC, Mon-Fri. 5 | 6 | jobs: 7 | autorelease: 8 | uses: alphagov/govuk-infrastructure/.github/workflows/autorelease-rubygem.yml@main 9 | secrets: 10 | GH_TOKEN: ${{ secrets.GOVUK_CI_GITHUB_API_TOKEN }} 11 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ⚠️ Make sure you [release a new version of this gem](https://github.com/alphagov/rubocop-govuk/pull/381/files) after merging your changes. ⚠️ 2 | 3 | Refer to the [existing docs](https://docs.publishing.service.gov.uk/manual/publishing-a-ruby-gem.html#ruby-version-compatibility) if you are making changes to the supported Ruby versions. 4 | -------------------------------------------------------------------------------- /.github/workflows/actionlint.yml: -------------------------------------------------------------------------------- 1 | name: Lint GitHub Actions 2 | on: 3 | push: 4 | paths: ['.github/**'] 5 | jobs: 6 | actionlint: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 10 | with: 11 | show-progress: false 12 | - uses: alphagov/govuk-infrastructure/.github/actions/actionlint@main 13 | -------------------------------------------------------------------------------- /config/default.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | NewCops: disable 3 | SuggestExtensions: false 4 | Exclude: 5 | - 'bin/**' 6 | - 'config.ru' 7 | - 'tmp/**/*' 8 | - 'db/schema.rb' 9 | - 'db/migrate/201*' 10 | - 'vendor/**/*' 11 | - 'node_modules/**/*' 12 | 13 | DisplayCopNames: 14 | Enabled: true 15 | 16 | ExtraDetails: 17 | Enabled: true 18 | 19 | DisplayStyleGuide: 20 | Enabled: true 21 | 22 | inherit_from: 23 | - layout.yml 24 | - metrics.yml 25 | - naming.yml 26 | - style.yml 27 | - rake.yml 28 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rubocop/rake_task" 3 | 4 | task default: %i[rubocop explain_yourself] 5 | 6 | RuboCop::RakeTask.new 7 | 8 | desc "Check for missing documentation" 9 | task :explain_yourself do 10 | missing_comment_regex = /^\s*\n([A-Z][\w\/]+):/ 11 | config_files = Dir["config/*.yml"] 12 | 13 | unexplained_cops = config_files.map do |file| 14 | File.read(file).scan(missing_comment_regex) 15 | end 16 | 17 | unexplained_cops.flatten! 18 | cops_exempt_from_explanation = %w[AllCops Rails] 19 | unexplained_cops -= cops_exempt_from_explanation 20 | 21 | if unexplained_cops.any? 22 | puts "Missing comment/explanation for Cop(s):\n\n" 23 | puts unexplained_cops 24 | puts 25 | abort "Exiting due to missing documentation" 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /rubocop-govuk.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |spec| 2 | spec.name = "rubocop-govuk" 3 | spec.version = "5.1.20" 4 | spec.authors = ["Government Digital Service"] 5 | spec.email = ["govuk-dev@digital.cabinet-office.gov.uk"] 6 | 7 | spec.summary = "RuboCop GOV.UK" 8 | spec.description = "Shared RuboCop rules for Ruby projects in GOV.UK" 9 | spec.homepage = "https://github.com/alphagov/rubocop-govuk" 10 | spec.license = "MIT" 11 | 12 | spec.files = Dir["config/**/*", "*.md"] 13 | 14 | spec.required_ruby_version = ">= 3.1" 15 | 16 | spec.add_development_dependency "rake", "~> 13" 17 | 18 | spec.add_dependency "rubocop", "1.82.0" 19 | spec.add_dependency "rubocop-ast", "1.48.0" 20 | spec.add_dependency "rubocop-capybara", "2.22.1" 21 | spec.add_dependency "rubocop-rails", "2.34.2" 22 | spec.add_dependency "rubocop-rake", "0.7.1" 23 | spec.add_dependency "rubocop-rspec", "3.8.0" 24 | end 25 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | The MIT License(MIT) 2 | 3 | Copyright (C) 2015 Crown Copyright (Government Digital Service) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /config/naming.yml: -------------------------------------------------------------------------------- 1 | # Conflicts with the original GDS styleguide 2 | # 3 | # While this may conflict with the original GDS styleguide, there 4 | # are times where we wish to call a method that "sets" something. 5 | # 6 | # def set_political_and_government(edition) 7 | # 8 | # The original styleguide only accounts for a specific kind of "set" 9 | # operation, where the argument is the value being assigned. 10 | # 11 | # Introduced in: c69a7eb3af955d6c4c0cf0c3cec8e9f330c74429 12 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#naming 13 | Naming/AccessorMethodName: 14 | Enabled: false 15 | 16 | # We should be free to decide on interfaces that make sense to us. 17 | # At the time of writing, this Cop is not auto-correctable, and 18 | # would generate a prohibitively high number of issues across our 19 | # repos, which would require manual intervention. 20 | Naming/PredicatePrefix: 21 | Enabled: false 22 | 23 | # This rule can cause readability issues when applied (for example 24 | # `born_on_or_before_6_april_1935` becomes `born_on_or_before_6april1935`) 25 | # and would require lots of amends to apply either `normalcase` 26 | # or `snake_case` to projects. It is not auto-correctable. 27 | Naming/VariableNumber: 28 | Enabled: false 29 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | workflow_dispatch: 9 | inputs: 10 | ref: 11 | description: 'The branch, tag or SHA to checkout' 12 | default: main 13 | type: string 14 | 15 | concurrency: 16 | group: ${{ github.workflow }}-${{ github.repository }}-${{ github.ref_name }} 17 | cancel-in-progress: false 18 | 19 | jobs: 20 | codeql-sast: 21 | name: CodeQL SAST scan 22 | uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main 23 | permissions: 24 | security-events: write 25 | 26 | dependency-review: 27 | name: Dependency Review scan 28 | uses: alphagov/govuk-infrastructure/.github/workflows/dependency-review.yml@main 29 | 30 | test: 31 | runs-on: ubuntu-latest 32 | steps: 33 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 34 | with: 35 | ref: ${{ inputs.ref || github.ref }} 36 | - uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0 37 | with: 38 | bundler-cache: true 39 | - run: bundle exec rake 40 | 41 | publish: 42 | needs: test 43 | if: ${{ github.ref == 'refs/heads/main' }} 44 | permissions: 45 | contents: write 46 | uses: alphagov/govuk-infrastructure/.github/workflows/publish-rubygem.yml@main 47 | secrets: 48 | GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }} 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RuboCop GOV.UK 2 | 3 | Defines the linting rules for GDS Ruby applications, primarily those associated with GOV.UK. 4 | 5 | GOV.UK has used a styleguide for many years, starting with rules in written form, which we then [automated with RuboCop](https://github.com/alphagov/styleguides/commit/cb589cdc4ba17f9c341f4db75900e554dd042672#diff-99f257b41e6471357be7e37c3a41d79045d11f7f0ae1000d6f7fc63b502273e7) and later [moved into this repo](https://github.com/alphagov/govuk-rfcs/blob/main/rfc-100-linting.md#proposal). A styleguide is a valuable asset: it keeps our code consistent and prevents stylistic squabbles. Everyone on GOV.UK is encouraged to use it in their Ruby projects and [contribute](CONTRIBUTING.md) to dependency upgrades and new releases, keeping pace with the rest of the Ruby community. 6 | 7 | ## Installation 8 | 9 | Add `rubocop-govuk` to your Gemfile and then run `bundle install`: 10 | 11 | ```ruby 12 | # Gemfile 13 | gem 'rubocop-govuk', require: false 14 | ``` 15 | 16 | Then inherit the default rules by adding the following in your project: 17 | 18 | ```yaml 19 | # .rubocop.yml 20 | inherit_gem: 21 | rubocop-govuk: 22 | - config/default.yml 23 | 24 | inherit_mode: 25 | merge: 26 | - Exclude 27 | 28 | # ************************************************************** 29 | # TRY NOT TO ADD OVERRIDES IN THIS FILE 30 | # 31 | # This repo is configured to follow the RuboCop GOV.UK styleguide. 32 | # Any rules you override here will cause this repo to diverge from 33 | # the way we write code in all other GOV.UK repos. 34 | # 35 | # See https://github.com/alphagov/rubocop-govuk/blob/main/CONTRIBUTING.md 36 | # ************************************************************** 37 | ``` 38 | 39 | You can also configure additional rules for Rails and RSpec: 40 | 41 | ```yaml 42 | # .rubocop.yml 43 | inherit_gem: 44 | rubocop-govuk: 45 | ... 46 | - config/rails.yml 47 | ``` 48 | 49 | ```yaml 50 | # .rubocop.yml 51 | inherit_gem: 52 | rubocop-govuk: 53 | ... 54 | - config/rspec.yml 55 | ``` 56 | 57 | ## Contributing 58 | 59 | Rules in this repo are defined based on their compatibility with GOV.UK apps and their code conventions. Everyone else is welcome to use it and suggest changes - see [CONTRIBUTING.md](CONTRIBUTING.md) for more details. 60 | 61 | ## Licence 62 | 63 | [MIT License](LICENCE) 64 | 65 | -------------------------------------------------------------------------------- /config/rspec.yml: -------------------------------------------------------------------------------- 1 | plugins: rubocop-rspec 2 | 3 | inherit_from: 4 | - capybara.yml 5 | 6 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 7 | # 8 | # We should avoid cops that are based on heuristics, since 9 | # it's not clear what action to take to fix an issue. 10 | RSpec/ExampleLength: 11 | Enabled: false 12 | 13 | # We should avoid cops that are based on heuristics, since 14 | # it's not clear what action to take to fix an issue. 15 | RSpec/MultipleMemoizedHelpers: 16 | Enabled: false 17 | 18 | # We have common cases, such as rake tasks, where we do not 19 | # use a class to the describe the test. 20 | RSpec/DescribeClass: 21 | Enabled: false 22 | 23 | # We accept multiple expectations (within reason), preferring 24 | # them to running mulitple similar tests. 25 | RSpec/MultipleExpectations: 26 | Enabled: false 27 | 28 | # Part of the GOV.UK feature style involves instance variables. 29 | RSpec/InstanceVariable: 30 | Exclude: 31 | - 'spec/features/**/*.rb' 32 | - 'spec/system/**/*.rb' 33 | 34 | # The GOV.UK Feature spec style has expectations in method calls so this 35 | # cop falsely triggers. 36 | RSpec/NoExpectationExample: 37 | Exclude: 38 | - 'spec/features/**/*.rb' 39 | - 'spec/system/**/*.rb' 40 | 41 | # In GOV.UK we quite often test that a class received a method. 42 | RSpec/MessageSpies: 43 | Enabled: false 44 | 45 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 46 | # 47 | # We should avoid cops that are based on heuristics, since 48 | # it's not clear what action to take to fix an issue. 49 | RSpec/NestedGroups: 50 | Enabled: false 51 | 52 | # Nested contexts make more sense with "and" or "but", since 53 | # they are a refinement of an outer context. 54 | RSpec/ContextWording: 55 | Prefixes: 56 | - when 57 | - with 58 | - without 59 | - and 60 | - but 61 | 62 | # Within GOV.UK we use Capybara test method syntax of feature, 63 | # scenario. 64 | # We don't want this cop outside of feature or system specs though. 65 | RSpec/Dialect: 66 | # Disables all Capybara-specific methods that have the same native 67 | # RSpec method (e.g. are just aliases) 68 | PreferredMethods: 69 | background: :before 70 | scenario: :it 71 | xscenario: :xit 72 | given: :let 73 | given!: :let! 74 | feature: :describe 75 | Exclude: 76 | - 'spec/features/**/*.rb' 77 | - 'spec/system/**/*.rb' 78 | -------------------------------------------------------------------------------- /.github/workflows/run-against-project.yml: -------------------------------------------------------------------------------- 1 | # GitHub Workflow to allow running rubocop-govuk against an alphagov repo 2 | # to test the effects of linting rules prior to releasing the gem. 3 | # 4 | # This is expected to be called manually via the GitHub UI (https://github.com/alphagov/rubocop-govuk/actions/workflows/run-against-project.yml) 5 | # or via the GitHub CLI. 6 | name: Run against project 7 | run-name: Running rubocop-govuk (${{ inputs.git_ref }}) against ${{ inputs.alphagov_repo }} 8 | 9 | on: 10 | workflow_dispatch: 11 | inputs: 12 | alphagov_repo: 13 | description: 'The alphagov repository to run rubocop-govuk against' 14 | required: true 15 | type: string 16 | git_ref: 17 | description: 'Commit, tag or branch name of rubocop-govuk to use' 18 | required: true 19 | type: string 20 | default: 'main' 21 | 22 | jobs: 23 | lint_project: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Cloning alphagov/${{ inputs.alphagov_repo }} 27 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 28 | with: 29 | repository: alphagov/${{ inputs.alphagov_repo }} 30 | - uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0 31 | with: 32 | bundler-cache: true 33 | # We need to turn off deployment mode so that we can modify the gems 34 | - run: bundle config unset deployment 35 | - run: bundle remove rubocop-govuk 36 | # There is a `bundle add --github --ref` command we could have used, 37 | # however the output of that falls foul of our linter (how ironic). 38 | # Instead of fighting/correcting/accepting that we have this work 39 | # around of amending the gemfile ourselves and running bundle install 40 | # again. 41 | - name: Amending gemfile for rubocop-govuk (${{ inputs.git_ref }}) 42 | run: | 43 | printf '\ngem "rubocop-govuk", github: "alphagov/rubocop-govuk", ref: "${{ inputs.git_ref }}"\n' >> Gemfile 44 | - name: Install rubcop-govuk gem 45 | run: bundle install 46 | - name: Run rubocop 47 | run: | 48 | # preserve exit code if rubocop fails 49 | set -o pipefail 50 | # use tee to output to stdout and populate GitHub summary 51 | bundle exec rubocop --format markdown | tee "$GITHUB_STEP_SUMMARY" 52 | -------------------------------------------------------------------------------- /config/metrics.yml: -------------------------------------------------------------------------------- 1 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 2 | # 3 | # We should avoid cops that are based on heuristics, since 4 | # it's not clear what action to take to fix an issue. 5 | # 6 | # For this Cop, there are also several kinds of file that 7 | # have long blocks by convention (tests, config, rake tasks, 8 | # gemspecs), to the point where its value is dubious. 9 | Metrics/BlockLength: 10 | Enabled: false 11 | 12 | # Introduced in: 736b3d295f88b9ba6676fc168b823535582388c2 13 | # "Disable opinionated cops" 14 | # 15 | # We should avoid cops that are based on heuristics, since 16 | # it's not clear what action to take to fix an issue. 17 | Metrics/AbcSize: 18 | Enabled: false 19 | 20 | # Introduced in: 736b3d295f88b9ba6676fc168b823535582388c2 21 | # "Disable opinionated cops" 22 | # 23 | # We should avoid cops that are based on heuristics, since 24 | # it's not clear what action to take to fix an issue. 25 | Metrics/ClassLength: 26 | Enabled: false 27 | 28 | # Introduced in: 736b3d295f88b9ba6676fc168b823535582388c2 29 | # "Disable opinionated cops" 30 | # 31 | # We should avoid cops that are based on heuristics, since 32 | # it's not clear what action to take to fix an issue. 33 | Metrics/ModuleLength: 34 | Enabled: false 35 | 36 | # Introduced in: 736b3d295f88b9ba6676fc168b823535582388c2 37 | # "Disable opinionated cops" 38 | # 39 | # We should avoid cops that are based on heuristics, since 40 | # it's not clear what action to take to fix an issue. 41 | Metrics/PerceivedComplexity: 42 | Enabled: false 43 | 44 | # Introduced in: c69a7eb3af955d6c4c0cf0c3cec8e9f330c74429 45 | # 46 | # We should avoid cops that are based on heuristics, since 47 | # it's not clear what action to take to fix an issue. 48 | Metrics/BlockNesting: 49 | Enabled: false 50 | 51 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 52 | # "Disable opinionated cops" 53 | # 54 | # We should avoid cops that are based on heuristics, since 55 | # it's not clear what action to take to fix an issue. 56 | Metrics/CyclomaticComplexity: 57 | Enabled: false 58 | 59 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 60 | # "Disable opinionated cops" 61 | # 62 | # We should avoid cops that are based on heuristics, since 63 | # it's not clear what action to take to fix an issue. 64 | Metrics/MethodLength: 65 | Enabled: false 66 | 67 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 68 | # "Disable opinionated cops" 69 | # 70 | # We should avoid cops that are based on heuristics, since 71 | # it's not clear what action to take to fix an issue. 72 | Metrics/ParameterLists: 73 | Enabled: false 74 | -------------------------------------------------------------------------------- /config/layout.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/alphagov/govuk-lint/pull/7 2 | # "There are occasions where following this rule forces you to make the 3 | # code less readable. This is particularly the case for tests where method 4 | # names form the test descriptions. Keeping test descriptions under a 5 | # certain length can force them to become cryptic." 6 | Layout/LineLength: 7 | Enabled: false 8 | 9 | # We have two styles of method call in our apps: 10 | # 11 | # SomeClass.first_method_call_on_same_line 12 | # .other_method_call 13 | # 14 | # a_particularly_long_first_method_call 15 | # .subsequent_method_call 16 | # 17 | # Any setting of this Cop would cause odd alignment 18 | # for one of these styles. Since there isn't a Cop to 19 | # set a preferred style, we should disable this one. 20 | Layout/MultilineMethodCallIndentation: 21 | Enabled: false 22 | 23 | # Part of the orignal GDS styleguide 24 | # "Outdent private etc" 25 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#classes 26 | Layout/AccessModifierIndentation: 27 | Enabled: true 28 | EnforcedStyle: outdent 29 | 30 | # Our predominant style of writing multiline arrays is: 31 | # 32 | # my_array = [ 33 | # element_1, 34 | # element_2, 35 | # ] 36 | # 37 | # even_in_a_method_call([ 38 | # element_1, 39 | # element_2, 40 | # ]) 41 | Layout/FirstArrayElementIndentation: 42 | EnforcedStyle: consistent 43 | 44 | # Our predominant style of writing multiline hashes is: 45 | # 46 | # my_hash = { 47 | # key_1: value_1, 48 | # key_2: value_2, 49 | # } 50 | # 51 | # even_in_a_method_call({ 52 | # key_1: value_1, 53 | # key_2: value_2, 54 | # }) 55 | Layout/FirstHashElementIndentation: 56 | EnforcedStyle: consistent 57 | 58 | # Our predominant style of writing multiline operations is 59 | # to indent the subsequent lines. This helps to prevent 60 | # misreading the next line as a new/separate statement. 61 | # 62 | # Introduced in: 9b2a744ab119d7797aaf423abcec914360f4208e 63 | Layout/MultilineOperationIndentation: 64 | EnforcedStyle: indented 65 | 66 | # We should be consistent: if some items of an array are 67 | # on multiple lines, then all items should be. This works 68 | # better with the indentation Cops, produces clearer diffs, 69 | # and avoids wasting time tweaking an arbitrary layout. 70 | Layout/MultilineArrayLineBreaks: 71 | Enabled: true 72 | 73 | # We should be consistent: if some items of a hash are 74 | # on multiple lines, then all items should be. This works 75 | # better with the indentation Cops, produces clearer diffs, 76 | # and avoids wasting time tweaking an arbitrary layout. 77 | Layout/MultilineHashKeyLineBreaks: 78 | Enabled: true 79 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This guidance is intended for changes to: 4 | 5 | - versions of dependencies for this repo (e.g. RuboCop itself); and 6 | - the [extra config we have](https://github.com/alphagov/rubocop-govuk/tree/main/config) to support historical GOV.UK patterns. 7 | 8 | All dependencies should be [locked to patch versions to avoid surprise upgrades](https://github.com/alphagov/rubocop-govuk/pull/154) in consumer repos. 9 | 10 | ## Getting started 11 | 12 | To install dependencies: 13 | 14 | ```bash 15 | bundle 16 | ``` 17 | 18 | To lint the config / Rakefile: 19 | 20 | ```bash 21 | bundle exec rake 22 | ``` 23 | 24 | RuboCop GOV.UK is a styleguide, so each rule in each YAML file should have a comment to explain why it's there. This is enforced by linting with [a custom `explain_yourself` rake task](https://github.com/alphagov/rubocop-govuk/blob/main/Rakefile). 25 | 26 | ## Doing a release 27 | 28 | ### 1. Check what the impact is going to be 29 | 30 | Find out how much effort it will be to adopt your changes in typical GOV.UK repos. This could just be running `rubocop -A` to autocorrect new issues, or it could involve significant manual effort. 31 | 32 | You can test changes against an alphagov repo by [running the GitHub worflow](https://github.com/alphagov/rubocop-govuk/actions/workflows/run-against-project.yml) we have configured. 33 | 34 | This is a rough list of typical GOV.UK repos we recommend testing against: 35 | 36 | - An old app e.g. Whitehall, Smart Answers 37 | - A newer app e.g. Content Publisher, Email Alert API 38 | - A non-Rails app e.g. Search API 39 | - A gem e.g. GDS API Adapters 40 | 41 | ### 2. Decide if the config needs to change 42 | 43 | Ideally we should have none of our own config and follow RuboCop defaults: 44 | 45 | - This is easier than making our own decisions. 46 | - We don't want to diverge from the Ruby community. 47 | 48 | However, we also want to make it easy for all GOV.UK repos to keep pace with RuboCop GOV.UK. This means we should **try to ensure all issues can be auto-corrected or are easy to fix manually**. 49 | 50 | You should only change the config as a last resort. Examples of good changes: 51 | 52 | - Disable a rule if it's based on heuristics ([example](https://github.com/alphagov/rubocop-govuk/blob/ce655779e45892db6ac00d6789c652ec2e506748/config/metrics.yml#L1-L10)). 53 | 54 | - Change a rule to match a GOV.UK-wide pattern ([example](https://github.com/alphagov/rubocop-govuk/blob/ce655779e45892db6ac00d6789c652ec2e506748/config/rails.yml#L16-L25)). 55 | 56 | - Change a rule if the effort to fix is *very* high ([example](https://github.com/alphagov/rubocop-govuk/blob/ce655779e45892db6ac00d6789c652ec2e506748/config/rspec.yml#L33-L35)). 57 | 58 | Sometimes it's more appropriate to put config overrides in the `.rubocop.yml` file of consumer repos ([example](https://github.com/alphagov/content-store/blob/857275148323fc9536490aefc253c8a9e73a175a/.rubocop.yml#L10-L12)). Use this approach if the override is only necessary in a small number of repos. 59 | 60 | ### 3. Consider making a pre-release version 61 | 62 | This can be helpful if there are lots of changes where it's hard to assess the impact e.g. a major dependency upgrade. Use the pre-release version to gather feedback from maintainers of consumer repos, working with them to make any necessary adjustments here before releasing the next official version. 63 | 64 | 👉 [Example of major release after testing a pre-release version](https://github.com/alphagov/rubocop-govuk/compare/v4.0.0.pre.1...v4.0.0). 65 | 66 | ### 4. Make your CHANGELOG really helpful 67 | 68 | The [CHANGELOG.md](CHANGELOG.md) is what maintainers of consumer repos will use to understand your changes. Tools like Dependabot will automatically include it in PR descriptions. A helpful changelog: 69 | 70 | - Gives an overview of the change e.g. "Upgrade X to Y". 71 | 72 | - Explains any actions to take e.g. "run `rubocop -A`". 73 | 74 | - Advises on potential compatibility issues (TODO: example). 75 | -------------------------------------------------------------------------------- /config/rails.yml: -------------------------------------------------------------------------------- 1 | ##################### Rails ################################## 2 | 3 | # By default Rails is switched off so this can be used by non-Rails apps, 4 | # this can be enabled in a local .rubocop.yml file 5 | 6 | plugins: rubocop-rails 7 | 8 | AllCops: 9 | Exclude: 10 | - 'db/schema.rb' 11 | - 'db/migrate/201*' 12 | 13 | Rails: 14 | Enabled: true 15 | 16 | # We have custom find_by methods in several repos, which 17 | # we're not going to rename. This Cop also raises false 18 | # positives for find_by methods that are unrelated to model 19 | # classes, as well as for repos using Mongoid. The value 20 | # of the consistency this brings is limited, since we mostly 21 | # use find_by(key: value) anyway. 22 | # 23 | # https://github.com/rubocop-hq/rubocop/issues/3758 24 | Rails/DynamicFindBy: 25 | Enabled: false 26 | 27 | # We commonly print output in Ruby code that has been 28 | # extracted from a Rake task in 'lib/'. 29 | Rails/Output: 30 | Exclude: 31 | - 'lib/**/*.rb' 32 | 33 | # It's unclear what remedial action to take for the total 34 | # set of methods this Cop has issues with. For example, we 35 | # use 'update_all' in many of our repos, for which there is 36 | # no efficient alternative. Instead, we should only enable 37 | # this Cop for methods that have a clear alternative. 38 | Rails/SkipsModelValidations: 39 | ForbiddenMethods: 40 | - update_attribute 41 | 42 | # While using has_many/through does have some advantages, 43 | # it also requires a significant amount of boilerplate code: 44 | # 45 | # - An additional 'has_many :join_table' statement 46 | # - An additional class for the join table (model) 47 | # 48 | # This Cop/rule appears to have been written with the 49 | # assumption that all join tables have inherent meaning, 50 | # we want to represent, which is not the case; sometimes 51 | # relationships are just # many-to-many, and that's it. 52 | Rails/HasAndBelongsToMany: 53 | Enabled: false 54 | 55 | # While using 'inverse_of' can reduce DB queries, we have 56 | # not found this to be a problem in practice. The advantage 57 | # of turning this on would be that we make the inverse 58 | # behaviour explicit everywhere ActiveRecord can't apply it 59 | # automatically, but this is rarely a surprise for developers. 60 | # We also don't want to add 'inverse_of: false' everywhere; 61 | # at the time of writing, there is no auto-correct for this. 62 | Rails/InverseOf: 63 | Enabled: false 64 | 65 | # This is incompatible with the more robust use of foreign 66 | # key constraints, which provide the same behaviour. 67 | # 68 | # Example: https://github.com/alphagov/content-publisher/blob/f26d9b551842fdf2084159b5b7f1bb078da56936/db/schema.rb#L396 69 | Rails/HasManyOrHasOneDependent: 70 | Enabled: false 71 | 72 | # We commonly want to render HTML without escaping it, which 73 | # is what 'html_safe' is for. In many cases, the content we 74 | # render has already been sanitised (e.g. through Govspeak), 75 | # or is otherwise trusted e.g. from a content item. We trust 76 | # that developers will use 'html_safe' responsibly, and prefer 77 | # the default, escaped output otherwise. At the time of writing, 78 | # this Cop is disabled in a lot of repos, indicating it offers 79 | # little value to many developers. 80 | Rails/OutputSafety: 81 | Enabled: false 82 | 83 | # We seldom check the return value of 'update' to see if 84 | # the operation was successful. Since we assume success, we 85 | # should raise an exception if this is not the case. 86 | Rails/SaveBang: 87 | Enabled: true 88 | 89 | # We should avoid unnecessary ambiguity between 'Time.current' 90 | # and 'Time.zone.now', where 'Time.current' behaves differently 91 | # depending on application config. We should always be explicit 92 | # about whether we mean 'Time[.zone].now'. 93 | Rails/TimeZone: 94 | EnforcedStyle: "strict" 95 | 96 | # This rule to avoid using instance variables in helpers 97 | # is over aggressive and is catching helper tests and helpers specs 98 | # as well. Minitests that don't use the Rspec let convention need 99 | # instance variables to do the testing. Excluding them from the rule. 100 | Rails/HelperInstanceVariable: 101 | Exclude: 102 | - '**/*_test.rb' -------------------------------------------------------------------------------- /config/style.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/alphagov/govuk-lint/pull/36 2 | # "When we have sequence of if/unless statements, 3 | # some with multiple lines within the if statement 4 | # block and some with a single line, forcing the single 5 | # line statements to re-written makes it a harder 6 | # to follow the branching logic." 7 | Style/IfUnlessModifier: 8 | Enabled: false 9 | 10 | # Part of the orignal GDS styleguide 11 | # "Never chain do...end" 12 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#syntax 13 | Style/MethodCalledOnDoEndBlock: 14 | Enabled: true 15 | 16 | # Part of the orignal GDS styleguide 17 | # "Add a trailing comma to multi-line array [...] 18 | # for clearer diffs with less line noise." 19 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#collections 20 | Style/TrailingCommaInArrayLiteral: 21 | EnforcedStyleForMultiline: comma 22 | 23 | # Part of the orignal GDS styleguide 24 | # "Add a trailing comma to multi-line hash definitions [...] 25 | # for clearer diffs with less line noise." 26 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#collections 27 | Style/TrailingCommaInHashLiteral: 28 | EnforcedStyleForMultiline: comma 29 | 30 | # Part of the orignal GDS styleguide 31 | # "When long lists of method arguments require 32 | # breaking over multiple lines, break each successive 33 | # argument on a new line, including the first argument 34 | # and closing paren. The final argument should include 35 | # a trailing comma." 36 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#general 37 | Style/TrailingCommaInArguments: 38 | EnforcedStyleForMultiline: comma 39 | 40 | # Part of the orignal GDS styleguide 41 | # "Prefer %w to the literal array syntax when you need 42 | # an array of strings." 43 | # https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#collections 44 | Style/WordArray: 45 | MinSize: 0 46 | 47 | # "Try not to mix up single-quoted and double-quoted 48 | # strings within a file: it can make the code harder to read. 49 | # Definitely don't mix up single-quoted and double-quoted 50 | # strings within a method. If in doubt, use double-quoted strings, 51 | # because you’ll probably need to use interpolation somewhere. 52 | Style/StringLiterals: 53 | EnforcedStyle: double_quotes 54 | 55 | # Introduced in: 5ca6b7d20fd62a6ce890868abdeca12837e436d7 56 | # "The wording of the description is hard to understand - it's not 57 | # immediately obvious what you have to do, and doesn't really say why 58 | # this is a good thing. 59 | # 60 | # It's not auto-fixable, which means it takes a lot of time to get the 61 | # syntax right for every occurrence of `%.2f` for example (taken from 62 | # `smart-answers`) for not very much benefit." 63 | Style/FormatStringToken: 64 | Enabled: false 65 | 66 | # Using the default style leads to buggy auto-correct in several 67 | # repos that have their own 'format' method defined. While it's not 68 | # ideal to override a standard/Kernel method, it's also not practical 69 | # to change a term that's so deeply embedded within our domain. 70 | # 71 | # Related PR: https://github.com/alphagov/specialist-publisher/pull/1640 72 | # Related PR: https://github.com/alphagov/publisher/pull/1268 73 | Style/FormatString: 74 | EnforcedStyle: sprintf 75 | 76 | # This is a contentious issue, since 'alias_method' works in 77 | # all circumstances, whereas 'alias' only works lexically. As 78 | # with single vs. double quotes, it seems pointless to expend 79 | # effort deciding between them. Our predominant style is to use 80 | # 'alias_method', which always works. 81 | Style/Alias: 82 | EnforcedStyle: prefer_alias_method 83 | 84 | # This prevents weird characters in comments, such as stylistic 85 | # quote characters and strange whitespace. We should only allow 86 | # special characters when they are essential for a comment. It's 87 | # a waste of effort to go and find the special sequence when an 88 | # alternative exists e.g. '×' can be replaced with '*' in maths. 89 | Style/AsciiComments: 90 | AllowedChars: ['£'] 91 | 92 | # We should only use braces in multiline blocks in a # chained 93 | # method call. This is consistent with the RSpec 'expect' syntax. 94 | # 95 | # expect { 96 | # a_long_and_complex_method_call 97 | # }.to raise_error(SomeError) 98 | # 99 | Style/BlockDelimiters: 100 | EnforcedStyle: braces_for_chaining 101 | 102 | # We have no concensus on this. Using the nested style is the 103 | # default for generated Rails app (see 'config/application.rb'). 104 | # Using the compact style can help to reduce boilerplate within 105 | # modules. At the time of writing, the auto-correct for this Cop 106 | # is unsafe for moving to either style. 107 | Style/ClassAndModuleChildren: 108 | Enabled: false 109 | 110 | # Introduced in: c69a7eb3af955d6c4c0cf0c3cec8e9f330c74429 111 | # Documenting every class is a lot of effort and we don't 112 | # expect to get any value from this. Another risk of adding 113 | # more documentation is the potential for confusion if that 114 | # documentation gets out-of-sync with the class/module. 115 | Style/Documentation: 116 | Enabled: false 117 | 118 | # Introduced in: c69a7eb3af955d6c4c0cf0c3cec8e9f330c74429 119 | # This can lead to excessively long lines. Consistent with 120 | # disabling "Layout/LineLength". 121 | # 122 | # "There are occasions where following this rule forces you to make the 123 | # code less readable." 124 | Style/GuardClause: 125 | Enabled: false 126 | 127 | # Analog of: 736b3d295f88b9ba6676fc168b823535582388c2 128 | # "Disable opinionated cops" 129 | # 130 | # We should avoid cops that are based on heuristics, since 131 | # it's not clear what action to take to fix an issue. 132 | Style/RegexpLiteral: 133 | Enabled: false 134 | 135 | # Using safe navigation is less explicit than making a clear 136 | # check for truthiness, as evidenced by its own safelist for 137 | # certain methods. Safe navigation is also less visible and 138 | # pollutes otherwise readable method calls. 139 | Style/SafeNavigation: 140 | Enabled: false 141 | 142 | # Introduced in: b171d652d3e434b74ddc621df3b5be24c49bc7e8 143 | # This cop was added in preperation for a Ruby feature 144 | # that is no longer likely to become part of the language. 145 | # https://github.com/rubocop-hq/rubocop/issues/7197 146 | Style/FrozenStringLiteralComment: 147 | Enabled: false 148 | 149 | # We should only use DateTime when it's necessary to account 150 | # for ancient calendar changes. Otherwise, the arbitrary use 151 | # of this class in place of Date or Time is confusing. 152 | # 153 | # https://rubystyle.guide/#no-datetime 154 | Style/DateTime: 155 | Enabled: true 156 | 157 | # This rule conflicts with Style/BlockDelimiters. 158 | # Style/MultilineBlockChain says use do...end instead of {...} for multi-line blocks, 159 | # but Style/BlockDelimiters says use {...} instead of do...end when chaining. 160 | # The latter should take priority over the former, because it leads to more readable code. 161 | Style/MultilineBlockChain: 162 | Enabled: false 163 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 5.1.20 2 | 3 | * Update dependencies 4 | 5 | # 5.1.19 6 | 7 | * Update dependencies 8 | 9 | # 5.1.18 10 | 11 | * Update dependencies 12 | 13 | # 5.1.17 14 | 15 | * Update dependencies 16 | 17 | # 5.1.16 18 | 19 | * Update dependencies 20 | 21 | # 5.1.15 22 | 23 | * Rename PredicateName cop to PredicatePrefix to address deprecation warning ([#511](https://github.com/alphagov/rubocop-govuk/pull/511)) 24 | 25 | # 5.1.14 26 | 27 | * Update dependencies 28 | 29 | # 5.1.13 30 | 31 | * Update dependencies 32 | 33 | # 5.1.12 34 | 35 | * Update dependencies 36 | 37 | # 5.1.11 38 | 39 | * Exclude `*_test.rb` files from being checked against HelperInstanceVariable rule as it is picking out helper test files as well. 40 | 41 | # 5.1.10 42 | 43 | * Update dependencies 44 | 45 | # 5.1.9 46 | 47 | * Configure CI workflow to handle concurrent releases ([#499](https://github.com/alphagov/rubocop-govuk/pull/499)) 48 | 49 | # 5.1.8 50 | 51 | * Update dependencies 52 | 53 | # 5.1.7 54 | 55 | * Update dependencies 56 | 57 | # 5.1.6 58 | 59 | * Update dependencies 60 | 61 | # 5.1.5 62 | 63 | * Update dependencies 64 | 65 | # 5.1.4 66 | 67 | * Update dependencies 68 | 69 | # 5.1.3 70 | 71 | * Update dependencies 72 | 73 | # 5.1.2 74 | 75 | * Update dependencies 76 | 77 | # 5.1.1 78 | 79 | * Update dependencies 80 | 81 | # 5.1.0 82 | 83 | * Migrate to the plugin system 84 | * Update rubocop-ast from 1.38.1 to 1.39.0 85 | 86 | # 5.0.11 87 | 88 | * Update dependencies 89 | 90 | # 5.0.10 91 | 92 | * Update dependencies 93 | 94 | # 5.0.9 95 | 96 | * Bump version to add Action Linting and Pass Ratchet check 97 | 98 | # 5.0.8 99 | 100 | * Update dependencies 101 | 102 | # 5.0.7 103 | 104 | * Update dependencies 105 | 106 | # 5.0.6 107 | 108 | * Update dependencies 109 | 110 | # 5.0.5 111 | 112 | * Update dependencies 113 | 114 | # 5.0.4 115 | 116 | * Update dependencies 117 | 118 | # 5.0.3 119 | 120 | * Update dependencies: rubocop from 1.64.1 to 1.68.0, rubocop-ast from 1.31.3 to 1.26.1, rubocop-rails from 2.25.1 to 2.27.0, rubocop-rspec from 3.0.1 to 3.2.0 121 | 122 | # 5.0.2 123 | 124 | * Update dependencies 125 | 126 | # 5.0.1 127 | 128 | - Disable RSpec/NoExpectationExample for feature and system specs as it false triggers. 129 | 130 | # 5.0.0 131 | 132 | - BREAKING: Update rubocop-rspec to 3.0 which enables by default previously pending cops. See [rubocop-rspec's changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md#300-2024-06-11) for details. 133 | 134 | # 4.18.0 135 | 136 | * Drop support for Ruby 3.0 137 | 138 | # 4.17.1 139 | 140 | * Update dependencies 141 | 142 | # 4.17.0 143 | 144 | - Apply feature spec exemptions to system specs 145 | - Update rubocop to 1.63.5 146 | - Update rubocop-rspec to 2.29.2 147 | - Update rubocop-ast to 1.31.3 148 | 149 | # 4.16.1 150 | 151 | * Update dependencies 152 | 153 | ## 4.16.0 154 | 155 | - Disable `Style/MultilineBlockChain` 156 | - Update rubocop-rails to 2.24.1 157 | 158 | ## 4.15.0 159 | 160 | - Update rubocop to 1.62.1 161 | - Update rubocop-ast to 1.31.2 162 | - Update rubocop-rails to 2.24.0 163 | - Update rubocop-rspec to 2.27.1 164 | 165 | ## 4.14.0 166 | 167 | - Update rubocop to 1.60.2 168 | - Update rubocop-rails to 2.23.1 169 | - Update rubocop-rspec to 2.26.1 170 | - Add Snyk scans to CI pipeline 171 | 172 | ## 4.13.0 173 | 174 | - Update rubocop to 1.59.0 175 | - Update rubocop-ast to 1.30.0 176 | - Update rubocop-rails to 2.23.0 177 | - Update rubocop-rspec to 2.25.0 178 | 179 | ## 4.12.0 180 | 181 | - Update rubocop to 1.55.0 182 | 183 | ## 4.11.0 184 | 185 | - Drop support for Ruby 2.7. 186 | - Update rubocop to 1.53.1 187 | - Update rubocop-ast to 1.29.0 188 | - Update rubocop-rails 2.20.2 189 | - Update rubocop-rake to 0.6.0 190 | - Update rubocop-rspec to 2.22.0 191 | 192 | # 4.10.0 193 | 194 | - Update rubocop to 1.44.1 195 | - Update rubocop-ast to 1.24.1 196 | - Update rubocop-rails to 2.17.4 197 | - Update rubocop-rspec to 2.18.1 198 | 199 | # 4.9.0 200 | 201 | - Update rubocop to 1.39.0 202 | - Update rubocop-rails to 2.17.3 203 | - Update rubocop-rspec to 2.15.0 204 | 205 | # 4.8.0 206 | 207 | - Update rubocop to 1.37.1 208 | - Update rubocop-ast to 1.23.0 209 | - Update rubocop-rails to 2.17.1 210 | - Update rubocop-rspec to 2.14.1 211 | 212 | # 4.7.0 213 | 214 | - Update rubocop to 1.35.0 215 | - Update rubocop-ast to 1.21.0 216 | 217 | # 4.6.0 218 | 219 | - Update rubocop to 1.31.2 220 | - Update rubocop-ast to 1.19.1 221 | - Update rubocop-rails to 2.15.2 222 | - Update rubocop-rspec to 2.12.1 223 | 224 | # 4.5.0 225 | 226 | - Update rubocop to 1.30.1 227 | - Update rubocop-ast to 1.18.0 228 | - Update rubocop-rspec to 2.11.1 229 | 230 | # 4.4.0 231 | 232 | - Update rubocop to 1.27.0 233 | - Update rubocop-ast to 1.17.0 234 | - Update rubocop-rails to 2.14.2 235 | - Update rubocop-rspec to 2.10.0 236 | - Drop support for Ruby 2.6 237 | 238 | # 4.3.0 239 | 240 | - Update rubocop to 1.25.0 241 | - Update rubocop-ast to 1.15.1 242 | - Update rubocop-rails to 2.13.2 243 | - Update rubocop-rspec to 2.7.0 244 | 245 | # 4.2.0 246 | 247 | - Update rubocop to 1.23.0 248 | - Update rubocop-ast to 1.13.0 249 | - Update rubocop-rails to 2.12.4 250 | - Update rubocop-rspec to 2.6.0 251 | 252 | # 4.1.0 253 | 254 | - Update rubocop to 1.21.0 255 | - Update rubocop-ast to 1.11.0 256 | - Update rubocop-rails to 2.12.0 257 | - Update rubocop-rspec to 2.4.0 258 | - Update rubocop-rake to 0.6.0 259 | 260 | # 4.0.0 261 | 262 | - Update rubocop to 1.15.0 263 | - Update rubocop-ast to 1.6.0 264 | - Update rubocop-rails to 2.10.0 265 | - Update rubocop-rspec to 2.3.0 266 | 267 | # 4.0.0.pre.1 268 | 269 | - Released as a pre-release to try surface any issues before wider rollout, 270 | use https://github.com/alphagov/rubocop-govuk/issues/129 to record any 271 | problems 272 | - BREAKING: Upgraded from Rubocop 0.x to 1.x which introduces lots of new 273 | cops 274 | - Update rubocop to 1.10.0 275 | - Update rubocop-ast to 1.4.0 276 | - Update rubocop-rails to 2.9.1 277 | - Update rubocop-rspec to 2.2.0 278 | - Make stable dependencies (>= 1.0) less strict on patch version 279 | - Disable `SuggestExtensions` to stop Rubocop suggesting additional 280 | extensions at runtime 281 | - Explicitly set target Ruby version to `>= 2.6` in gemspec 282 | - Downgrade local Ruby version to `2.6.6` to capture lowest supported 283 | Ruby version 284 | - Fix namespace change of `Capybara/FeatureMethods` 285 | - Disable `Naming/VariableNumbers` 286 | 287 | # 4.0.0.pre.pre.1 288 | 289 | - Mistakenly named release, same as 4.0.0.pre.1 290 | 291 | # 3.17.2 292 | 293 | - Rename Blacklist to ForbiddenMethods to fix rubocop-rails warnings 294 | 295 | # 3.17.1 296 | 297 | - Pin rubocop-ast to 0.8.0 298 | 299 | # 3.17.0 300 | 301 | - Enable Rails/SaveBang 302 | - Enable Style/DateTime 303 | - Enforce strict Time.zone.now 304 | - Bump rubocop to 0.87.1 305 | - Bump rubocop-rspec to 1.42.0 306 | 307 | # 3.16.0 308 | 309 | - Bump and lock rubocop-rails to 2.6.0 310 | - Bump and lock rubocop-rspec to 1.39.0 311 | 312 | # 3.15.0 313 | 314 | - Remove cops that are RuboCop defaults (#88) 315 | - Disable Rails/DynamicFindBy 316 | - Permit "and", "but" with RSpec/ContextWording 317 | 318 | # 3.14.0 319 | 320 | - Disable Rails/InverseOf 321 | - Disable Rails/HasManyOrHasOneDependent 322 | - Disable Rails/OutputSafety 323 | 324 | # 3.13.0 325 | 326 | - Disable Layout/FirstMethodArgumentLineBreak (#79) 327 | - Disable Layout/MultilineMethodArgumentLineBreaks (#80) 328 | 329 | # 3.12.0 330 | 331 | - Disable Rails/HasAndBelongsToMany (#77) 332 | 333 | # 3.11.0 334 | 335 | - Add optional config for RSpec Cops (#75) 336 | - Enable Style/Next (#74) 337 | - Partially enable Rails/SkipsModelValidations (#74) 338 | - Partially enable Rails/Output (#74) 339 | - Enable Rails/HasAndBelongsToMany (#74) 340 | - Enable Bundler/DuplicatedGem (#74) 341 | 342 | # 3.10.0 343 | 344 | * Enable Style/NegatedIf (#71) 345 | * Enable Style/GlobalVars (#71) 346 | * Enable Style/RaiseArgs (#71) 347 | * Enable Style/MethodDefParentheses (#71) 348 | * Enable Style/NumericLiterals (#71) 349 | * Enable Layout/MultilineArrayLineBreaks (#63) 350 | * Enable Layout/MultilineHashKeyLineBreaks (#63) 351 | * Enable Layout/MultilineMethodArgumentLineBreaks (#63) 352 | * Enable Layout/FirstMethodArgumentLineBreak (#63) 353 | * Fix bug with Style/FormatString (#70) 354 | 355 | # 3.9.0 356 | 357 | * Enable Style/Alias (#60) 358 | * Enable Style/AsciiComments (#60) 359 | * Enable Style/BlockDelimiters (#60) 360 | * Enable Style/CaseEquality (#60) 361 | * Enable Style/PreferredHashMethods (#60) 362 | * Enable Style/DoubleNegation (#60) 363 | * Enable Style/FormatString (#60) 364 | * Enable Style/Encoding (#64) 365 | * Enable Style/IfWithSemicolon (#64) 366 | * Enable Style/Lambda (#64) 367 | * Enable Style/LambdaCall (#64) 368 | * Enable Style/ModuleFunction (#64) 369 | * Enable Style/NilComparison (#64) 370 | * Enable Style/SignalException (#64) 371 | * Enable Style/SingleLineMethods (#64) 372 | * Enable Style/CommandLiteral (#64) 373 | * Disable Metrics/BlockLength (#65, #68) 374 | 375 | # 3.8.0 376 | 377 | * Enable check for flip-flops (#55) 378 | * Enable Layout/FirstArrayElementIndentation (#56) 379 | * Enable Layout/FirstHashElementIndentation (#56) 380 | * Enable Naming/AsciiIdentifiers (#58) 381 | * Enable Naming/FileName (#58) 382 | * Enable Rails/ActionFilter (#59) 383 | * Enable Rails/ScopeArgs (#59) 384 | 385 | # 3.7.0 386 | 387 | * Turn a load of Cops back on (#52) 388 | 389 | # 3.6.0 390 | 391 | * Remove config that matches RuboCop defaults (#47) 392 | * Reorganise all the Cops (#44) 393 | 394 | # 3.5.0 395 | 396 | * Disable pending cops by default (#37) 397 | 398 | # 3.4.0 399 | 400 | * Add rubocop-rake cops (#32) 401 | * Revert #27 (hash transform cops) (#31) 402 | 403 | # 3.3.2 404 | 405 | * Exclude /tmp directory (#29) 406 | 407 | # 3.3.1 408 | 409 | * Exclude two unsafe style cops (#27) 410 | 411 | # 3.3.0 412 | 413 | * Exclude Rails migrations from linting checks (#25) 414 | 415 | # 3.2.0 416 | 417 | * Configure new cops about hash styles (#24) 418 | * Exclude `tmp` directory from linting checks (#22) 419 | 420 | # 3.1.0 421 | 422 | * Fix deprecation warning for AllCops/Excludes => AllCops/Exclude (#17) 423 | * Exclude `config.ru` from linter checks (#18) 424 | 425 | # 3.0.0 426 | 427 | * Update Rubocop to 0.80.1 428 | * This deletes the Style/BracesAroundHashParameters cop for future 429 | Ruby 3 compatibility. 430 | * Exclude `bin` directory and `db/schema.rb` from linter checks (#14) 431 | 432 | # 2.0.0 433 | 434 | * Use specific version for RuboCop 435 | * Update RuboCop to 0.77 436 | 437 | # 1.0.0 438 | 439 | * Allow importing of Ruby and Rails rules seperately 440 | 441 | # 0.2.0 442 | 443 | * Disable the Style/FormatStringToken cop 444 | 445 | # 0.1.0 446 | 447 | * Initial release with previous work from `govuk-lint` 448 | --------------------------------------------------------------------------------