gitlab-styles 6.2.0 → 6.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8de6943529f148b2e25546b043835e1d00cb06b4b9c88124457b9556830e7c29
4
- data.tar.gz: 44f5b72122c8626318a1914eec7e3e462eeab5c479393d2f526b6e4937123131
3
+ metadata.gz: 4f15e657637a0d30fed824f3d8312b970b9ee9bebc5a0feb603b83fa884b1705
4
+ data.tar.gz: fef3baec21ab04501f316d754a02aab77fb4dc816a048f87070d6d1b4a28f74c
5
5
  SHA512:
6
- metadata.gz: 35e146b2b436d9801ee242f8867662be1b3b9febe1f6b55eebf951fbe676dfdfffd93d3f0615928940a0b68bcc5e8ea049c23ac035a468db235f28464c32e648
7
- data.tar.gz: 9352b19250deedf7a716c576ab3f54b18e855dca95f5a18ed204bbe34ef7d395ed27a75e2dfe7ad00969552f28f474550053e8479e15c35487defe4f73bc9646
6
+ metadata.gz: 9954e550cf2ead877c73939a6f20893be5a584eb2c4f0850ea2cb5c8f4e976f3a20d3f910c0a39072c87e666cba51a8f5d283c56e33e2b2db76b1376f18cab7f
7
+ data.tar.gz: a54833e11f28072707ca11e21428820d888a8c95f89a5577e2633d324311400eca5d277b93311a405239397ca9ad3abac2a9982fcd5ace63f5a4491af970d513
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency 'rubocop', '~> 0.91', '>= 0.91.1'
26
26
  spec.add_dependency 'rubocop-gitlab-security', '~> 0.1.1'
27
+ spec.add_dependency 'rubocop-graphql', '~> 0.10'
27
28
  spec.add_dependency 'rubocop-performance', '~> 1.9.2'
28
29
  spec.add_dependency 'rubocop-rails', '~> 2.9'
29
30
  spec.add_dependency 'rubocop-rspec', '~> 1.44'
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../model_helpers'
4
+
5
+ module Gitlab
6
+ module Styles
7
+ module Rubocop
8
+ module Cop
9
+ module Rails
10
+ class IncludeUrlHelper < RuboCop::Cop::Cop
11
+ MSG = <<~MSG
12
+ Avoid including `ActionView::Helpers::UrlHelper`.
13
+ It adds/overrides ~40 methods while usually only one is needed.
14
+ Instead, use the `Gitlab::Routing.url_helpers`/`Application.routes.url_helpers`(outside of gitlab)
15
+ and `ActionController::Base.helpers.link_to`.
16
+ See https://gitlab.com/gitlab-org/gitlab/-/issues/340567.
17
+ MSG
18
+
19
+ def_node_matcher :include_url_helpers_node?, <<~PATTERN
20
+ (send nil? :include (const (const (const {nil? cbase} :ActionView) :Helpers) :UrlHelper))
21
+ PATTERN
22
+
23
+ def on_send(node)
24
+ add_offense(node) if include_url_helpers_node?(node)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module Styles
5
+ module Rubocop
6
+ module Cop
7
+ module Style
8
+ # This cop flags uses of OpenStruct, as it is now officially discouraged
9
+ # to be used for performance, version compatibility, and potential security issues.
10
+ #
11
+ # See also:
12
+ # - https://rubyreferences.github.io/rubychanges/3.0.html#standard-library
13
+ # - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
14
+ # - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67855
15
+ class OpenStructUse < RuboCop::Cop::Cop
16
+ MSG = 'Avoid using `OpenStruct`. It is officially discouraged. ' \
17
+ 'Replace it with `Struct`, `Hash`, or RSpec doubles. ' \
18
+ 'See https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats'
19
+
20
+ def_node_matcher :uses_open_struct?, <<-PATTERN
21
+ (const {nil? (cbase)} :OpenStruct)
22
+ PATTERN
23
+
24
+ def on_const(node)
25
+ return unless uses_open_struct?(node)
26
+ return if custom_class_or_module_definition?(node)
27
+
28
+ add_offense(node)
29
+ end
30
+
31
+ private
32
+
33
+ def custom_class_or_module_definition?(node)
34
+ parent = node.parent
35
+
36
+ (parent.class_type? || parent.module_type?) && node.left_siblings.empty?
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Styles
5
- VERSION = '6.2.0'
5
+ VERSION = '6.5.0'
6
6
  end
7
7
  end
@@ -1,3 +1,7 @@
1
+ ---
2
+ require:
3
+ - ./lib/gitlab/styles/rubocop
4
+
1
5
  # Denies the use of ActiveRecord methods outside of configured
2
6
  # excluded directories
3
7
  # Directories that allow the use of the denied methods.
data/rubocop-default.yml CHANGED
@@ -4,12 +4,14 @@ require:
4
4
  - rubocop-performance
5
5
  - rubocop-rspec
6
6
  - rubocop-rails
7
+ - rubocop-graphql
7
8
  - ./lib/gitlab/styles/rubocop
8
9
 
9
10
  inherit_from:
10
11
  - rubocop-all.yml
11
12
  - rubocop-bundler.yml
12
13
  - rubocop-gemspec.yml
14
+ - rubocop-graphql.yml
13
15
  - rubocop-layout.yml
14
16
  - rubocop-lint.yml
15
17
  - rubocop-metrics.yml
@@ -0,0 +1,30 @@
1
+ ---
2
+ require:
3
+ - rubocop-graphql
4
+
5
+ # Ensures all arguments have a description
6
+ # Disabled because our bespoke Graphql/Descriptions cop covers this.
7
+ GraphQL/ArgumentDescription:
8
+ Enabled: false
9
+
10
+ # Ensures all fields have a description
11
+ # Disabled because our bespoke Graphql/Descriptions cop covers this.
12
+ GraphQL/FieldDescription:
13
+ Enabled: false
14
+
15
+ # Suggests using input type instead of many arguments
16
+ GraphQL/ExtractInputType:
17
+ Enabled: false
18
+
19
+ # Suggests extracting fields with common prefixes to the separate type
20
+ GraphQL/ExtractType:
21
+ Enabled: false
22
+
23
+ # Checks that types are defined with class-based API
24
+ GraphQL/LegacyDsl:
25
+ Enabled: false
26
+
27
+ # Ensures all types have a description
28
+ # Disabled because our bespoke Graphql/Descriptions cop covers this.
29
+ GraphQL/ObjectDescription:
30
+ Enabled: false
@@ -1,4 +1,7 @@
1
1
  ---
2
+ require:
3
+ - ./lib/gitlab/styles/rubocop
4
+
2
5
  # Checks for methods that may lead to batch type issues on a table that's been
3
6
  # explicitly denied because of its size.
4
7
  #
@@ -1,4 +1,7 @@
1
1
  ---
2
+ require:
3
+ - rubocop-performance
4
+
2
5
  # Used to identify usages of ancestors.include? and change them to use ⇐ instead.
3
6
  # https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performanceancestorsinclude
4
7
  Performance/AncestorsInclude:
@@ -35,11 +38,9 @@ Performance/DoubleStartEndWith:
35
38
  Performance/MethodObjectAsBlock: # (new in 1.9)
36
39
  Enabled: true
37
40
 
38
- # Use `Struct.new(..., keyword_init: true)` instead of `OpenStruct.new(...)`.
41
+ # Superseded by Style/OpenStructUse
39
42
  Performance/OpenStruct:
40
- Enabled: true
41
- Exclude:
42
- - 'spec/**/*'
43
+ Enabled: false
43
44
 
44
45
  # Use `Range#cover?` instead of `Range#include?`.
45
46
  Performance/RangeInclude:
data/rubocop-rails.yml CHANGED
@@ -1,4 +1,8 @@
1
1
  ---
2
+ require:
3
+ - rubocop-rails
4
+ - ./lib/gitlab/styles/rubocop
5
+
2
6
  # Enables Rails cops.
3
7
  Rails:
4
8
  Enabled: true
@@ -183,3 +187,7 @@ Rails/WhereExists:
183
187
  # https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railswherenot
184
188
  Rails/WhereNot:
185
189
  Enabled: true
190
+
191
+ # Bans the use of `include ActionView::Helpers::UrlHelper`.
192
+ Rails/IncludeUrlHelper:
193
+ Enabled: true
data/rubocop-rspec.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  ---
2
+ require:
3
+ - ./lib/gitlab/styles/rubocop
4
+
2
5
  # Check that instances are not being stubbed globally.
3
6
  RSpec/AnyInstance:
4
7
  Enabled: false
data/rubocop-security.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  ---
2
+ require:
3
+ - rubocop-gitlab-security
4
+
2
5
  # This cop checks for the use of JSON class methods which have potential
3
6
  # security issues.
4
7
  Security/JSONLoad:
data/rubocop-style.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  ---
2
+ require:
3
+ - ./lib/gitlab/styles/rubocop
4
+
2
5
  # Checks for grouping of accessors in class and module bodies.
3
6
  # https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleaccessorgrouping
4
7
  Style/AccessorGrouping:
@@ -294,6 +297,10 @@ Style/NumericLiterals:
294
297
  Style/OneLineConditional:
295
298
  Enabled: true
296
299
 
300
+ # Do not use OpenStruct.
301
+ Style/OpenStructUse:
302
+ Enabled: true
303
+
297
304
  # Don't use parentheses around the condition of an if/unless/while.
298
305
  Style/ParenthesesAroundCondition:
299
306
  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: 6.2.0
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.1.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: rubocop-graphql
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.10'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.10'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: rubocop-performance
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +178,7 @@ files:
164
178
  - lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb
165
179
  - lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
166
180
  - lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
181
+ - lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb
167
182
  - lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
168
183
  - lib/gitlab/styles/rubocop/cop/rspec/base.rb
169
184
  - lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb
@@ -174,6 +189,7 @@ files:
174
189
  - lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb
175
190
  - lib/gitlab/styles/rubocop/cop/rspec/verbose_include_metadata.rb
176
191
  - lib/gitlab/styles/rubocop/cop/style/hash_transformation.rb
192
+ - lib/gitlab/styles/rubocop/cop/style/open_struct_use.rb
177
193
  - lib/gitlab/styles/rubocop/cop/without_reactive_cache.rb
178
194
  - lib/gitlab/styles/rubocop/migration_helpers.rb
179
195
  - lib/gitlab/styles/rubocop/model_helpers.rb
@@ -184,6 +200,7 @@ files:
184
200
  - rubocop-code_reuse.yml
185
201
  - rubocop-default.yml
186
202
  - rubocop-gemspec.yml
203
+ - rubocop-graphql.yml
187
204
  - rubocop-layout.yml
188
205
  - rubocop-lint.yml
189
206
  - rubocop-metrics.yml
@@ -213,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
230
  - !ruby/object:Gem::Version
214
231
  version: '0'
215
232
  requirements: []
216
- rubygems_version: 3.1.4
233
+ rubygems_version: 3.1.6
217
234
  signing_key:
218
235
  specification_version: 4
219
236
  summary: GitLab style guides and shared style configs.