gitlab-styles 10.1.0 → 12.0.1
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/.gitlab-ci.yml +41 -24
- data/.rubocop_todo.yml +1 -10
- data/Gemfile.lock +46 -40
- data/README.md +2 -1
- data/gitlab-styles.gemspec +8 -7
- data/lib/gitlab/styles/rubocop.rb +1 -1
- data/lib/gitlab/styles/version.rb +1 -1
- data/lib/rubocop/cop/active_record_dependent.rb +10 -12
- data/lib/rubocop/cop/active_record_serialize.rb +5 -1
- data/lib/rubocop/cop/code_reuse/active_record.rb +1 -1
- data/lib/rubocop/cop/gem_fetcher.rb +1 -1
- data/lib/rubocop/cop/gitlab_security/redirect_to_params_update.rb +1 -1
- data/lib/rubocop/cop/gitlab_security/send_file_params.rb +1 -1
- data/lib/rubocop/cop/gitlab_security/system_command_injection.rb +1 -1
- data/lib/rubocop/cop/in_batches.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/use_restrict_on_send.rb +1 -1
- data/lib/rubocop/cop/layout/line_break_after_final_mixin.rb +75 -0
- data/lib/rubocop/cop/migration/update_large_table.rb +2 -2
- data/lib/rubocop/cop/performance/rubyzip.rb +4 -4
- data/lib/rubocop/cop/polymorphic_associations.rb +8 -5
- data/lib/rubocop/cop/rspec/specify_expected.rb +49 -0
- data/lib/rubocop/cop/style/open_struct_use.rb +2 -2
- data/lib/rubocop/cop/without_reactive_cache.rb +2 -2
- data/rubocop-all.yml +2 -1
- data/rubocop-default.yml +1 -15
- data/rubocop-factory_bot.yml +8 -0
- data/rubocop-gemspec.yml +15 -4
- data/rubocop-graphql.yml +27 -1
- data/rubocop-layout.yml +16 -4
- data/rubocop-minimal.yml +17 -0
- data/rubocop-rails.yml +5 -0
- data/rubocop-rspec.yml +14 -6
- data/rubocop-style.yml +14 -6
- metadata +38 -21
- data/lib/rubocop/cop/rspec/factory_bot/excessive_create_list.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5301968fa7603c90e9ed917011c49e4a3124a7c442963e778fcc1f4862c7cf03
|
|
4
|
+
data.tar.gz: 4b7676b2fcdb2bed6f3be9c8b0505ba04afa5ec008e95b6c980da5ef3a795032
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcb7c63e4e3cacd1638d87b2406483d763ecad6dbdb218a3da292f8be56112ca64d0d1596ac108143981d502834f6672e4c9128981edc8b6bd05566c924289f7
|
|
7
|
+
data.tar.gz: e08bb7c660e85a30ffc64d669363e6b420219745231a5ea7e5524e657ae72c4f6b1fcb00c9d01d31c9bb846c5d8be57db22d8640dff67ae554f76db2092375ae
|
data/.gitlab-ci.yml
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
+
workflow:
|
|
2
|
+
rules:
|
|
3
|
+
# For merge requests, create a pipeline.
|
|
4
|
+
- if: '$CI_MERGE_REQUEST_IID'
|
|
5
|
+
# For the default branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
|
|
6
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
7
|
+
# For tags, create a pipeline.
|
|
8
|
+
- if: '$CI_COMMIT_TAG'
|
|
9
|
+
|
|
1
10
|
stages:
|
|
2
11
|
- test
|
|
3
12
|
- deploy
|
|
4
13
|
|
|
5
14
|
default:
|
|
6
|
-
image: "ruby:${RUBY_VERSION}"
|
|
7
15
|
tags:
|
|
8
16
|
- gitlab-org
|
|
17
|
+
|
|
18
|
+
.base-ruby-job:
|
|
19
|
+
image: "ruby:${RUBY_VERSION}"
|
|
9
20
|
before_script:
|
|
10
21
|
- bundle --version
|
|
11
|
-
- bundle
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
workflow:
|
|
17
|
-
rules:
|
|
18
|
-
# For merge requests, create a pipeline.
|
|
19
|
-
- if: '$CI_MERGE_REQUEST_IID'
|
|
20
|
-
# For the default branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
|
|
21
|
-
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
22
|
-
# For tags, create a pipeline.
|
|
23
|
-
- if: '$CI_COMMIT_TAG'
|
|
22
|
+
- bundle config set --local deployment 'true'
|
|
23
|
+
- bundle install -j $(nproc)
|
|
24
|
+
parallel:
|
|
25
|
+
matrix:
|
|
26
|
+
- RUBY_VERSION: ['3.0', '3.1', '3.2']
|
|
24
27
|
|
|
25
28
|
styles:
|
|
29
|
+
extends: .base-ruby-job
|
|
26
30
|
stage: test
|
|
27
31
|
script:
|
|
28
32
|
- bundle exec rubocop --debug --parallel
|
|
29
|
-
parallel:
|
|
30
|
-
matrix:
|
|
31
|
-
- RUBY_VERSION: ['2.7', '3.0', '3.1', '3.2']
|
|
32
33
|
|
|
33
34
|
specs:
|
|
35
|
+
extends: .base-ruby-job
|
|
34
36
|
stage: test
|
|
35
37
|
script:
|
|
36
38
|
# Disable simplecov for all Ruby version other than 3.0
|
|
37
39
|
- if [[ "$RUBY_VERSION" != "3.0" ]]; then export SIMPLECOV=0; fi
|
|
38
40
|
- bundle exec rspec
|
|
39
|
-
parallel:
|
|
40
|
-
matrix:
|
|
41
|
-
- RUBY_VERSION: ['2.7', '3.0', '3.1', '3.2']
|
|
42
41
|
artifacts:
|
|
43
42
|
name: coverage
|
|
44
43
|
expire_in: 31d
|
|
@@ -51,7 +50,25 @@ specs:
|
|
|
51
50
|
path: coverage/coverage.xml
|
|
52
51
|
|
|
53
52
|
include:
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
- component: gitlab.com/components/sast/sast@~latest
|
|
54
|
+
- component: gitlab.com/components/secret-detection/secret-detection@~latest
|
|
55
|
+
- component: gitlab.com/gitlab-org/components/gem-release/gem-release@~latest
|
|
56
|
+
inputs:
|
|
57
|
+
smoke_test_script: "ruby -r 'gitlab/styles' -e \"puts Gitlab::Styles::VERSION\""
|
|
58
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
59
|
+
- component: gitlab.com/gitlab-org/components/danger-review/danger-review@~latest
|
|
60
|
+
|
|
61
|
+
semgrep-sast:
|
|
62
|
+
rules:
|
|
63
|
+
- if: '$CI_MERGE_REQUEST_IID'
|
|
64
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
65
|
+
|
|
66
|
+
gemnasium-dependency_scanning:
|
|
67
|
+
rules:
|
|
68
|
+
- if: '$CI_MERGE_REQUEST_IID'
|
|
69
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
70
|
+
|
|
71
|
+
secret_detection:
|
|
72
|
+
rules:
|
|
73
|
+
- if: '$CI_MERGE_REQUEST_IID'
|
|
74
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2024-01-24 13:27:15 UTC using RuboCop version 1.57.2.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -25,12 +25,3 @@ InternalAffairs/MissingCopDepartment:
|
|
|
25
25
|
- 'lib/rubocop/cop/polymorphic_associations.rb'
|
|
26
26
|
- 'lib/rubocop/cop/redirect_with_status.rb'
|
|
27
27
|
- 'lib/rubocop/cop/without_reactive_cache.rb'
|
|
28
|
-
|
|
29
|
-
# Offense count: 5
|
|
30
|
-
InternalAffairs/UseRestrictOnSend:
|
|
31
|
-
Exclude:
|
|
32
|
-
- 'lib/rubocop/cop/active_record_dependent.rb'
|
|
33
|
-
- 'lib/rubocop/cop/active_record_serialize.rb'
|
|
34
|
-
- 'lib/rubocop/cop/in_batches.rb'
|
|
35
|
-
- 'lib/rubocop/cop/polymorphic_associations.rb'
|
|
36
|
-
- 'lib/rubocop/cop/without_reactive_cache.rb'
|
data/Gemfile.lock
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gitlab-styles (
|
|
5
|
-
rubocop (~> 1.
|
|
6
|
-
rubocop-
|
|
7
|
-
rubocop-
|
|
8
|
-
rubocop-
|
|
9
|
-
rubocop-
|
|
4
|
+
gitlab-styles (12.0.1)
|
|
5
|
+
rubocop (~> 1.62.1)
|
|
6
|
+
rubocop-factory_bot (~> 2.25.1)
|
|
7
|
+
rubocop-graphql (~> 1.5.0)
|
|
8
|
+
rubocop-performance (~> 1.20.2)
|
|
9
|
+
rubocop-rails (~> 2.24.0)
|
|
10
|
+
rubocop-rspec (~> 2.27.1)
|
|
10
11
|
|
|
11
12
|
GEM
|
|
12
13
|
remote: https://rubygems.org/
|
|
@@ -16,7 +17,7 @@ GEM
|
|
|
16
17
|
i18n (>= 1.6, < 2)
|
|
17
18
|
minitest (>= 5.1)
|
|
18
19
|
tzinfo (~> 2.0)
|
|
19
|
-
addressable (2.8.
|
|
20
|
+
addressable (2.8.5)
|
|
20
21
|
public_suffix (>= 2.0.2, < 6.0)
|
|
21
22
|
ast (2.4.2)
|
|
22
23
|
binding_of_caller (1.0.0)
|
|
@@ -32,18 +33,18 @@ GEM
|
|
|
32
33
|
concurrent-ruby (1.2.2)
|
|
33
34
|
cork (0.3.0)
|
|
34
35
|
colored2 (~> 3.1)
|
|
35
|
-
danger (9.3.
|
|
36
|
+
danger (9.3.2)
|
|
36
37
|
claide (~> 1.0)
|
|
37
38
|
claide-plugins (>= 0.9.2)
|
|
38
39
|
colored2 (~> 3.1)
|
|
39
40
|
cork (~> 0.1)
|
|
40
41
|
faraday (>= 0.9.0, < 3.0)
|
|
41
42
|
faraday-http-cache (~> 2.0)
|
|
42
|
-
git (~> 1.13
|
|
43
|
+
git (~> 1.13)
|
|
43
44
|
kramdown (~> 2.3)
|
|
44
45
|
kramdown-parser-gfm (~> 1.0)
|
|
45
46
|
no_proxy_fix
|
|
46
|
-
octokit (~>
|
|
47
|
+
octokit (~> 6.0)
|
|
47
48
|
terminal-table (>= 1, < 4)
|
|
48
49
|
danger-gitlab (8.0.0)
|
|
49
50
|
danger
|
|
@@ -76,41 +77,43 @@ GEM
|
|
|
76
77
|
faraday-patron (1.0.0)
|
|
77
78
|
faraday-rack (1.0.0)
|
|
78
79
|
faraday-retry (1.0.3)
|
|
79
|
-
git (1.
|
|
80
|
+
git (1.18.0)
|
|
80
81
|
addressable (~> 2.8)
|
|
81
82
|
rchardet (~> 1.8)
|
|
82
83
|
gitlab (4.19.0)
|
|
83
84
|
httparty (~> 0.20)
|
|
84
85
|
terminal-table (>= 1.5.1)
|
|
85
|
-
gitlab-dangerfiles (
|
|
86
|
-
danger (>=
|
|
86
|
+
gitlab-dangerfiles (4.6.0)
|
|
87
|
+
danger (>= 9.3.0)
|
|
87
88
|
danger-gitlab (>= 8.0.0)
|
|
88
|
-
rake
|
|
89
|
+
rake (~> 13.0)
|
|
89
90
|
httparty (0.21.0)
|
|
90
91
|
mini_mime (>= 1.0.0)
|
|
91
92
|
multi_xml (>= 0.5.2)
|
|
92
93
|
i18n (1.13.0)
|
|
93
94
|
concurrent-ruby (~> 1.0)
|
|
94
|
-
json (2.
|
|
95
|
+
json (2.7.1)
|
|
95
96
|
kramdown (2.4.0)
|
|
96
97
|
rexml
|
|
97
98
|
kramdown-parser-gfm (1.1.0)
|
|
98
99
|
kramdown (~> 2.0)
|
|
100
|
+
language_server-protocol (3.17.0.3)
|
|
99
101
|
lefthook (1.3.13)
|
|
100
102
|
method_source (1.0.0)
|
|
101
|
-
mini_mime (1.1.
|
|
103
|
+
mini_mime (1.1.5)
|
|
102
104
|
minitest (5.18.0)
|
|
103
105
|
multi_xml (0.6.0)
|
|
104
106
|
multipart-post (2.3.0)
|
|
105
107
|
nap (1.1.0)
|
|
106
108
|
no_proxy_fix (0.1.2)
|
|
107
|
-
octokit (
|
|
109
|
+
octokit (6.1.1)
|
|
108
110
|
faraday (>= 1, < 3)
|
|
109
111
|
sawyer (~> 0.9)
|
|
110
112
|
open4 (1.3.4)
|
|
111
|
-
parallel (1.
|
|
112
|
-
parser (3.
|
|
113
|
+
parallel (1.24.0)
|
|
114
|
+
parser (3.3.0.5)
|
|
113
115
|
ast (~> 2.4.1)
|
|
116
|
+
racc
|
|
114
117
|
proc_to_ast (0.1.0)
|
|
115
118
|
coderay
|
|
116
119
|
parser
|
|
@@ -121,13 +124,14 @@ GEM
|
|
|
121
124
|
pry-byebug (3.10.1)
|
|
122
125
|
byebug (~> 11.0)
|
|
123
126
|
pry (>= 0.13, < 0.15)
|
|
124
|
-
public_suffix (5.0.
|
|
127
|
+
public_suffix (5.0.3)
|
|
128
|
+
racc (1.7.3)
|
|
125
129
|
rack (3.0.7)
|
|
126
130
|
rainbow (3.1.1)
|
|
127
131
|
rake (13.0.6)
|
|
128
132
|
rchardet (1.8.0)
|
|
129
|
-
regexp_parser (2.8.
|
|
130
|
-
rexml (3.2.
|
|
133
|
+
regexp_parser (2.8.3)
|
|
134
|
+
rexml (3.2.6)
|
|
131
135
|
rspec (3.12.0)
|
|
132
136
|
rspec-core (~> 3.12.0)
|
|
133
137
|
rspec-expectations (~> 3.12.0)
|
|
@@ -149,35 +153,37 @@ GEM
|
|
|
149
153
|
binding_of_caller
|
|
150
154
|
rspec-parameterized-core (< 2)
|
|
151
155
|
rspec-support (3.12.0)
|
|
152
|
-
rubocop (1.
|
|
156
|
+
rubocop (1.62.1)
|
|
153
157
|
json (~> 2.3)
|
|
158
|
+
language_server-protocol (>= 3.17.0)
|
|
154
159
|
parallel (~> 1.10)
|
|
155
|
-
parser (>= 3.
|
|
160
|
+
parser (>= 3.3.0.2)
|
|
156
161
|
rainbow (>= 2.2.2, < 4.0)
|
|
157
162
|
regexp_parser (>= 1.8, < 3.0)
|
|
158
163
|
rexml (>= 3.2.5, < 4.0)
|
|
159
|
-
rubocop-ast (>= 1.
|
|
164
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
160
165
|
ruby-progressbar (~> 1.7)
|
|
161
166
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
162
|
-
rubocop-ast (1.
|
|
163
|
-
parser (>= 3.
|
|
164
|
-
rubocop-capybara (2.
|
|
167
|
+
rubocop-ast (1.31.2)
|
|
168
|
+
parser (>= 3.3.0.4)
|
|
169
|
+
rubocop-capybara (2.20.0)
|
|
165
170
|
rubocop (~> 1.41)
|
|
166
|
-
rubocop-factory_bot (2.
|
|
167
|
-
rubocop (~> 1.
|
|
168
|
-
rubocop-graphql (
|
|
169
|
-
rubocop (>= 0.
|
|
170
|
-
rubocop-performance (1.
|
|
171
|
-
rubocop (>= 1.
|
|
172
|
-
rubocop-ast (>=
|
|
173
|
-
rubocop-rails (2.
|
|
171
|
+
rubocop-factory_bot (2.25.1)
|
|
172
|
+
rubocop (~> 1.41)
|
|
173
|
+
rubocop-graphql (1.5.0)
|
|
174
|
+
rubocop (>= 0.90, < 2)
|
|
175
|
+
rubocop-performance (1.20.2)
|
|
176
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
177
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
|
178
|
+
rubocop-rails (2.24.0)
|
|
174
179
|
activesupport (>= 4.2.0)
|
|
175
180
|
rack (>= 1.1)
|
|
176
181
|
rubocop (>= 1.33.0, < 2.0)
|
|
182
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
177
183
|
rubocop-rake (0.6.0)
|
|
178
184
|
rubocop (~> 1.0)
|
|
179
|
-
rubocop-rspec (2.
|
|
180
|
-
rubocop (~> 1.
|
|
185
|
+
rubocop-rspec (2.27.1)
|
|
186
|
+
rubocop (~> 1.40)
|
|
181
187
|
rubocop-capybara (~> 2.17)
|
|
182
188
|
rubocop-factory_bot (~> 2.22)
|
|
183
189
|
ruby-progressbar (1.13.0)
|
|
@@ -200,7 +206,7 @@ GEM
|
|
|
200
206
|
faraday (~> 1.0)
|
|
201
207
|
tzinfo (2.0.6)
|
|
202
208
|
concurrent-ruby (~> 1.0)
|
|
203
|
-
unicode-display_width (2.
|
|
209
|
+
unicode-display_width (2.5.0)
|
|
204
210
|
unparser (0.6.7)
|
|
205
211
|
diff-lcs (~> 1.3)
|
|
206
212
|
parser (>= 3.2.0)
|
|
@@ -210,7 +216,7 @@ PLATFORMS
|
|
|
210
216
|
|
|
211
217
|
DEPENDENCIES
|
|
212
218
|
bundler (~> 2.1)
|
|
213
|
-
gitlab-dangerfiles (~>
|
|
219
|
+
gitlab-dangerfiles (~> 4.6.0)
|
|
214
220
|
gitlab-styles!
|
|
215
221
|
lefthook (~> 1.3.13)
|
|
216
222
|
pry-byebug (~> 3.10)
|
data/README.md
CHANGED
|
@@ -91,7 +91,8 @@ To release a new version:
|
|
|
91
91
|
1. Create a Merge Request.
|
|
92
92
|
1. Use Merge Request template [Release.md](https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/blob/master/.gitlab/merge_request_templates/Release.md).
|
|
93
93
|
1. Follow the instructions.
|
|
94
|
-
1. After the Merge Request has been merged, a new gem version is [published automatically](https://gitlab.com/gitlab-org/
|
|
94
|
+
1. After the Merge Request has been merged, a new gem version is [published automatically](https://gitlab.com/gitlab-org/components/gem-release).
|
|
95
|
+
1. Once the new gem version is visible on [RubyGems.org](https://rubygems.org/gems/gitlab-styles), it is recommended to update [GitLab's `Gemfile`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/Gemfile) to bump the `gitlab-styles` Ruby gem to the new version also.
|
|
95
96
|
|
|
96
97
|
See [!123](https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/merge_requests/123) as an example.
|
|
97
98
|
|
data/gitlab-styles.gemspec
CHANGED
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
5
5
|
require 'gitlab/styles/version'
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.required_ruby_version = '>=
|
|
8
|
+
spec.required_ruby_version = '>= 3.0'
|
|
9
9
|
spec.name = 'gitlab-styles'
|
|
10
10
|
spec.version = Gitlab::Styles::VERSION
|
|
11
11
|
spec.authors = ['GitLab']
|
|
@@ -22,14 +22,15 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ['lib']
|
|
24
24
|
|
|
25
|
-
spec.add_dependency 'rubocop', '~> 1.
|
|
26
|
-
spec.add_dependency 'rubocop-
|
|
27
|
-
spec.add_dependency 'rubocop-
|
|
28
|
-
spec.add_dependency 'rubocop-
|
|
29
|
-
spec.add_dependency 'rubocop-
|
|
25
|
+
spec.add_dependency 'rubocop', '~> 1.62.1'
|
|
26
|
+
spec.add_dependency 'rubocop-factory_bot', '~> 2.25.1'
|
|
27
|
+
spec.add_dependency 'rubocop-graphql', '~> 1.5.0'
|
|
28
|
+
spec.add_dependency 'rubocop-performance', '~> 1.20.2'
|
|
29
|
+
spec.add_dependency 'rubocop-rails', '~> 2.24.0'
|
|
30
|
+
spec.add_dependency 'rubocop-rspec', '~> 2.27.1'
|
|
30
31
|
|
|
31
32
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
|
32
|
-
spec.add_development_dependency 'gitlab-dangerfiles', '~>
|
|
33
|
+
spec.add_development_dependency 'gitlab-dangerfiles', '~> 4.6.0'
|
|
33
34
|
spec.add_development_dependency 'lefthook', '~> 1.3.13'
|
|
34
35
|
spec.add_development_dependency 'pry-byebug', '~> 3.10'
|
|
35
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
@@ -5,21 +5,19 @@ module Rubocop
|
|
|
5
5
|
# Cop that prevents the use of `dependent: ...` in ActiveRecord models.
|
|
6
6
|
class ActiveRecordDependent < RuboCop::Cop::Base
|
|
7
7
|
MSG = 'Do not use `dependent:` to remove associated data, ' \
|
|
8
|
-
|
|
8
|
+
'use foreign keys with cascading deletes instead.'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
ALLOWED_OPTIONS = [
|
|
10
|
+
RESTRICT_ON_SEND = %i[has_many has_one belongs_to].to_set.freeze
|
|
11
|
+
ALLOWED_OPTIONS = %i[restrict_with_error].freeze
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
key_name = pair.children[0].children[0]
|
|
18
|
-
option_name = pair.children[1].children[0]
|
|
13
|
+
# @!method dependent_use(node)
|
|
14
|
+
def_node_matcher :dependent_use, <<~PATTERN
|
|
15
|
+
(send _ %RESTRICT_ON_SEND ... (hash <$(pair (sym :dependent) (sym $_)) ...>))
|
|
16
|
+
PATTERN
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
add_offense(pair)
|
|
18
|
+
def on_send(node)
|
|
19
|
+
dependent_use(node) do |pair, value|
|
|
20
|
+
add_offense(pair) unless ALLOWED_OPTIONS.include?(value)
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
23
|
end
|
|
@@ -6,8 +6,12 @@ module Rubocop
|
|
|
6
6
|
class ActiveRecordSerialize < RuboCop::Cop::Base
|
|
7
7
|
MSG = 'Do not store serialized data in the database, use separate columns and/or tables instead'
|
|
8
8
|
|
|
9
|
+
RESTRICT_ON_SEND = %i[serialize].freeze
|
|
10
|
+
|
|
9
11
|
def on_send(node)
|
|
10
|
-
|
|
12
|
+
return if node.receiver
|
|
13
|
+
|
|
14
|
+
add_offense(node.loc.selector)
|
|
11
15
|
end
|
|
12
16
|
end
|
|
13
17
|
end
|
|
@@ -6,7 +6,7 @@ module Rubocop
|
|
|
6
6
|
# Cop that denies the use of ActiveRecord methods outside of models.
|
|
7
7
|
class ActiveRecord < RuboCop::Cop::Base
|
|
8
8
|
MSG = 'This method can only be used inside an ActiveRecord model: ' \
|
|
9
|
-
|
|
9
|
+
'https://gitlab.com/gitlab-org/gitlab-foss/issues/49653'
|
|
10
10
|
|
|
11
11
|
# Various methods from ActiveRecord::Querying that are denied. We
|
|
12
12
|
# exclude some generic ones such as `any?` and `first`, as these may
|
|
@@ -7,7 +7,7 @@ module Rubocop
|
|
|
7
7
|
# rubygems.org.
|
|
8
8
|
class GemFetcher < RuboCop::Cop::Base
|
|
9
9
|
MSG = 'Do not use gems from git repositories, only use gems from RubyGems or vendored gems. ' \
|
|
10
|
-
|
|
10
|
+
'See https://docs.gitlab.com/ee/development/gemfile.html#no-gems-fetched-from-git-repositories'
|
|
11
11
|
|
|
12
12
|
# See https://bundler.io/guides/git.html#custom-git-sources
|
|
13
13
|
GIT_SOURCES = %i[git github gist bitbucket].freeze
|
|
@@ -17,7 +17,7 @@ module RuboCop
|
|
|
17
17
|
#
|
|
18
18
|
class RedirectToParamsUpdate < RuboCop::Cop::Base
|
|
19
19
|
MSG = 'Avoid using `redirect_to(params.%<name>s(...))`. ' \
|
|
20
|
-
|
|
20
|
+
'Only pass allowed arguments into redirect_to() (e.g. not including `host`)'
|
|
21
21
|
|
|
22
22
|
# @!method redirect_to_params_update_node(node)
|
|
23
23
|
def_node_matcher :redirect_to_params_update_node, <<-PATTERN
|
|
@@ -21,7 +21,7 @@ module RuboCop
|
|
|
21
21
|
#
|
|
22
22
|
class SendFileParams < RuboCop::Cop::Base
|
|
23
23
|
MSG = 'Do not pass user provided params directly to send_file(), ' \
|
|
24
|
-
|
|
24
|
+
'verify the path with file.expand_path() first.'
|
|
25
25
|
|
|
26
26
|
# @!method params_node?(node)
|
|
27
27
|
def_node_search :params_node?, <<-PATTERN
|
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
|
19
19
|
#
|
|
20
20
|
class SystemCommandInjection < RuboCop::Cop::Base
|
|
21
21
|
MSG = 'Do not include variables in the command name for system(). ' \
|
|
22
|
-
|
|
22
|
+
'Use parameters "system(cmd, params)" or exec() instead.'
|
|
23
23
|
|
|
24
24
|
# @!method system_var?(node)
|
|
25
25
|
def_node_matcher :system_var?, <<-PATTERN
|
|
@@ -6,9 +6,9 @@ module Rubocop
|
|
|
6
6
|
class InBatches < RuboCop::Cop::Base
|
|
7
7
|
MSG = 'Do not use `in_batches`, use `each_batch` from the EachBatch module instead'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
return unless node.children[1] == :in_batches
|
|
9
|
+
RESTRICT_ON_SEND = %i[in_batches].freeze
|
|
11
10
|
|
|
11
|
+
def on_send(node)
|
|
12
12
|
add_offense(node.loc.selector)
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
|
43
43
|
# end
|
|
44
44
|
class UseRestrictOnSend < Base
|
|
45
45
|
MSG = 'Define constant `RESTRICT_ON_SEND` to speed up calls to `on_send`. ' \
|
|
46
|
-
|
|
46
|
+
'The following line is then no longer necessary:'
|
|
47
47
|
|
|
48
48
|
# @!method method_name_plain(node)
|
|
49
49
|
def_node_matcher :method_name_plain, <<~PATTERN
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Layout
|
|
6
|
+
# Checks if there is an empty line after the last include/extend/prepend.
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# # bad
|
|
10
|
+
# class Hello
|
|
11
|
+
# include Something1
|
|
12
|
+
# include Something2
|
|
13
|
+
# def world
|
|
14
|
+
# end
|
|
15
|
+
# end
|
|
16
|
+
|
|
17
|
+
# # good
|
|
18
|
+
# class Hello
|
|
19
|
+
# include Something1
|
|
20
|
+
# include Something2
|
|
21
|
+
#
|
|
22
|
+
# def world
|
|
23
|
+
# end
|
|
24
|
+
# end
|
|
25
|
+
class LineBreakAfterFinalMixin < RuboCop::Cop::Base
|
|
26
|
+
extend RuboCop::Cop::AutoCorrector
|
|
27
|
+
|
|
28
|
+
MSG = 'Add an empty line after the last `%<mixin>s`.'
|
|
29
|
+
|
|
30
|
+
MIXIN_METHODS = %i[include extend prepend].to_set.freeze
|
|
31
|
+
|
|
32
|
+
# @!method mixin?(node)
|
|
33
|
+
def_node_matcher :mixin?, <<~PATTERN
|
|
34
|
+
(send {nil? | self} MIXIN_METHODS ...)
|
|
35
|
+
PATTERN
|
|
36
|
+
|
|
37
|
+
def on_class(node)
|
|
38
|
+
return unless node.body
|
|
39
|
+
|
|
40
|
+
mixins = node.body.child_nodes.select { |child| mixin?(child) }
|
|
41
|
+
|
|
42
|
+
return if mixins.empty?
|
|
43
|
+
|
|
44
|
+
last_mixin = mixins.last
|
|
45
|
+
|
|
46
|
+
return if next_line_valid?(last_mixin)
|
|
47
|
+
|
|
48
|
+
add_offense(last_mixin, message: format(MSG, mixin: last_mixin.method_name)) do |corrector|
|
|
49
|
+
corrector.insert_after(last_mixin, "\n")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def next_line_valid?(node)
|
|
56
|
+
next_line = next_line(node)
|
|
57
|
+
|
|
58
|
+
empty_line?(next_line) || end_line?(next_line)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def next_line(node)
|
|
62
|
+
processed_source[node.loc.line]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def empty_line?(line)
|
|
66
|
+
line.empty?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def end_line?(line)
|
|
70
|
+
/^\s*end\b/.match?(line)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -18,8 +18,8 @@ module Rubocop
|
|
|
18
18
|
include Gitlab::Styles::Rubocop::MigrationHelpers
|
|
19
19
|
|
|
20
20
|
MSG = 'Using `%s` on the `%s` table will take a long time to ' \
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
'complete, and should be avoided unless absolutely ' \
|
|
22
|
+
'necessary'
|
|
23
23
|
|
|
24
24
|
# @!method batch_update?(node)
|
|
25
25
|
def_node_matcher :batch_update?, <<~PATTERN
|
|
@@ -13,10 +13,10 @@ module Rubocop
|
|
|
13
13
|
# - https://github.com/rubyzip/rubyzip#notes-on-zipinputstream
|
|
14
14
|
class Rubyzip < RuboCop::Cop::Base
|
|
15
15
|
MSG = 'Be careful when opening or iterating zip files via Zip::File. ' \
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
'Zip archives may contain many entries, and their file index is ' \
|
|
17
|
+
'read into memory upon construction, which can lead to ' \
|
|
18
|
+
'high memory use and poor performance. ' \
|
|
19
|
+
'Consider iterating archive entries via Zip::InputStream instead.'
|
|
20
20
|
|
|
21
21
|
# @!method reads_central_directory?(node)
|
|
22
22
|
def_node_matcher :reads_central_directory?, <<-PATTERN
|
|
@@ -6,13 +6,16 @@ module Rubocop
|
|
|
6
6
|
class PolymorphicAssociations < RuboCop::Cop::Base
|
|
7
7
|
MSG = 'Do not use polymorphic associations, use separate tables instead'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
return unless node.children[1] == :belongs_to
|
|
9
|
+
RESTRICT_ON_SEND = %i[belongs_to].to_set.freeze
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
# @!method polymorphic_pair(node)
|
|
12
|
+
def_node_matcher :polymorphic_pair, <<~PATTERN
|
|
13
|
+
(send _ %RESTRICT_ON_SEND ... (hash <$(pair (sym :polymorphic) _) ...>))
|
|
14
|
+
PATTERN
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
def on_send(node)
|
|
17
|
+
polymorphic_pair(node) do |pair|
|
|
18
|
+
add_offense(pair)
|
|
16
19
|
end
|
|
17
20
|
end
|
|
18
21
|
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop-rspec'
|
|
4
|
+
require_relative 'base'
|
|
5
|
+
|
|
6
|
+
module Rubocop
|
|
7
|
+
module Cop
|
|
8
|
+
module RSpec
|
|
9
|
+
# Checks whether `specify` is used with `is_expected` and suggests the
|
|
10
|
+
# use of `it`.
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
#
|
|
14
|
+
# # bad
|
|
15
|
+
# specify { is_expected.to eq(true) }
|
|
16
|
+
#
|
|
17
|
+
# # good
|
|
18
|
+
# it { is_expected.to eq(true) }
|
|
19
|
+
#
|
|
20
|
+
class SpecifyExpected < Base
|
|
21
|
+
extend RuboCop::Cop::AutoCorrector
|
|
22
|
+
|
|
23
|
+
MSG = 'Prefer using `it` when used with `is_expected`.'
|
|
24
|
+
|
|
25
|
+
# @!method specify_with_expected?(node)
|
|
26
|
+
def_node_matcher :specify_with_expected?, <<~PATTERN
|
|
27
|
+
(block
|
|
28
|
+
(send nil? :specify ...)
|
|
29
|
+
_args
|
|
30
|
+
(send
|
|
31
|
+
(send nil? :is_expected)
|
|
32
|
+
...
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
PATTERN
|
|
36
|
+
|
|
37
|
+
RESTRICT_ON_SEND = %i[specify].freeze
|
|
38
|
+
|
|
39
|
+
def on_send(node)
|
|
40
|
+
return unless specify_with_expected?(node.parent)
|
|
41
|
+
|
|
42
|
+
add_offense(node) do |corrector|
|
|
43
|
+
corrector.replace(node, 'it')
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -12,8 +12,8 @@ module Rubocop
|
|
|
12
12
|
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67855
|
|
13
13
|
class OpenStructUse < RuboCop::Cop::Base
|
|
14
14
|
MSG = 'Avoid using `OpenStruct`. It is officially discouraged. ' \
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
'Replace it with `Struct`, `Hash`, or RSpec doubles. ' \
|
|
16
|
+
'See https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats'
|
|
17
17
|
|
|
18
18
|
# @!method uses_open_struct?(node)
|
|
19
19
|
def_node_matcher :uses_open_struct?, <<-PATTERN
|
|
@@ -6,9 +6,9 @@ module Rubocop
|
|
|
6
6
|
class WithoutReactiveCache < RuboCop::Cop::Base
|
|
7
7
|
MSG = 'without_reactive_cache is for debugging purposes only. Please use with_reactive_cache.'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
return unless node.children[1] == :without_reactive_cache
|
|
9
|
+
RESTRICT_ON_SEND = %i[without_reactive_cache].freeze
|
|
11
10
|
|
|
11
|
+
def on_send(node)
|
|
12
12
|
add_offense(node.loc.selector)
|
|
13
13
|
end
|
|
14
14
|
end
|
data/rubocop-all.yml
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
AllCops:
|
|
3
|
-
|
|
3
|
+
# The oldest supported Ruby version.
|
|
4
|
+
TargetRubyVersion: 3.0
|
|
4
5
|
# Cop names are not displayed in offense messages by default. Change behavior
|
|
5
6
|
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
|
|
6
7
|
# option.
|
data/rubocop-default.yml
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
require:
|
|
3
|
-
- rubocop-performance
|
|
4
|
-
- rubocop-rspec
|
|
5
|
-
- rubocop-rails
|
|
6
|
-
- rubocop-graphql
|
|
7
3
|
- ./lib/gitlab/styles/rubocop
|
|
8
4
|
|
|
9
5
|
inherit_from:
|
|
10
6
|
- rubocop-all.yml
|
|
11
|
-
- rubocop-
|
|
7
|
+
- rubocop-minimal.yml
|
|
12
8
|
- rubocop-capybara.yml
|
|
13
|
-
- rubocop-fips.yml
|
|
14
|
-
- rubocop-gemspec.yml
|
|
15
9
|
- rubocop-graphql.yml
|
|
16
10
|
- rubocop-internal-affairs.yml
|
|
17
|
-
- rubocop-layout.yml
|
|
18
|
-
- rubocop-lint.yml
|
|
19
|
-
- rubocop-metrics.yml
|
|
20
11
|
- rubocop-migrations.yml
|
|
21
|
-
- rubocop-naming.yml
|
|
22
|
-
- rubocop-performance.yml
|
|
23
12
|
- rubocop-rails.yml
|
|
24
|
-
- rubocop-rspec.yml
|
|
25
|
-
- rubocop-security.yml
|
|
26
|
-
- rubocop-style.yml
|
data/rubocop-gemspec.yml
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
---
|
|
2
|
+
# Checks that deprecated attributes are not set in a gemspec file. Removing
|
|
3
|
+
# deprecated attributes allows the user to receive smaller packed gems.
|
|
4
|
+
Gemspec/DeprecatedAttributeAssignment:
|
|
5
|
+
Enabled: true
|
|
6
|
+
|
|
7
|
+
# Enforce that development dependencies for a gem are specified in Gemfile,
|
|
8
|
+
# rather than in the gemspec using add_development_dependency
|
|
9
|
+
# Reason: Each project may decide to use a different strategy.
|
|
10
|
+
Gemspec/DevelopmentDependencies:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
2
13
|
# Dependencies in the gemspec should be alphabetically sorted
|
|
3
14
|
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
|
4
15
|
Gemspec/OrderedDependencies:
|
|
5
16
|
Include:
|
|
6
17
|
- '**/*.gemspec'
|
|
7
18
|
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
Gemspec/
|
|
19
|
+
# Requires a gemspec to have rubygems_mfa_required metadata set.
|
|
20
|
+
# Most gems are released via CI and MFA cannot be used with improved security.
|
|
21
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage/-/merge_requests/313#note_1605402392
|
|
22
|
+
Gemspec/RequireMFA:
|
|
12
23
|
Enabled: false
|
data/rubocop-graphql.yml
CHANGED
|
@@ -18,12 +18,38 @@ GraphQL/ExtractInputType:
|
|
|
18
18
|
|
|
19
19
|
# Suggests extracting fields with common prefixes to the separate type
|
|
20
20
|
GraphQL/ExtractType:
|
|
21
|
-
Enabled:
|
|
21
|
+
Enabled: true
|
|
22
|
+
|
|
23
|
+
# Enforce use of `graphql_name` in GrahQL types.
|
|
24
|
+
GraphQL/GraphqlName:
|
|
25
|
+
EnforcedStyle: required
|
|
22
26
|
|
|
23
27
|
# Checks that types are defined with class-based API
|
|
24
28
|
GraphQL/LegacyDsl:
|
|
25
29
|
Enabled: false
|
|
26
30
|
|
|
31
|
+
# Detects missing max_complexity configuration in schema files.
|
|
32
|
+
# Max complexity is defined in a different way.
|
|
33
|
+
# See https://gitlab.com/gitlab-org/gitlab/-/blob/9c0dfedd80ede7dbdcc92cf3f5b14bf36998e85c/app/graphql/gitlab_schema.rb#L41-44
|
|
34
|
+
GraphQL/MaxComplexitySchema:
|
|
35
|
+
Enabled: false
|
|
36
|
+
|
|
37
|
+
# Detects missing max_depth configuration in schema files.
|
|
38
|
+
# Max depth is defined in a different way.
|
|
39
|
+
# See https://gitlab.com/gitlab-org/gitlab/-/blob/9c0dfedd80ede7dbdcc92cf3f5b14bf36998e85c/app/graphql/gitlab_schema.rb#L41-45
|
|
40
|
+
GraphQL/MaxDepthSchema:
|
|
41
|
+
Enabled: false
|
|
42
|
+
|
|
43
|
+
# Detects types that implement Node interface and not have `.authorized?` check.
|
|
44
|
+
# `authorize` is used instead.
|
|
45
|
+
GraphQL/NotAuthorizedNodeType:
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
# Checks that GraphQL Argument definitions prepare arguments to allow better Sorbet typing.
|
|
49
|
+
# Sorbet is not (yet) used.
|
|
50
|
+
GraphQL/PrepareMethod:
|
|
51
|
+
Enabled: false
|
|
52
|
+
|
|
27
53
|
# Ensures all types have a description
|
|
28
54
|
# Disabled because our bespoke Graphql/Descriptions cop covers this.
|
|
29
55
|
GraphQL/ObjectDescription:
|
data/rubocop-layout.yml
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
+
require:
|
|
3
|
+
- ./lib/gitlab/styles/rubocop
|
|
4
|
+
|
|
2
5
|
# Check indentation of private/protected visibility modifiers.
|
|
3
6
|
Layout/AccessModifierIndentation:
|
|
4
7
|
Enabled: true
|
|
@@ -154,11 +157,9 @@ Layout/IndentationWidth:
|
|
|
154
157
|
Layout/LeadingCommentSpace:
|
|
155
158
|
Enabled: true
|
|
156
159
|
|
|
157
|
-
#
|
|
158
|
-
Layout/
|
|
160
|
+
# Checks if there is an empty line after the last include/extend/prepend.
|
|
161
|
+
Layout/LineBreakAfterFinalMixin:
|
|
159
162
|
Enabled: true
|
|
160
|
-
Max: 120
|
|
161
|
-
AllowedPatterns: ['\s#\srubocop']
|
|
162
163
|
|
|
163
164
|
# Checks that strings broken over multiple lines (by a backslash) contain
|
|
164
165
|
# trailing spaces instead of leading spaces (default) or leading spaces instead
|
|
@@ -171,6 +172,12 @@ Layout/LineContinuationLeadingSpace:
|
|
|
171
172
|
Layout/LineContinuationSpacing:
|
|
172
173
|
Enabled: true
|
|
173
174
|
|
|
175
|
+
# Limit lines to 120 characters.
|
|
176
|
+
Layout/LineLength:
|
|
177
|
+
Enabled: true
|
|
178
|
+
Max: 120
|
|
179
|
+
AllowedPatterns: ['\s#\srubocop']
|
|
180
|
+
|
|
174
181
|
# Checks that the closing brace in an array literal is either on the same line
|
|
175
182
|
# as the last array element, or a new line.
|
|
176
183
|
Layout/MultilineArrayBraceLayout:
|
|
@@ -185,6 +192,7 @@ Layout/MultilineBlockLayout:
|
|
|
185
192
|
# literal and a backslash.
|
|
186
193
|
Layout/LineEndStringConcatenationIndentation:
|
|
187
194
|
Enabled: true
|
|
195
|
+
EnforcedStyle: indented
|
|
188
196
|
|
|
189
197
|
# Checks that the closing brace in a hash literal is either on the same line as
|
|
190
198
|
# the last hash element, or a new line.
|
|
@@ -309,3 +317,7 @@ Layout/TrailingEmptyLines:
|
|
|
309
317
|
# Avoid trailing whitespace.
|
|
310
318
|
Layout/TrailingWhitespace:
|
|
311
319
|
Enabled: true
|
|
320
|
+
|
|
321
|
+
# checks if the code style follows the ExpectedOrder
|
|
322
|
+
Layout/ClassStructure:
|
|
323
|
+
Enabled: true
|
data/rubocop-minimal.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
# This are the cops that has no external dependency on Rails specific code
|
|
3
|
+
# or GitLab specific code
|
|
4
|
+
#
|
|
5
|
+
# It is intended to be used by any of our Ruby Gems that are plain ruby code only
|
|
6
|
+
inherit_from:
|
|
7
|
+
- rubocop-bundler.yml
|
|
8
|
+
- rubocop-fips.yml
|
|
9
|
+
- rubocop-gemspec.yml
|
|
10
|
+
- rubocop-layout.yml
|
|
11
|
+
- rubocop-lint.yml
|
|
12
|
+
- rubocop-metrics.yml
|
|
13
|
+
- rubocop-naming.yml
|
|
14
|
+
- rubocop-performance.yml
|
|
15
|
+
- rubocop-rspec.yml
|
|
16
|
+
- rubocop-security.yml
|
|
17
|
+
- rubocop-style.yml
|
data/rubocop-rails.yml
CHANGED
|
@@ -178,6 +178,11 @@ Rails/RenderInline:
|
|
|
178
178
|
Rails/RenderPlainText:
|
|
179
179
|
Enabled: true
|
|
180
180
|
|
|
181
|
+
# Checks for the usage of obsolete `require_dependency` method for Rails
|
|
182
|
+
# applications running in Zeitwerk mode.
|
|
183
|
+
Rails/RequireDependency:
|
|
184
|
+
Enabled: true
|
|
185
|
+
|
|
181
186
|
# Checks the arguments of ActiveRecord scopes.
|
|
182
187
|
Rails/ScopeArgs:
|
|
183
188
|
Enabled: true
|
data/rubocop-rspec.yml
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
require:
|
|
3
|
+
- rubocop-rspec
|
|
3
4
|
- ./lib/gitlab/styles/rubocop
|
|
4
5
|
|
|
5
|
-
# Check for create_list FactoryBot declarations higher than MaxAmount
|
|
6
|
-
RSpec/FactoryBot/ExcessiveCreateList:
|
|
7
|
-
Enabled: true
|
|
8
|
-
MaxAmount: 10
|
|
9
|
-
|
|
10
6
|
# Check that instances are not being stubbed globally.
|
|
11
7
|
RSpec/AnyInstance:
|
|
12
8
|
Enabled: false
|
|
@@ -83,6 +79,7 @@ RSpec/ExpectOutput:
|
|
|
83
79
|
Enabled: true
|
|
84
80
|
|
|
85
81
|
# Checks the file and folder naming of the spec file.
|
|
82
|
+
# Will be replaced with RSpec/SpecFilePathFormat and RSpec/SpecFilePathSuffix.
|
|
86
83
|
RSpec/FilePath:
|
|
87
84
|
Enabled: true
|
|
88
85
|
IgnoreMethods: true
|
|
@@ -137,7 +134,7 @@ RSpec/MultipleExpectations:
|
|
|
137
134
|
|
|
138
135
|
# Checks for explicitly referenced test subjects.
|
|
139
136
|
RSpec/NamedSubject:
|
|
140
|
-
Enabled:
|
|
137
|
+
Enabled: true
|
|
141
138
|
|
|
142
139
|
# Checks for nested example groups.
|
|
143
140
|
RSpec/NestedGroups:
|
|
@@ -163,6 +160,17 @@ RSpec/SingleLineHook:
|
|
|
163
160
|
- 'spec/factories/*'
|
|
164
161
|
- 'spec/requests/api/v3/*'
|
|
165
162
|
|
|
163
|
+
# Checks the file and folder naming of the spec file.
|
|
164
|
+
# Will replace RSpec/FilePath.
|
|
165
|
+
RSpec/SpecFilePathFormat:
|
|
166
|
+
Enabled: false
|
|
167
|
+
IgnoreMethods: true
|
|
168
|
+
|
|
169
|
+
# Checks the file and folder naming of the spec file.
|
|
170
|
+
# Will replace RSpec/FilePath.
|
|
171
|
+
RSpec/SpecFilePathSuffix:
|
|
172
|
+
Enabled: false
|
|
173
|
+
|
|
166
174
|
# Checks that message expectations do not have a configured response.
|
|
167
175
|
# https://docs.rubocop.org/rubocop-rspec/1.44/cops_rspec.html#rspecstubbedmock
|
|
168
176
|
RSpec/StubbedMock:
|
data/rubocop-style.yml
CHANGED
|
@@ -52,10 +52,14 @@ Style/BisectedAttrAccessor:
|
|
|
52
52
|
Style/BlockComments:
|
|
53
53
|
Enabled: true
|
|
54
54
|
|
|
55
|
-
# Avoid using {...} for multi-line blocks (
|
|
56
|
-
#
|
|
55
|
+
# Avoid using {...} for multi-line blocks (multi-line chaining is always ugly).
|
|
56
|
+
# Prefer {...} over do...end for single-line blocks.
|
|
57
57
|
Style/BlockDelimiters:
|
|
58
58
|
Enabled: true
|
|
59
|
+
# Do flag `it {` in multi-line blocks. Off by default.
|
|
60
|
+
AllowedMethods:
|
|
61
|
+
- proc
|
|
62
|
+
- lambda
|
|
59
63
|
|
|
60
64
|
# Checks for uses of the case equality operator(===).
|
|
61
65
|
Style/CaseEquality:
|
|
@@ -127,11 +131,10 @@ Style/EndBlock:
|
|
|
127
131
|
Style/EvenOdd:
|
|
128
132
|
Enabled: true
|
|
129
133
|
|
|
130
|
-
#
|
|
131
|
-
#
|
|
132
|
-
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleexplicitblockargument
|
|
134
|
+
# Reason: Using `yield` is ~20% faster than `&block`.
|
|
135
|
+
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/94090#note_1452639709
|
|
133
136
|
Style/ExplicitBlockArgument:
|
|
134
|
-
Enabled:
|
|
137
|
+
Enabled: false
|
|
135
138
|
|
|
136
139
|
# Enforces consistency when using exponential notation for numbers in the code
|
|
137
140
|
Style/ExponentialNotation:
|
|
@@ -308,6 +311,11 @@ Style/NumberedParametersLimit:
|
|
|
308
311
|
Style/NumericLiterals:
|
|
309
312
|
Enabled: false
|
|
310
313
|
|
|
314
|
+
|
|
315
|
+
# Enforces the use Object#then instead of Object#yield_self.
|
|
316
|
+
Style/ObjectThen:
|
|
317
|
+
Enabled: true
|
|
318
|
+
|
|
311
319
|
# Favor the ternary operator(?:) over if/then/else/end constructs.
|
|
312
320
|
Style/OneLineConditional:
|
|
313
321
|
Enabled: true
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitlab-styles
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 12.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GitLab
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -16,70 +16,84 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.
|
|
19
|
+
version: 1.62.1
|
|
20
20
|
type: :runtime
|
|
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: 1.
|
|
26
|
+
version: 1.62.1
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rubocop-factory_bot
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.25.1
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 2.25.1
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: rubocop-graphql
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
30
44
|
requirements:
|
|
31
45
|
- - "~>"
|
|
32
46
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
47
|
+
version: 1.5.0
|
|
34
48
|
type: :runtime
|
|
35
49
|
prerelease: false
|
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
51
|
requirements:
|
|
38
52
|
- - "~>"
|
|
39
53
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
54
|
+
version: 1.5.0
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: rubocop-performance
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
44
58
|
requirements:
|
|
45
59
|
- - "~>"
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
61
|
+
version: 1.20.2
|
|
48
62
|
type: :runtime
|
|
49
63
|
prerelease: false
|
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
65
|
requirements:
|
|
52
66
|
- - "~>"
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
68
|
+
version: 1.20.2
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rubocop-rails
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
58
72
|
requirements:
|
|
59
73
|
- - "~>"
|
|
60
74
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
75
|
+
version: 2.24.0
|
|
62
76
|
type: :runtime
|
|
63
77
|
prerelease: false
|
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
79
|
requirements:
|
|
66
80
|
- - "~>"
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
82
|
+
version: 2.24.0
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: rubocop-rspec
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
87
|
- - "~>"
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
89
|
+
version: 2.27.1
|
|
76
90
|
type: :runtime
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
94
|
- - "~>"
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
96
|
+
version: 2.27.1
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: bundler
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +114,14 @@ dependencies:
|
|
|
100
114
|
requirements:
|
|
101
115
|
- - "~>"
|
|
102
116
|
- !ruby/object:Gem::Version
|
|
103
|
-
version:
|
|
117
|
+
version: 4.6.0
|
|
104
118
|
type: :development
|
|
105
119
|
prerelease: false
|
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
121
|
requirements:
|
|
108
122
|
- - "~>"
|
|
109
123
|
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
124
|
+
version: 4.6.0
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: lefthook
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -248,7 +262,7 @@ dependencies:
|
|
|
248
262
|
- - "~>"
|
|
249
263
|
- !ruby/object:Gem::Version
|
|
250
264
|
version: 0.1.4
|
|
251
|
-
description:
|
|
265
|
+
description:
|
|
252
266
|
email:
|
|
253
267
|
- gitlab_rubygems@gitlab.com
|
|
254
268
|
executables: []
|
|
@@ -302,6 +316,7 @@ files:
|
|
|
302
316
|
- lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
|
|
303
317
|
- lib/rubocop/cop/internal_affairs/missing_cop_department.rb
|
|
304
318
|
- lib/rubocop/cop/internal_affairs/use_restrict_on_send.rb
|
|
319
|
+
- lib/rubocop/cop/layout/line_break_after_final_mixin.rb
|
|
305
320
|
- lib/rubocop/cop/line_break_after_guard_clauses.rb
|
|
306
321
|
- lib/rubocop/cop/line_break_around_conditional_block.rb
|
|
307
322
|
- lib/rubocop/cop/migration/update_large_table.rb
|
|
@@ -313,9 +328,9 @@ files:
|
|
|
313
328
|
- lib/rubocop/cop/rspec/empty_line_after_let_block.rb
|
|
314
329
|
- lib/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
|
315
330
|
- lib/rubocop/cop/rspec/example_starting_character.rb
|
|
316
|
-
- lib/rubocop/cop/rspec/factory_bot/excessive_create_list.rb
|
|
317
331
|
- lib/rubocop/cop/rspec/have_link_parameters.rb
|
|
318
332
|
- lib/rubocop/cop/rspec/single_line_hook.rb
|
|
333
|
+
- lib/rubocop/cop/rspec/specify_expected.rb
|
|
319
334
|
- lib/rubocop/cop/rspec/useless_dynamic_definition.rb
|
|
320
335
|
- lib/rubocop/cop/rspec/verbose_include_metadata.rb
|
|
321
336
|
- lib/rubocop/cop/style/hash_transformation.rb
|
|
@@ -326,6 +341,7 @@ files:
|
|
|
326
341
|
- rubocop-capybara.yml
|
|
327
342
|
- rubocop-code_reuse.yml
|
|
328
343
|
- rubocop-default.yml
|
|
344
|
+
- rubocop-factory_bot.yml
|
|
329
345
|
- rubocop-fips.yml
|
|
330
346
|
- rubocop-gemspec.yml
|
|
331
347
|
- rubocop-graphql.yml
|
|
@@ -334,6 +350,7 @@ files:
|
|
|
334
350
|
- rubocop-lint.yml
|
|
335
351
|
- rubocop-metrics.yml
|
|
336
352
|
- rubocop-migrations.yml
|
|
353
|
+
- rubocop-minimal.yml
|
|
337
354
|
- rubocop-naming.yml
|
|
338
355
|
- rubocop-performance.yml
|
|
339
356
|
- rubocop-rails.yml
|
|
@@ -344,7 +361,7 @@ homepage: https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles
|
|
|
344
361
|
licenses:
|
|
345
362
|
- MIT
|
|
346
363
|
metadata: {}
|
|
347
|
-
post_install_message:
|
|
364
|
+
post_install_message:
|
|
348
365
|
rdoc_options: []
|
|
349
366
|
require_paths:
|
|
350
367
|
- lib
|
|
@@ -352,15 +369,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
352
369
|
requirements:
|
|
353
370
|
- - ">="
|
|
354
371
|
- !ruby/object:Gem::Version
|
|
355
|
-
version: '
|
|
372
|
+
version: '3.0'
|
|
356
373
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
374
|
requirements:
|
|
358
375
|
- - ">="
|
|
359
376
|
- !ruby/object:Gem::Version
|
|
360
377
|
version: '0'
|
|
361
378
|
requirements: []
|
|
362
|
-
rubygems_version: 3.
|
|
363
|
-
signing_key:
|
|
379
|
+
rubygems_version: 3.3.27
|
|
380
|
+
signing_key:
|
|
364
381
|
specification_version: 4
|
|
365
382
|
summary: GitLab style guides and shared style configs.
|
|
366
383
|
test_files: []
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rubocop-rspec'
|
|
4
|
-
require_relative '../base'
|
|
5
|
-
|
|
6
|
-
module Rubocop
|
|
7
|
-
module Cop
|
|
8
|
-
module RSpec
|
|
9
|
-
module FactoryBot
|
|
10
|
-
# Check for create_list FactoryBot declarations higher than configured MaxAmount.
|
|
11
|
-
#
|
|
12
|
-
# @example MaxAmount: 20
|
|
13
|
-
# We do not allow more than 20 items to be created.
|
|
14
|
-
#
|
|
15
|
-
# # bad
|
|
16
|
-
# create_list(:merge_request, 1000, state: :opened)
|
|
17
|
-
#
|
|
18
|
-
# # good
|
|
19
|
-
# create_list(:merge_request, 15, state: :opened)
|
|
20
|
-
#
|
|
21
|
-
# @example
|
|
22
|
-
# We do not allow more than 10 items to be created (default)
|
|
23
|
-
# # bad
|
|
24
|
-
# create_list(:merge_request, 1000, state: :opened)
|
|
25
|
-
#
|
|
26
|
-
# # good
|
|
27
|
-
# create_list(:merge_request, 10, state: :opened)
|
|
28
|
-
#
|
|
29
|
-
class ExcessiveCreateList < Base
|
|
30
|
-
MESSAGE = 'Avoid using `create_list` with more than %{max_amount} items.'
|
|
31
|
-
|
|
32
|
-
# @!method create_list?(node)
|
|
33
|
-
def_node_matcher :create_list?, <<~PATTERN
|
|
34
|
-
(send nil? :create_list (sym ...) $(int _) ...)
|
|
35
|
-
PATTERN
|
|
36
|
-
|
|
37
|
-
RESTRICT_ON_SEND = %i[create_list].freeze
|
|
38
|
-
|
|
39
|
-
def on_send(node)
|
|
40
|
-
number_node = create_list?(node)
|
|
41
|
-
return unless number_node
|
|
42
|
-
|
|
43
|
-
max_amount = cop_config['MaxAmount']
|
|
44
|
-
return if number_node.value <= max_amount
|
|
45
|
-
|
|
46
|
-
add_offense(number_node, message: format(MESSAGE, max_amount: max_amount))
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|