rubocop-govuk 3.12.0 → 3.17.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 +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +16 -12
- data/config/layout.yml +0 -21
- data/config/rails.yml +52 -0
- data/config/rspec.yml +10 -0
- data/config/style.yml +8 -19
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af3af6d23a64db34fb0e3713513b75a2666647c18b60c92379a8d000cf3bcca
|
4
|
+
data.tar.gz: 87cae9593714f68d179f0588a340d0d6792495a295043eef258f09d79cefd9ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c33dab371549df141d65ec957462d79d5d9f3de28206c2f4842fd692c0e58b417bf24cef2238a7539ea141f1364639f6db9032d3d62c60c5082164399b244a
|
7
|
+
data.tar.gz: 89c6ac7ca0daf85714140b5f6ce4d3b9e6d02646267ff4a4f848f63d191450691e79dea222ca494ffbce13cee24119010722f772b65e537bef5f283507c7a6fd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
# 3.17.0
|
2
|
+
|
3
|
+
- Enable Rails/SaveBang
|
4
|
+
- Enable Style/DateTime
|
5
|
+
- Enforce strict Time.zone.now
|
6
|
+
- Bump rubocop to 0.87.1
|
7
|
+
- Bump rubocop-rspec to 1.42.0
|
8
|
+
|
9
|
+
# 3.16.0
|
10
|
+
|
11
|
+
- Bump and lock rubocop-rails to 2.6.0
|
12
|
+
- Bump and lock rubocop-rspec to 1.39.0
|
13
|
+
|
14
|
+
# 3.15.0
|
15
|
+
|
16
|
+
- Remove cops that are RuboCop defaults (#88)
|
17
|
+
- Disable Rails/DynamicFindBy
|
18
|
+
- Permit "and", "but" with RSpec/ContextWording
|
19
|
+
|
20
|
+
# 3.14.0
|
21
|
+
|
22
|
+
- Disable Rails/InverseOf
|
23
|
+
- Disable Rails/HasManyOrHasOneDependent
|
24
|
+
- Disable Rails/OutputSafety
|
25
|
+
|
26
|
+
# 3.13.0
|
27
|
+
|
28
|
+
- Disable Layout/FirstMethodArgumentLineBreak (#79)
|
29
|
+
- Disable Layout/MultilineMethodArgumentLineBreaks (#80)
|
30
|
+
|
1
31
|
# 3.12.0
|
2
32
|
|
3
33
|
- Disable Rails/HasAndBelongsToMany (#77)
|
data/README.md
CHANGED
@@ -11,35 +11,39 @@ Add `rubocop-govuk` to your Gemfile and then run `bundle install`:
|
|
11
11
|
gem 'rubocop-govuk'
|
12
12
|
```
|
13
13
|
|
14
|
-
|
14
|
+
Then inherit the default rules by adding the following in your project:
|
15
15
|
|
16
16
|
```yaml
|
17
17
|
# .rubocop.yml
|
18
18
|
inherit_gem:
|
19
19
|
rubocop-govuk:
|
20
20
|
- config/default.yml
|
21
|
+
|
22
|
+
inherit_mode:
|
23
|
+
merge:
|
24
|
+
- Exclude
|
21
25
|
```
|
22
26
|
|
23
|
-
|
27
|
+
You can also configure additional rules for Rails and RSpec:
|
24
28
|
|
25
29
|
```yaml
|
26
30
|
# .rubocop.yml
|
27
31
|
inherit_gem:
|
28
32
|
rubocop-govuk:
|
29
|
-
|
33
|
+
...
|
30
34
|
- config/rails.yml
|
31
|
-
|
32
|
-
inherit_mode:
|
33
|
-
merge:
|
34
|
-
- Exclude
|
35
35
|
```
|
36
36
|
|
37
|
-
|
37
|
+
```yaml
|
38
|
+
# .rubocop.yml
|
39
|
+
inherit_gem:
|
40
|
+
rubocop-govuk:
|
41
|
+
...
|
42
|
+
- config/rspec.yml
|
43
|
+
```
|
38
44
|
|
39
|
-
|
45
|
+
## Testing
|
40
46
|
|
41
|
-
|
42
|
-
bundle exec rubocop
|
43
|
-
```
|
47
|
+
Run `bundle exec rake`.
|
44
48
|
|
45
49
|
[guides]: https://github.com/alphagov/styleguides
|
data/config/layout.yml
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
# Part of the orignal GDS styleguide
|
2
|
-
# "Use empty lines between defs and to break up a method into logical paragraphs."
|
3
|
-
# https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#general
|
4
|
-
Layout/EmptyLineBetweenDefs:
|
5
|
-
Enabled: true
|
6
|
-
AllowAdjacentOneLineDefs: false
|
7
|
-
|
8
1
|
# https://github.com/alphagov/govuk-lint/pull/7
|
9
2
|
# "There are occasions where following this rule forces you to make the
|
10
3
|
# code less readable. This is particularly the case for tests where method
|
@@ -83,17 +76,3 @@ Layout/MultilineArrayLineBreaks:
|
|
83
76
|
# and avoids wasting time tweaking an arbitrary layout.
|
84
77
|
Layout/MultilineHashKeyLineBreaks:
|
85
78
|
Enabled: true
|
86
|
-
|
87
|
-
# We should be consistent: if some items of a method call are
|
88
|
-
# on multiple lines, then all items should be. This works
|
89
|
-
# better with the indentation Cops, produces clearer diffs,
|
90
|
-
# and avoids wasting time tweaking an arbitrary layout.
|
91
|
-
Layout/MultilineMethodArgumentLineBreaks:
|
92
|
-
Enabled: true
|
93
|
-
|
94
|
-
# We should put each argument of a method call on a new line,
|
95
|
-
# if any are on new lines. This prevents unnecessary decisions
|
96
|
-
# about which style to use; the multiline style also helps to
|
97
|
-
# avoid excessively long lines.
|
98
|
-
Layout/FirstMethodArgumentLineBreak:
|
99
|
-
Enabled: true
|
data/config/rails.yml
CHANGED
@@ -13,6 +13,17 @@ AllCops:
|
|
13
13
|
Rails:
|
14
14
|
Enabled: true
|
15
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
|
+
|
16
27
|
# We commonly print output in Ruby code that has been
|
17
28
|
# extracted from a Rake task in 'lib/'.
|
18
29
|
Rails/Output:
|
@@ -40,3 +51,44 @@ Rails/SkipsModelValidations:
|
|
40
51
|
# relationships are just # many-to-many, and that's it.
|
41
52
|
Rails/HasAndBelongsToMany:
|
42
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"
|
data/config/rspec.yml
CHANGED
@@ -35,3 +35,13 @@ RSpec/MessageSpies:
|
|
35
35
|
# it's not clear what action to take to fix an issue.
|
36
36
|
RSpec/NestedGroups:
|
37
37
|
Enabled: false
|
38
|
+
|
39
|
+
# Nested contexts make more sense with "and" or "but", since
|
40
|
+
# they are a refinement of an outer context.
|
41
|
+
RSpec/ContextWording:
|
42
|
+
Prefixes:
|
43
|
+
- when
|
44
|
+
- with
|
45
|
+
- without
|
46
|
+
- and
|
47
|
+
- but
|
data/config/style.yml
CHANGED
@@ -13,20 +13,6 @@ Style/IfUnlessModifier:
|
|
13
13
|
Style/MethodCalledOnDoEndBlock:
|
14
14
|
Enabled: true
|
15
15
|
|
16
|
-
# Part of the orignal GDS styleguide
|
17
|
-
# "Omit the parentheses when the method doesn’t accept any arguments"
|
18
|
-
# https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#syntax
|
19
|
-
Style/MethodCallWithoutArgsParentheses:
|
20
|
-
Enabled: true
|
21
|
-
|
22
|
-
# Part of the orignal GDS styleguide
|
23
|
-
# "Use Ruby 1.9 syntax for symbolic hash keys.
|
24
|
-
# This includes method calls."
|
25
|
-
# https://github.com/alphagov/styleguides/blob/6395a10d41c3938f4c147cda443fd83f854c3e7a/ruby.md#collections
|
26
|
-
Style/HashSyntax:
|
27
|
-
Exclude:
|
28
|
-
- 'db/schema.rb'
|
29
|
-
|
30
16
|
# Part of the orignal GDS styleguide
|
31
17
|
# "Add a trailing comma to multi-line array [...]
|
32
18
|
# for clearer diffs with less line noise."
|
@@ -153,14 +139,17 @@ Style/RegexpLiteral:
|
|
153
139
|
Style/SafeNavigation:
|
154
140
|
Enabled: false
|
155
141
|
|
156
|
-
# We should allow for single line empty methods, as this
|
157
|
-
# is a convention for Rails controller actions.
|
158
|
-
Style/SingleLineMethods:
|
159
|
-
AllowIfMethodIsEmpty: true
|
160
|
-
|
161
142
|
# Introduced in: b171d652d3e434b74ddc621df3b5be24c49bc7e8
|
162
143
|
# This cop was added in preperation for a Ruby feature
|
163
144
|
# that is no longer likely to become part of the language.
|
164
145
|
# https://github.com/rubocop-hq/rubocop/issues/7197
|
165
146
|
Style/FrozenStringLiteralComment:
|
166
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
|
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.
|
4
|
+
version: 3.17.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-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '13
|
19
|
+
version: '13'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '13
|
26
|
+
version: '13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.87.1
|
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.
|
40
|
+
version: 0.87.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.6.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:
|
54
|
+
version: 2.6.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.5.1
|
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
68
|
version: 0.5.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.42.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:
|
82
|
+
version: 1.42.0
|
83
83
|
description: Shared RuboCop rules for Ruby projects in GOV.UK
|
84
84
|
email:
|
85
85
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.1.
|
121
|
+
rubygems_version: 3.1.4
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: RuboCop GOV.UK
|