gitlab-styles 9.2.0 → 10.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -3
  3. data/.gitlab/merge_request_templates/Release.md +18 -5
  4. data/.gitlab-ci.yml +17 -2
  5. data/.rubocop.yml +6 -1
  6. data/.rubocop_todo.yml +36 -0
  7. data/.tests_mapping.yml +10 -0
  8. data/Gemfile +0 -11
  9. data/Gemfile.lock +227 -0
  10. data/README.md +0 -1
  11. data/gitlab-styles.gemspec +15 -8
  12. data/lefthook.yml +11 -3
  13. data/lib/gitlab/styles/rubocop/migration_helpers.rb +1 -1
  14. data/lib/gitlab/styles/version.rb +1 -1
  15. data/lib/rubocop/cop/active_record_dependent.rb +0 -5
  16. data/lib/rubocop/cop/active_record_serialize.rb +0 -6
  17. data/lib/rubocop/cop/avoid_return_from_blocks.rb +4 -4
  18. data/lib/rubocop/cop/custom_error_class.rb +1 -1
  19. data/lib/rubocop/cop/gem_fetcher.rb +1 -1
  20. data/lib/rubocop/cop/gitlab_security/deep_munge.rb +36 -0
  21. data/lib/rubocop/cop/gitlab_security/json_serialization.rb +133 -0
  22. data/lib/rubocop/cop/gitlab_security/public_send.rb +47 -0
  23. data/lib/rubocop/cop/gitlab_security/redirect_to_params_update.rb +38 -0
  24. data/lib/rubocop/cop/gitlab_security/send_file_params.rb +40 -0
  25. data/lib/rubocop/cop/gitlab_security/sql_injection.rb +41 -0
  26. data/lib/rubocop/cop/gitlab_security/system_command_injection.rb +38 -0
  27. data/lib/rubocop/cop/in_batches.rb +0 -2
  28. data/lib/rubocop/cop/internal_affairs/missing_cop_department.rb +80 -0
  29. data/lib/rubocop/cop/internal_affairs/use_restrict_on_send.rb +99 -0
  30. data/lib/rubocop/cop/line_break_after_guard_clauses.rb +4 -6
  31. data/lib/rubocop/cop/line_break_around_conditional_block.rb +1 -1
  32. data/lib/rubocop/cop/migration/update_large_table.rb +1 -0
  33. data/lib/rubocop/cop/polymorphic_associations.rb +0 -5
  34. data/lib/rubocop/cop/rails/include_url_helper.rb +0 -2
  35. data/lib/rubocop/cop/redirect_with_status.rb +44 -30
  36. data/lib/rubocop/cop/rspec/empty_line_after_shared_example.rb +9 -2
  37. data/lib/rubocop/cop/rspec/example_starting_character.rb +1 -1
  38. data/lib/rubocop/cop/rspec/factory_bot/excessive_create_list.rb +52 -0
  39. data/lib/rubocop/cop/rspec/useless_dynamic_definition.rb +67 -0
  40. data/lib/rubocop/cop/rspec/verbose_include_metadata.rb +1 -1
  41. data/rubocop-capybara.yml +8 -0
  42. data/rubocop-default.yml +2 -4
  43. data/rubocop-gemspec.yml +6 -0
  44. data/rubocop-internal-affairs.yml +11 -0
  45. data/rubocop-layout.yml +2 -2
  46. data/rubocop-lint.yml +134 -5
  47. data/rubocop-naming.yml +5 -0
  48. data/rubocop-rails.yml +33 -1
  49. data/rubocop-rspec.yml +5 -5
  50. data/rubocop-security.yml +19 -1
  51. data/rubocop-style.yml +18 -3
  52. metadata +142 -29
  53. data/lib/gitlab/styles/rubocop/model_helpers.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e3e06ef1557da413f41116af9b5b01733a309e35bcd2717e8d8ec2473470589
4
- data.tar.gz: 704feb3fc08d96cde2a0cdadc8dbe5bbdde1bcb3b18a010f6b964462ec0f33aa
3
+ metadata.gz: 0cd204f5572b14a03cd4f6faec35d9973f07dcab0579cf17ebb5fc10d56ac6b0
4
+ data.tar.gz: 7a126190155bc1b39eea832c88e4636306f0fafb09f4b6c2c12c9fb275032a8c
5
5
  SHA512:
6
- metadata.gz: 1dcbe74347c735155eed09bfd24923dff24013454269d8edc7d5e62c4b35ebf7413958bd3b4cff55192bdc51f01dbdfdf438f853dfab322e20b96f6ed283142c
7
- data.tar.gz: 74ce09358878dd2deca30b2af8698eb46f3417b9f041794c00ee5e97bda90719548fb86250ef8718a7969c23361d256e7acf5669abaaaf6d60ed23eb5608e516
6
+ metadata.gz: ef80fd1223c28800de324bb2e71bc1c4e381137ddf7e4a4605e7d1e6e301cca3fc5cee69146a80fe23213a77c8c459d7037e305372242702d4cc8c9bb2b08c0b
7
+ data.tar.gz: 4f60365ef4232d584eb8ec18f99f8ac5537bd4bf933777d5125c4fb2f71423e7c487dd61f18e9e4e40738c4d02949d9291d7fda7a66fa88442bcdeb8854621c0
data/.gitignore CHANGED
@@ -1,7 +1,7 @@
1
+ /_yardoc/
1
2
  /.bundle/
3
+ /.byebug_history
2
4
  /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
5
  /coverage/
6
6
  /pkg/
7
7
  /spec/reports/
@@ -11,4 +11,4 @@
11
11
  .rspec_status
12
12
 
13
13
  # Ignore IDE specific files
14
- .idea/
14
+ .idea/
@@ -1,13 +1,26 @@
1
- <!-- Replace `<PREVIOUS_VERSION>` with the previous version number here, `<COMMIT_UPDATING_VERSION>` with the latest
1
+ <!-- Replace `<PREVIOUS_VERSION>` with the previous version number, `<COMMIT_UPDATING_VERSION>` with the latest
2
2
  commit from this merge request, and `<NEW_VERSION>` with the upcoming version number. -->
3
3
  ## Diff
4
4
 
5
- https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/compare/v<PREVIOUS_VERSION>...<COMMIT_UPDATING_VERSION>
5
+ https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/compare/v<PREVIOUS_VERSION>...<COMMIT_UPDATING_VERSION>
6
6
 
7
7
  ## Checklist
8
8
 
9
- - [ ] Diff link is up-to-date.
10
- - [ ] Check the release notes: https://gitlab.com/api/v4/projects/4176070/repository/changelog?version=<NEW_VERSION>
11
- - [ ] Based on the diff and the release notes, `version.rb` is updated, according to [SemVer](https://semver.org).
9
+ - [ ] Change the `VERSION` constant to a minor version in `lib/gitlab/styles/version.rb` (you might have to change the version number in the next steps according to [SemVer](https://semver.org)).
10
+ - [ ] Ensure the diff link above is up-to-date.
11
+ - [ ] Add release notes to the [Changelog](#changelog) section below.
12
+ - [ ] Based on the diff and the release notes, update the `version.rb` according to [SemVer](https://semver.org).
13
+ - [ ] Create an MR on `gitlab-org/gitlab` project [with the `New Version of gitlab-styles.md` template](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/merge_request_templates/New%20Version%20of%20gitlab-styles.md) to test the new version of `gitlab-styles`, and follow the MR instructions.
14
+
15
+ ## Changelog
16
+
17
+ <!--
18
+ Paste output of:
19
+
20
+ curl https://gitlab.com/api/v4/projects/4176070/repository/changelog?version=<NEW_VERSION> | jq -r ".notes"
21
+
22
+ NOTE: Skip `v` in `<NEW_VERSION>`. For example, Use `version=10.0.0` instead of `version=v10.0.0`.
23
+
24
+ -->
12
25
 
13
26
  /label ~"type::maintenance" ~"static code analysis"
data/.gitlab-ci.yml CHANGED
@@ -10,6 +10,9 @@ default:
10
10
  - bundle --version
11
11
  - bundle install
12
12
 
13
+ variables:
14
+ BUNDLE_FROZEN: 'true'
15
+
13
16
  workflow:
14
17
  rules:
15
18
  # For merge requests, create a pipeline.
@@ -25,15 +28,27 @@ styles:
25
28
  - bundle exec rubocop --debug --parallel
26
29
  parallel:
27
30
  matrix:
28
- - RUBY_VERSION: ['2.7', '3.0']
31
+ - RUBY_VERSION: ['2.7', '3.0', '3.1', '3.2']
29
32
 
30
33
  specs:
31
34
  stage: test
32
35
  script:
36
+ # Disable simplecov for all Ruby version other than 3.0
37
+ - if [[ "$RUBY_VERSION" != "3.0" ]]; then export SIMPLECOV=0; fi
33
38
  - bundle exec rspec
34
39
  parallel:
35
40
  matrix:
36
- - RUBY_VERSION: ['2.7', '3.0']
41
+ - RUBY_VERSION: ['2.7', '3.0', '3.1', '3.2']
42
+ artifacts:
43
+ name: coverage
44
+ expire_in: 31d
45
+ paths:
46
+ - coverage/index.html
47
+ - coverage/assets/
48
+ reports:
49
+ coverage_report:
50
+ coverage_format: cobertura
51
+ path: coverage/coverage.xml
37
52
 
38
53
  include:
39
54
  - project: 'gitlab-org/quality/pipeline-common'
data/.rubocop.yml CHANGED
@@ -1,12 +1,17 @@
1
1
  inherit_from:
2
2
  - rubocop-default.yml
3
+ - .rubocop_todo.yml
3
4
 
4
5
  require:
5
6
  - rubocop/cop/internal_affairs
7
+ - rubocop-rake
6
8
 
7
9
  AllCops:
8
10
  NewCops: disable # https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/40
9
- SuggestExtensions: false # https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/39
11
+
12
+ Gemspec/DevelopmentDependencies:
13
+ EnforcedStyle: gemspec
14
+ Enabled: true
10
15
 
11
16
  InternalAffairs/DeprecateCopHelper:
12
17
  Enabled: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,36 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2023-06-05 10:15:47 UTC using RuboCop version 1.50.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ InternalAffairs/InheritDeprecatedCopClass:
11
+ Exclude:
12
+ - 'lib/rubocop/cop/gitlab_security/json_serialization.rb'
13
+
14
+ # Offense count: 11
15
+ InternalAffairs/MissingCopDepartment:
16
+ Exclude:
17
+ - 'lib/rubocop/cop/active_record_dependent.rb'
18
+ - 'lib/rubocop/cop/active_record_serialize.rb'
19
+ - 'lib/rubocop/cop/avoid_return_from_blocks.rb'
20
+ - 'lib/rubocop/cop/custom_error_class.rb'
21
+ - 'lib/rubocop/cop/gem_fetcher.rb'
22
+ - 'lib/rubocop/cop/in_batches.rb'
23
+ - 'lib/rubocop/cop/line_break_after_guard_clauses.rb'
24
+ - 'lib/rubocop/cop/line_break_around_conditional_block.rb'
25
+ - 'lib/rubocop/cop/polymorphic_associations.rb'
26
+ - 'lib/rubocop/cop/redirect_with_status.rb'
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'
@@ -0,0 +1,10 @@
1
+ ---
2
+ mapping:
3
+ - source: 'lib/(.+)\.rb'
4
+ test: 'spec/%s_spec.rb'
5
+
6
+ - source: 'rubocop-.*\.yml'
7
+ test: 'spec/yml_spec.rb'
8
+
9
+ - source: '(spec/.*_spec\.rb)'
10
+ test: '%s'
data/Gemfile CHANGED
@@ -4,14 +4,3 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in gitlab-rubocop.gemspec
6
6
  gemspec
7
-
8
- group :development do
9
- gem "lefthook", require: false
10
- end
11
-
12
- group :test do
13
- # Pin these dependencies, otherwise a new rule could break the CI pipelines
14
- gem 'rubocop', '1.38.0'
15
- gem 'rubocop-rspec', '2.15.0'
16
- gem 'rspec-parameterized', '0.5.2', require: false
17
- end
data/Gemfile.lock ADDED
@@ -0,0 +1,227 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitlab-styles (10.1.0)
5
+ rubocop (~> 1.50.2)
6
+ rubocop-graphql (~> 0.18)
7
+ rubocop-performance (~> 1.15)
8
+ rubocop-rails (~> 2.17)
9
+ rubocop-rspec (~> 2.22)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (7.0.4.3)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ addressable (2.8.4)
20
+ public_suffix (>= 2.0.2, < 6.0)
21
+ ast (2.4.2)
22
+ binding_of_caller (1.0.0)
23
+ debug_inspector (>= 0.0.1)
24
+ byebug (11.1.3)
25
+ claide (1.1.0)
26
+ claide-plugins (0.9.2)
27
+ cork
28
+ nap
29
+ open4 (~> 1.3)
30
+ coderay (1.1.3)
31
+ colored2 (3.1.2)
32
+ concurrent-ruby (1.2.2)
33
+ cork (0.3.0)
34
+ colored2 (~> 3.1)
35
+ danger (9.3.0)
36
+ claide (~> 1.0)
37
+ claide-plugins (>= 0.9.2)
38
+ colored2 (~> 3.1)
39
+ cork (~> 0.1)
40
+ faraday (>= 0.9.0, < 3.0)
41
+ faraday-http-cache (~> 2.0)
42
+ git (~> 1.13.0)
43
+ kramdown (~> 2.3)
44
+ kramdown-parser-gfm (~> 1.0)
45
+ no_proxy_fix
46
+ octokit (~> 5.0)
47
+ terminal-table (>= 1, < 4)
48
+ danger-gitlab (8.0.0)
49
+ danger
50
+ gitlab (~> 4.2, >= 4.2.0)
51
+ debug_inspector (1.1.0)
52
+ diff-lcs (1.5.0)
53
+ docile (1.4.0)
54
+ faraday (1.10.3)
55
+ faraday-em_http (~> 1.0)
56
+ faraday-em_synchrony (~> 1.0)
57
+ faraday-excon (~> 1.1)
58
+ faraday-httpclient (~> 1.0)
59
+ faraday-multipart (~> 1.0)
60
+ faraday-net_http (~> 1.0)
61
+ faraday-net_http_persistent (~> 1.0)
62
+ faraday-patron (~> 1.0)
63
+ faraday-rack (~> 1.0)
64
+ faraday-retry (~> 1.0)
65
+ ruby2_keywords (>= 0.0.4)
66
+ faraday-em_http (1.0.0)
67
+ faraday-em_synchrony (1.0.0)
68
+ faraday-excon (1.1.0)
69
+ faraday-http-cache (2.5.0)
70
+ faraday (>= 0.8)
71
+ faraday-httpclient (1.0.1)
72
+ faraday-multipart (1.0.4)
73
+ multipart-post (~> 2)
74
+ faraday-net_http (1.0.1)
75
+ faraday-net_http_persistent (1.2.0)
76
+ faraday-patron (1.0.0)
77
+ faraday-rack (1.0.0)
78
+ faraday-retry (1.0.3)
79
+ git (1.13.2)
80
+ addressable (~> 2.8)
81
+ rchardet (~> 1.8)
82
+ gitlab (4.19.0)
83
+ httparty (~> 0.20)
84
+ terminal-table (>= 1.5.1)
85
+ gitlab-dangerfiles (3.6.7)
86
+ danger (>= 8.4.5)
87
+ danger-gitlab (>= 8.0.0)
88
+ rake
89
+ httparty (0.21.0)
90
+ mini_mime (>= 1.0.0)
91
+ multi_xml (>= 0.5.2)
92
+ i18n (1.13.0)
93
+ concurrent-ruby (~> 1.0)
94
+ json (2.6.3)
95
+ kramdown (2.4.0)
96
+ rexml
97
+ kramdown-parser-gfm (1.1.0)
98
+ kramdown (~> 2.0)
99
+ lefthook (1.3.13)
100
+ method_source (1.0.0)
101
+ mini_mime (1.1.2)
102
+ minitest (5.18.0)
103
+ multi_xml (0.6.0)
104
+ multipart-post (2.3.0)
105
+ nap (1.1.0)
106
+ no_proxy_fix (0.1.2)
107
+ octokit (5.6.1)
108
+ faraday (>= 1, < 3)
109
+ sawyer (~> 0.9)
110
+ open4 (1.3.4)
111
+ parallel (1.23.0)
112
+ parser (3.2.2.1)
113
+ ast (~> 2.4.1)
114
+ proc_to_ast (0.1.0)
115
+ coderay
116
+ parser
117
+ unparser
118
+ pry (0.14.2)
119
+ coderay (~> 1.1)
120
+ method_source (~> 1.0)
121
+ pry-byebug (3.10.1)
122
+ byebug (~> 11.0)
123
+ pry (>= 0.13, < 0.15)
124
+ public_suffix (5.0.1)
125
+ rack (3.0.7)
126
+ rainbow (3.1.1)
127
+ rake (13.0.6)
128
+ rchardet (1.8.0)
129
+ regexp_parser (2.8.0)
130
+ rexml (3.2.5)
131
+ rspec (3.12.0)
132
+ rspec-core (~> 3.12.0)
133
+ rspec-expectations (~> 3.12.0)
134
+ rspec-mocks (~> 3.12.0)
135
+ rspec-core (3.12.2)
136
+ rspec-support (~> 3.12.0)
137
+ rspec-expectations (3.12.3)
138
+ diff-lcs (>= 1.2.0, < 2.0)
139
+ rspec-support (~> 3.12.0)
140
+ rspec-mocks (3.12.5)
141
+ diff-lcs (>= 1.2.0, < 2.0)
142
+ rspec-support (~> 3.12.0)
143
+ rspec-parameterized-core (1.0.0)
144
+ parser
145
+ proc_to_ast
146
+ rspec (>= 2.13, < 4)
147
+ unparser
148
+ rspec-parameterized-table_syntax (1.0.0)
149
+ binding_of_caller
150
+ rspec-parameterized-core (< 2)
151
+ rspec-support (3.12.0)
152
+ rubocop (1.50.2)
153
+ json (~> 2.3)
154
+ parallel (~> 1.10)
155
+ parser (>= 3.2.0.0)
156
+ rainbow (>= 2.2.2, < 4.0)
157
+ regexp_parser (>= 1.8, < 3.0)
158
+ rexml (>= 3.2.5, < 4.0)
159
+ rubocop-ast (>= 1.28.0, < 2.0)
160
+ ruby-progressbar (~> 1.7)
161
+ unicode-display_width (>= 2.4.0, < 3.0)
162
+ rubocop-ast (1.28.1)
163
+ parser (>= 3.2.1.0)
164
+ rubocop-capybara (2.18.0)
165
+ rubocop (~> 1.41)
166
+ rubocop-factory_bot (2.23.0)
167
+ rubocop (~> 1.33)
168
+ rubocop-graphql (0.19.0)
169
+ rubocop (>= 0.87, < 2)
170
+ rubocop-performance (1.17.1)
171
+ rubocop (>= 1.7.0, < 2.0)
172
+ rubocop-ast (>= 0.4.0)
173
+ rubocop-rails (2.19.1)
174
+ activesupport (>= 4.2.0)
175
+ rack (>= 1.1)
176
+ rubocop (>= 1.33.0, < 2.0)
177
+ rubocop-rake (0.6.0)
178
+ rubocop (~> 1.0)
179
+ rubocop-rspec (2.22.0)
180
+ rubocop (~> 1.33)
181
+ rubocop-capybara (~> 2.17)
182
+ rubocop-factory_bot (~> 2.22)
183
+ ruby-progressbar (1.13.0)
184
+ ruby2_keywords (0.0.5)
185
+ sawyer (0.9.2)
186
+ addressable (>= 2.3.5)
187
+ faraday (>= 0.17.3, < 3)
188
+ simplecov (0.22.0)
189
+ docile (~> 1.1)
190
+ simplecov-html (~> 0.11)
191
+ simplecov_json_formatter (~> 0.1)
192
+ simplecov-cobertura (2.1.0)
193
+ rexml
194
+ simplecov (~> 0.19)
195
+ simplecov-html (0.12.3)
196
+ simplecov_json_formatter (0.1.4)
197
+ terminal-table (3.0.2)
198
+ unicode-display_width (>= 1.1.1, < 3)
199
+ test_file_finder (0.1.4)
200
+ faraday (~> 1.0)
201
+ tzinfo (2.0.6)
202
+ concurrent-ruby (~> 1.0)
203
+ unicode-display_width (2.4.2)
204
+ unparser (0.6.7)
205
+ diff-lcs (~> 1.3)
206
+ parser (>= 3.2.0)
207
+
208
+ PLATFORMS
209
+ ruby
210
+
211
+ DEPENDENCIES
212
+ bundler (~> 2.1)
213
+ gitlab-dangerfiles (~> 3.6.7)
214
+ gitlab-styles!
215
+ lefthook (~> 1.3.13)
216
+ pry-byebug (~> 3.10)
217
+ rake (~> 13.0)
218
+ rspec (~> 3.0)
219
+ rspec-parameterized-table_syntax (~> 1.0.0)
220
+ rubocop-rake (~> 0.6)
221
+ simplecov (~> 0.22.0)
222
+ simplecov-cobertura (~> 2.1.0)
223
+ simplecov-html (~> 0.12.3)
224
+ test_file_finder (~> 0.1.4)
225
+
226
+ BUNDLED WITH
227
+ 2.4.13
data/README.md CHANGED
@@ -91,7 +91,6 @@ 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. (Optional, but appreciated) Create an MR on `gitlab-org/gitlab` project [with the `New Version of gitlab-styles.md` template](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/merge_request_templates/New%20Version%20of%20gitlab-styles.md) to test the new version of `gitlab-styles`, and follow the MR instructions.
95
94
  1. After the Merge Request has been merged, a new gem version is [published automatically](https://gitlab.com/gitlab-org/quality/pipeline-common/-/blob/master/ci/gem-release.yml)
96
95
 
97
96
  See [!123](https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/merge_requests/123) as an example.
@@ -22,15 +22,22 @@ 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.38.0'
26
- spec.add_dependency 'rubocop-gitlab-security', '~> 0.1.1'
27
- spec.add_dependency 'rubocop-graphql', '~> 0.14'
28
- spec.add_dependency 'rubocop-performance', '~> 1.14'
29
- spec.add_dependency 'rubocop-rails', '~> 2.15'
30
- spec.add_dependency 'rubocop-rspec', '~> 2.15'
25
+ spec.add_dependency 'rubocop', '~> 1.50.2'
26
+ spec.add_dependency 'rubocop-graphql', '~> 0.18'
27
+ spec.add_dependency 'rubocop-performance', '~> 1.15'
28
+ spec.add_dependency 'rubocop-rails', '~> 2.17'
29
+ spec.add_dependency 'rubocop-rspec', '~> 2.22'
31
30
 
32
31
  spec.add_development_dependency 'bundler', '~> 2.1'
33
- spec.add_development_dependency 'gitlab-dangerfiles', '~> 2.11.0'
34
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'gitlab-dangerfiles', '~> 3.6.7'
33
+ spec.add_development_dependency 'lefthook', '~> 1.3.13'
34
+ spec.add_development_dependency 'pry-byebug', '~> 3.10'
35
+ spec.add_development_dependency 'rake', '~> 13.0'
35
36
  spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rspec-parameterized-table_syntax', '~> 1.0.0'
38
+ spec.add_development_dependency 'rubocop-rake', '~> 0.6'
39
+ spec.add_development_dependency 'simplecov', '~> 0.22.0'
40
+ spec.add_development_dependency 'simplecov-cobertura', '~> 2.1.0'
41
+ spec.add_development_dependency 'simplecov-html', '~> 0.12.3'
42
+ spec.add_development_dependency 'test_file_finder', '~> 0.1.4'
36
43
  end
data/lefthook.yml CHANGED
@@ -10,7 +10,15 @@ pre-push:
10
10
  glob: '*.{rb,rake}'
11
11
  run: bundle exec rubocop --parallel --force-exclusion {files}
12
12
 
13
- # Run all tests (warn if there are any missing tools required for tests).
13
+ # Run only relevant specs.
14
14
  rspec:
15
- run: bundle exec rspec -f progress
16
- glob: '*.rb'
15
+ files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
16
+ run: |
17
+ tests=$(tff --mapping-file .tests_mapping.yml {files})
18
+ if [ "$tests" != "" ]; then
19
+ echo "bundle exec rspec --format progress $tests"
20
+ bundle exec rspec --format progress $tests
21
+ else
22
+ echo "No specs to run."
23
+ exit 0
24
+ fi
@@ -7,7 +7,7 @@ module Gitlab
7
7
  module MigrationHelpers
8
8
  # Returns true if the given node originated from the db/migrate directory.
9
9
  def in_migration?(node)
10
- dirname = File.dirname(node.location.expression.source_buffer.name)
10
+ dirname = File.dirname(node.source_range.source_buffer.name)
11
11
 
12
12
  dirname.end_with?(
13
13
  'db/migrate',
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Styles
5
- VERSION = '9.2.0'
5
+ VERSION = '10.1.0'
6
6
  end
7
7
  end
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../gitlab/styles/rubocop/model_helpers'
4
-
5
3
  module Rubocop
6
4
  module Cop
7
5
  # Cop that prevents the use of `dependent: ...` in ActiveRecord models.
8
6
  class ActiveRecordDependent < RuboCop::Cop::Base
9
- include Gitlab::Styles::Rubocop::ModelHelpers
10
-
11
7
  MSG = 'Do not use `dependent:` to remove associated data, ' \
12
8
  'use foreign keys with cascading deletes instead.'
13
9
 
@@ -15,7 +11,6 @@ module Rubocop
15
11
  ALLOWED_OPTIONS = [:restrict_with_error].freeze
16
12
 
17
13
  def on_send(node)
18
- return unless in_model?(node)
19
14
  return unless METHOD_NAMES.include?(node.children[1])
20
15
 
21
16
  node.children.last.each_node(:pair) do |pair|
@@ -1,18 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../gitlab/styles/rubocop/model_helpers'
4
-
5
3
  module Rubocop
6
4
  module Cop
7
5
  # Cop that prevents the use of `serialize` in ActiveRecord models.
8
6
  class ActiveRecordSerialize < RuboCop::Cop::Base
9
- include Gitlab::Styles::Rubocop::ModelHelpers
10
-
11
7
  MSG = 'Do not store serialized data in the database, use separate columns and/or tables instead'
12
8
 
13
9
  def on_send(node)
14
- return unless in_model?(node)
15
-
16
10
  add_offense(node.loc.selector) if node.children[1] == :serialize
17
11
  end
18
12
  end
@@ -23,7 +23,7 @@ module Rubocop
23
23
  class AvoidReturnFromBlocks < RuboCop::Cop::Base
24
24
  MSG = 'Do not return from a block, use next or break instead.'
25
25
  DEF_METHODS = %i[define_method lambda].freeze
26
- WHITELISTED_METHODS = %i[each each_filename times loop].freeze
26
+ ALLOWED_METHODS = %i[each each_filename times loop].freeze
27
27
 
28
28
  def on_block(node)
29
29
  block_body = node.body
@@ -32,7 +32,7 @@ module Rubocop
32
32
  return unless top_block?(node)
33
33
 
34
34
  block_body.each_node(:return) do |return_node|
35
- next if parent_blocks(node, return_node).all? { |block| whitelisted?(block) }
35
+ next if parent_blocks(node, return_node).all? { |block| allowed?(block) }
36
36
 
37
37
  add_offense(return_node)
38
38
  end
@@ -71,8 +71,8 @@ module Rubocop
71
71
  (node.block_type? && DEF_METHODS.include?(node.method_name))
72
72
  end
73
73
 
74
- def whitelisted?(block_node)
75
- WHITELISTED_METHODS.include?(block_node.method_name)
74
+ def allowed?(block_node)
75
+ ALLOWED_METHODS.include?(block_node.method_name)
76
76
  end
77
77
  end
78
78
  end
@@ -36,7 +36,7 @@ module Rubocop
36
36
 
37
37
  replacement = "#{class_name_from_node(klass)} = Class.new(#{class_name_from_node(parent)})"
38
38
 
39
- corrector.replace(node.source_range, replacement)
39
+ corrector.replace(node, replacement)
40
40
  end
41
41
  end
42
42
 
@@ -14,7 +14,7 @@ module Rubocop
14
14
 
15
15
  # @!method gem_option(node)
16
16
  def_node_matcher :gem_option, <<~PATTERN
17
- (send nil? :gem _
17
+ (send nil? :gem _ ...
18
18
  (hash
19
19
  <$(pair (sym {#{GIT_SOURCES.map(&:inspect).join(' ')}}) _)
20
20
  ...>
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module GitlabSecurity
6
+ # Checks for disabling the deep munge security control.
7
+ #
8
+ # Disabling this security setting can leave the application open to unsafe
9
+ # query generation
10
+ #
11
+ # @example
12
+ #
13
+ # # bad
14
+ # config.action_dispatch.perform_deep_munge = false
15
+ #
16
+ # See CVE-2012-2660, CVE-2012-2694, and CVE-2013-0155.
17
+ class DeepMunge < RuboCop::Cop::Base
18
+ MSG = 'Never disable the deep munge security option.'
19
+
20
+ # @!method disable_deep_munge?(node)
21
+ def_node_matcher :disable_deep_munge?, <<-PATTERN
22
+ (send
23
+ (send (send nil? :config) :action_dispatch) :perform_deep_munge=
24
+ { (false) (send true :!) }
25
+ )
26
+ PATTERN
27
+
28
+ def on_send(node)
29
+ return unless disable_deep_munge?(node)
30
+
31
+ add_offense(node.loc.selector)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end