rubocop-govuk 3.17.2 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b616c24ca10792345f9270f1eda98ba66a75a4d1672cf1a917db76596ec8ffd1
4
- data.tar.gz: 672788da8bcbd07a06a544acb7b746a34cc697446d72c76cf7fd745ffc0e3454
3
+ metadata.gz: 347f72f459d1d27eed0cb6091f07a4bebd0a2d1dc43d915f64370349fb670dd1
4
+ data.tar.gz: c04dc7953ff4437d04d70c96fd63e092b4e1429fc77188012029f2ee4d758bd6
5
5
  SHA512:
6
- metadata.gz: 2ea901cf52031d78896105a99c1792eb47c2c2d90ce8b14f3ac76c2767e74fed7b6570b309f1a429f5c6416eb51dee99aa90af1faa9b168748337e466f7bd7d0
7
- data.tar.gz: 1a0373d4ad1b24899a92b916214cc0f8fc097ba1dd2b2962e44a193d28fb7f1c910df1bef8a48f62cb6baddd62a952cd2501decd6c3af9d8d0bbe7817ec8718c
6
+ metadata.gz: 0e12b34da4a0cb1bec5649039495da937742339ecfeb15f49fe25553dd13f1b3bc6f45f79ff4aeb121b59639084fea577a7b394e15f7b97745fbcf520ff36e7e
7
+ data.tar.gz: b95261537420b8907a19056fad2b34e664d3f466c9a254401237429d44e3c5fcc01ab569b0f00f24fc67fe375dcd4d37ffb717e14532896e09aeb4690fb634b7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,49 @@
1
+ # 4.2.0
2
+
3
+ - Update rubocop to 1.23.0
4
+ - Update rubocop-ast to 1.13.0
5
+ - Update rubocop-rails to 2.12.4
6
+ - Update rubocop-rspec to 2.6.0
7
+
8
+ # 4.1.0
9
+
10
+ - Update rubocop to 1.21.0
11
+ - Update rubocop-ast to 1.11.0
12
+ - Update rubocop-rails to 2.12.0
13
+ - Update rubocop-rspec to 2.4.0
14
+ - Update rubocop-rake to 0.6.0
15
+
16
+ # 4.0.0
17
+
18
+ - Update rubocop to 1.15.0
19
+ - Update rubocop-ast to 1.6.0
20
+ - Update rubocop-rails to 2.10.0
21
+ - Update rubocop-rspec to 2.3.0
22
+
23
+ # 4.0.0.pre.1
24
+
25
+ - Released as a pre-release to try surface any issues before wider rollout,
26
+ use https://github.com/alphagov/rubocop-govuk/issues/129 to record any
27
+ problems
28
+ - BREAKING: Upgraded from Rubocop 0.x to 1.x which introduces lots of new
29
+ cops
30
+ - Update rubocop to 1.10.0
31
+ - Update rubocop-ast to 1.4.0
32
+ - Update rubocop-rails to 2.9.1
33
+ - Update rubocop-rspec to 2.2.0
34
+ - Make stable dependencies (>= 1.0) less strict on patch version
35
+ - Disable `SuggestExtensions` to stop Rubocop suggesting additional
36
+ extensions at runtime
37
+ - Explicitly set target Ruby version to `>= 2.6` in gemspec
38
+ - Downgrade local Ruby version to `2.6.6` to capture lowest supported
39
+ Ruby version
40
+ - Fix namespace change of `Capybara/FeatureMethods`
41
+ - Disable `Naming/VariableNumbers`
42
+
43
+ # 4.0.0.pre.pre.1
44
+
45
+ - Mistakenly named release, same as 4.0.0.pre.1
46
+
1
47
  # 3.17.2
2
48
 
3
49
  - Rename Blacklist to ForbiddenMethods to fix rubocop-rails warnings
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,78 @@
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 locally by tweaking the Gemfile or `.gemspec` for the repo e.g.
33
+
34
+ ```
35
+ gem "rubocop-govuk", path: "/govuk/rubocop-govuk"
36
+ ```
37
+
38
+ This is a rough list of typical GOV.UK repos we recommend testing against:
39
+
40
+ - An old app e.g. Whitehall, Smart Answers
41
+ - A newer app e.g. Content Publisher, Email Alert API
42
+ - A non-Rails app e.g. Search API
43
+ - A gem e.g. GDS API Adapters
44
+
45
+ ### 2. Decide if the config needs to change
46
+
47
+ Ideally we should have none of our own config and follow RuboCop defaults:
48
+
49
+ - This is easier than making our own decisions.
50
+ - We don't want to diverge from the Ruby community.
51
+
52
+ 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**.
53
+
54
+ You should only change the config as a last resort. Examples of good changes:
55
+
56
+ - Disable a rule if it's based on heuristics ([example](https://github.com/alphagov/rubocop-govuk/blob/ce655779e45892db6ac00d6789c652ec2e506748/config/metrics.yml#L1-L10)).
57
+
58
+ - Change a rule to match a GOV.UK-wide pattern ([example](https://github.com/alphagov/rubocop-govuk/blob/ce655779e45892db6ac00d6789c652ec2e506748/config/rails.yml#L16-L25)).
59
+
60
+ - 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)).
61
+
62
+ 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.
63
+
64
+ ### 3. Consider making a pre-release version
65
+
66
+ 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.
67
+
68
+ 👉 [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).
69
+
70
+ ### 4. Make your CHANGELOG really helpful
71
+
72
+ 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:
73
+
74
+ - Gives an overview of the change e.g. "Upgrade X to Y".
75
+
76
+ - Explains any actions to take e.g. "run `rubocop -A`".
77
+
78
+ - Advises on potential compatibility issues (TODO: example).
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # RuboCop GOV.UK
2
2
 
3
- This repository provides common RuboCop rules for use with GOV.UK Ruby projects to comply with our [style guides][guides].
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.
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,7 +10,7 @@ Add `rubocop-govuk` to your Gemfile and then run `bundle install`:
8
10
 
9
11
  ```ruby
10
12
  # Gemfile
11
- gem 'rubocop-govuk'
13
+ gem 'rubocop-govuk', require: false
12
14
  ```
13
15
 
14
16
  Then inherit the default rules by adding the following in your project:
@@ -42,8 +44,6 @@ inherit_gem:
42
44
  - config/rspec.yml
43
45
  ```
44
46
 
45
- ## Testing
46
-
47
- Run `bundle exec rake`.
47
+ ## Contributing
48
48
 
49
- [guides]: https://github.com/alphagov/styleguides
49
+ 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.
data/config/capybara.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  # Within GOV.UK we use Capybara test method syntax of feature,
2
2
  # scenario. We don't want this outside of feature specs though.
3
- Capybara/FeatureMethods:
3
+ RSpec/Capybara/FeatureMethods:
4
4
  Exclude:
5
5
  - 'spec/features/**/*.rb'
data/config/default.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  NewCops: disable
3
+ SuggestExtensions: false
3
4
  Exclude:
4
5
  - 'bin/**'
5
6
  - 'config.ru'
data/config/naming.yml CHANGED
@@ -19,3 +19,10 @@ Naming/AccessorMethodName:
19
19
  # repos, which would require manual intervention.
20
20
  Naming/PredicateName:
21
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
data/config/rspec.yml CHANGED
@@ -10,6 +10,11 @@ inherit_from:
10
10
  RSpec/ExampleLength:
11
11
  Enabled: false
12
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
+
13
18
  # We have common cases, such as rake tasks, where we do not
14
19
  # use a class to the describe the test.
15
20
  RSpec/DescribeClass:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-govuk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.2
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-14 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,70 +30,70 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.87.1
33
+ version: 1.23.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.87.1
40
+ version: 1.23.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop-ast
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.0
47
+ version: 1.13.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.0
54
+ version: 1.13.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.8.1
61
+ version: 2.12.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 2.8.1
68
+ version: 2.12.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.5.1
75
+ version: 0.6.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.5.1
82
+ version: 0.6.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 1.42.0
89
+ version: 2.6.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 1.42.0
96
+ version: 2.6.0
97
97
  description: Shared RuboCop rules for Ruby projects in GOV.UK
98
98
  email:
99
99
  - govuk-dev@digital.cabinet-office.gov.uk
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - CHANGELOG.md
105
+ - CONTRIBUTING.md
105
106
  - LICENSE.md
106
107
  - README.md
107
108
  - config/capybara.yml
@@ -125,14 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
126
  requirements:
126
127
  - - ">="
127
128
  - !ruby/object:Gem::Version
128
- version: '0'
129
+ version: '2.6'
129
130
  required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  requirements:
131
132
  - - ">="
132
133
  - !ruby/object:Gem::Version
133
134
  version: '0'
134
135
  requirements: []
135
- rubygems_version: 3.1.4
136
+ rubygems_version: 3.2.31
136
137
  signing_key:
137
138
  specification_version: 4
138
139
  summary: RuboCop GOV.UK