gitlab-styles 14.1.0 → 15.0.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.
@@ -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 = '>= 3.1'
8
+ spec.required_ruby_version = '>= 3.3'
9
9
  spec.name = 'gitlab-styles'
10
10
  spec.version = Gitlab::Styles::VERSION
11
11
  spec.authors = ['GitLab']
@@ -16,31 +16,30 @@ Gem::Specification.new do |spec|
16
16
  spec.license = 'MIT'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(docs|test|spec|features|playground)/})
19
+ f.match(%r{^(docs|test|spec|features)/})
20
20
  end
21
21
  spec.bindir = 'exe'
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.81.7'
26
- spec.add_dependency 'rubocop-capybara', '2.21.0'
27
- spec.add_dependency 'rubocop-factory_bot', '2.26.1'
28
- spec.add_dependency 'rubocop-graphql', '1.5.4'
29
- spec.add_dependency 'rubocop-performance', '1.23.1'
30
- spec.add_dependency 'rubocop-rails', '2.29.1'
31
- spec.add_dependency 'rubocop-rspec', '3.4.0'
32
- spec.add_dependency 'rubocop-rspec_rails', '2.30.0'
25
+ spec.add_dependency 'rubocop', '1.92.1'
26
+ spec.add_dependency 'rubocop-capybara', '3.1.0'
27
+ spec.add_dependency 'rubocop-factory_bot', '2.28.0'
28
+ spec.add_dependency 'rubocop-graphql', '1.8.0'
29
+ spec.add_dependency 'rubocop-performance', '1.27.0'
30
+ spec.add_dependency 'rubocop-rails', '2.38.0'
31
+ spec.add_dependency 'rubocop-rspec', '3.10.2'
32
+ spec.add_dependency 'rubocop-rspec_rails', '2.33.0'
33
33
 
34
- spec.add_development_dependency 'bundler', '~> 2.1'
35
- spec.add_development_dependency 'gitlab-dangerfiles', '~> 4.6.0'
36
- spec.add_development_dependency 'lefthook', '~> 1.3.13'
37
- spec.add_development_dependency 'pry-byebug', '~> 3.10'
38
- spec.add_development_dependency 'rake', '~> 13.0'
39
- spec.add_development_dependency 'rspec', '~> 3.0'
40
- spec.add_development_dependency 'rspec-parameterized-table_syntax', '~> 1.0.0'
41
- spec.add_development_dependency 'rubocop-rake', '~> 0.6'
42
- spec.add_development_dependency 'simplecov', '~> 0.22.0'
43
- spec.add_development_dependency 'simplecov-cobertura', '~> 2.1.0'
44
- spec.add_development_dependency 'simplecov-html', '~> 0.12.3'
45
- spec.add_development_dependency 'test_file_finder', '~> 0.1.4'
34
+ spec.add_development_dependency 'bundler', '~> 4.0'
35
+ spec.add_development_dependency 'gitlab-dangerfiles', '~> 4.14.0'
36
+ spec.add_development_dependency 'lefthook', '~> 2.2'
37
+ spec.add_development_dependency 'pry-byebug', '~> 3.12'
38
+ spec.add_development_dependency 'rake', '~> 13.4'
39
+ spec.add_development_dependency 'rspec', '~> 3.13'
40
+ spec.add_development_dependency 'rspec-parameterized-table_syntax', '~> 2.1'
41
+ spec.add_development_dependency 'rubocop-rake', '~> 0.7'
42
+ spec.add_development_dependency 'simplecov', '~> 1.3'
43
+ spec.add_development_dependency 'simplecov-cobertura', '~> 4.0'
44
+ spec.add_development_dependency 'test_file_finder', '~> 0.3'
46
45
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-require the RSpec cops under `rubocop/cop/rspec/**/*.rb`. They need the rubocop-rspec plugin.
4
+ Dir[File.join(File.expand_path('../../../rubocop/cop/rspec', __dir__), '**', '*.rb')].each { |cop| require(cop) }
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Auto-require all cops under `rubocop/cop/**/*.rb`
4
- cops_glob = File.join(__dir__, '..', '..', 'rubocop', 'cop', '**', '*.rb')
5
- Dir[cops_glob].each { |cop| require(cop) }
3
+ # Auto-require all cops under `rubocop/cop/**/*.rb`, except the RSpec cops, which need rubocop-rspec.
4
+ # The rubocop-*.yml configs don't use this: each requires only the cops it configures, and
5
+ # `rubocop-rspec.yml` loads the RSpec cops through `gitlab/styles/rubocop/rspec`.
6
+ cops_dir = File.expand_path('../../rubocop/cop', __dir__)
7
+ rspec_cops_dir = File.join(cops_dir, 'rspec')
8
+ Dir[File.join(cops_dir, '**', '*.rb')].each { |cop| require(cop) unless cop.start_with?("#{rspec_cops_dir}/") }
6
9
 
7
10
  module Gitlab
8
11
  module Styles
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Styles
5
- VERSION = '14.1.0'
5
+ VERSION = '15.0.0'
6
6
  end
7
7
  end
@@ -39,6 +39,7 @@ module Rubocop
39
39
  end
40
40
 
41
41
  alias_method :on_numblock, :on_block
42
+ alias_method :on_itblock, :on_block
42
43
 
43
44
  private
44
45
 
@@ -47,7 +48,7 @@ module Rubocop
47
48
  top_block = nil
48
49
 
49
50
  while current_node && current_node.type != :def
50
- top_block = current_node if current_node.block_type?
51
+ top_block = current_node if current_node.any_block_type?
51
52
  current_node = current_node.parent
52
53
  end
53
54
 
@@ -58,7 +59,7 @@ module Rubocop
58
59
  blocks = []
59
60
 
60
61
  until node == current_node || def?(current_node)
61
- blocks << current_node if current_node.block_type?
62
+ blocks << current_node if current_node.any_block_type?
62
63
  current_node = current_node.parent
63
64
  end
64
65
 
@@ -67,7 +68,7 @@ module Rubocop
67
68
  end
68
69
 
69
70
  def def?(node)
70
- node.any_def_type? || (node.block_type? && DEF_METHODS.include?(node.method_name))
71
+ node.any_def_type? || (node.any_block_type? && DEF_METHODS.include?(node.method_name))
71
72
  end
72
73
 
73
74
  def allowed?(block_node)
@@ -6,6 +6,7 @@ module Rubocop
6
6
  module Cop
7
7
  module RSpec
8
8
  class Base < RuboCop::Cop::RSpec::Base # rubocop:disable InternalAffairs/CopDescriptionWithExample -- Base class
9
+ exclude_from_registry
9
10
  end
10
11
  end
11
12
  end
@@ -55,6 +55,7 @@ module Rubocop
55
55
  end
56
56
  end
57
57
  alias_method :on_numblock, :on_block
58
+ alias_method :on_itblock, :on_block
58
59
  end
59
60
  end
60
61
  end
@@ -46,9 +46,9 @@ module Rubocop
46
46
  # @!method shared_examples(node)
47
47
  def_node_matcher :shared_examples, <<~PATTERN
48
48
  {
49
- (block (send #rspec? #SharedGroups.all ...) ...)
49
+ (any_block (send #rspec? #SharedGroups.all ...) ...)
50
50
  {
51
- (block (send nil? #Includes.all ...) ...)
51
+ (any_block (send nil? #Includes.all ...) ...)
52
52
  (send nil? #Includes.all ...)
53
53
  }
54
54
  }
@@ -64,6 +64,7 @@ module Rubocop
64
64
  end
65
65
  end
66
66
  alias_method :on_numblock, :on_block
67
+ alias_method :on_itblock, :on_block
67
68
  end
68
69
  end
69
70
  end
@@ -54,7 +54,7 @@ module Rubocop
54
54
 
55
55
  # @!method it_description(node)
56
56
  def_node_matcher :it_description, <<-PATTERN
57
- (block (send _ :it ${
57
+ (any_block (send _ :it ${
58
58
  (str $_)
59
59
  (dstr (str $_ ) ...)
60
60
  } ...) ...)
@@ -66,6 +66,7 @@ module Rubocop
66
66
  end
67
67
  end
68
68
  alias_method :on_numblock, :on_block
69
+ alias_method :on_itblock, :on_block
69
70
 
70
71
  private
71
72
 
@@ -91,9 +92,7 @@ module Rubocop
91
92
  end
92
93
 
93
94
  def replacement_text(node)
94
- text = text(node)
95
-
96
- text.strip!
95
+ text = text(node).strip
97
96
 
98
97
  text = downcase_first_letter(text) if invalid_description?(text)
99
98
 
@@ -35,6 +35,7 @@ module Rubocop
35
35
  @example_count += 1 if example?(node)
36
36
  end
37
37
  alias_method :on_numblock, :on_block
38
+ alias_method :on_itblock, :on_block
38
39
 
39
40
  def on_investigation_end
40
41
  add_global_offense(format(MSG, count: @example_count, max: @max)) if @example_count > @max
@@ -37,6 +37,7 @@ module Rubocop
37
37
  add_offense(node, message: MESSAGE)
38
38
  end
39
39
  alias_method :on_numblock, :on_block
40
+ alias_method :on_itblock, :on_block
40
41
  end
41
42
  end
42
43
  end
data/rubocop-all.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  AllCops:
3
3
  # The oldest supported Ruby version.
4
- TargetRubyVersion: 3.1
4
+ TargetRubyVersion: 3.3
5
5
  # Cop names are not displayed in offense messages by default. Change behavior
6
6
  # by overriding DisplayCopNames, or by giving the -D/--display-cop-names
7
7
  # option.
data/rubocop-capybara.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-capybara
4
- - ./lib/gitlab/styles/rubocop
5
4
 
6
5
  # Checks if there is a more specific finder offered by Capybara.
7
6
  # https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/merge_requests/131#note_1141024624
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/code_reuse/active_record
4
4
 
5
5
  # Denies the use of ActiveRecord methods outside of configured
6
6
  # excluded directories
data/rubocop-default.yml CHANGED
@@ -1,7 +1,4 @@
1
1
  ---
2
- require:
3
- - ./lib/gitlab/styles/rubocop
4
-
5
2
  inherit_from:
6
3
  - rubocop-all.yml
7
4
  - rubocop-capybara.yml
@@ -1,7 +1,6 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-factory_bot
4
- - ./lib/gitlab/styles/rubocop
5
4
 
6
5
  # Check for create_list FactoryBot declarations higher than MaxAmount
7
6
  FactoryBot/ExcessiveCreateList:
data/rubocop-fips.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/fips/md5
4
+ - ./lib/rubocop/cop/fips/open_ssl
5
+ - ./lib/rubocop/cop/fips/sha1
4
6
 
5
7
  # Denies usage of MD5
6
8
  Fips/MD5:
data/rubocop-graphql.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-graphql
4
4
 
5
5
  # Ensures all arguments have a description
@@ -1,6 +1,9 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/internal_affairs/cop_description_with_example
4
+ - ./lib/rubocop/cop/internal_affairs/deprecate_cop_helper
5
+ - ./lib/rubocop/cop/internal_affairs/missing_cop_department
6
+ - ./lib/rubocop/cop/internal_affairs/use_restrict_on_send
4
7
 
5
8
  InternalAffairs/DeprecateCopHelper:
6
9
  Include:
data/rubocop-layout.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/layout/line_break_after_final_mixin
4
+ - ./lib/rubocop/cop/line_break_around_conditional_block
4
5
 
5
6
  # Check indentation of private/protected visibility modifiers.
6
7
  Layout/AccessModifierIndentation:
@@ -57,6 +58,10 @@ Layout/DotPosition:
57
58
  Layout/ElseAlignment:
58
59
  Enabled: true
59
60
 
61
+ # Add an empty line after guard clauses.
62
+ Layout/EmptyLineAfterGuardClause:
63
+ Enabled: true
64
+
60
65
  # Checks for a newline after the final magic comment.
61
66
  Layout/EmptyLineAfterMagicComment:
62
67
  Enabled: true
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/migration/update_large_table
4
4
 
5
5
  # Checks for methods that may lead to batch type issues on a table that's been
6
6
  # explicitly denied because of its size.
@@ -1,19 +1,14 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-performance
4
- - ./lib/gitlab/styles/rubocop
4
+ require:
5
+ - ./lib/rubocop/cop/performance/rubyzip
5
6
 
6
7
  # Used to identify usages of ancestors.include? and change them to use ⇐ instead.
7
8
  # https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performanceancestorsinclude
8
9
  Performance/AncestorsInclude:
9
10
  Enabled: true
10
11
 
11
- # Identifies places where numeric argument to BigDecimal should be converted to string.
12
- # Initializing from String is faster than from Numeric for BigDecimal.
13
- # https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancebigdecimalwithnumericargument
14
- Performance/BigDecimalWithNumericArgument:
15
- Enabled: true
16
-
17
12
  Performance/BlockGivenWithExplicitBlock: # (new in 1.9)
18
13
  Enabled: true
19
14
 
data/rubocop-rails.yml CHANGED
@@ -1,7 +1,13 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-rails
4
- - ./lib/gitlab/styles/rubocop
4
+ require:
5
+ - ./lib/rubocop/cop/active_record_dependent
6
+ - ./lib/rubocop/cop/active_record_serialize
7
+ - ./lib/rubocop/cop/in_batches
8
+ - ./lib/rubocop/cop/polymorphic_associations
9
+ - ./lib/rubocop/cop/redirect_with_status
10
+ - ./lib/rubocop/cop/rails/include_url_helper
5
11
 
6
12
  # Cop that prevents the use of `dependent: ...` in ActiveRecord models.
7
13
  Cop/ActiveRecordDependent:
data/rubocop-rspec.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-rspec
4
4
  - rubocop-rspec_rails
5
- - ./lib/gitlab/styles/rubocop
5
+ require:
6
+ - ./lib/gitlab/styles/rubocop/rspec
6
7
 
7
8
  # Check that instances are not being stubbed globally.
8
9
  RSpec/AnyInstance:
@@ -21,6 +22,22 @@ RSpec/BeforeAfterAll:
21
22
  RSpec/ClassCheck:
22
23
  Enabled: false
23
24
 
25
+ # Checks that `context` docstrings start with an allowed prefix. These are the
26
+ # most common prefixes in gitlab-org/gitlab:
27
+ # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92980
28
+ # Quote them all, because YAML reads unquoted `on` as `true`.
29
+ RSpec/ContextWording:
30
+ Prefixes:
31
+ - 'when'
32
+ - 'with'
33
+ - 'without'
34
+ - 'for'
35
+ - 'and'
36
+ - 'on'
37
+ - 'in'
38
+ - 'as'
39
+ - 'if'
40
+
24
41
  # Check that the first argument to the top level describe is the tested class or
25
42
  # module.
26
43
  RSpec/DescribeClass:
data/rubocop-security.yml CHANGED
@@ -1,6 +1,12 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/gitlab_security/deep_munge
4
+ - ./lib/rubocop/cop/gitlab_security/json_serialization
5
+ - ./lib/rubocop/cop/gitlab_security/public_send
6
+ - ./lib/rubocop/cop/gitlab_security/redirect_to_params_update
7
+ - ./lib/rubocop/cop/gitlab_security/send_file_params
8
+ - ./lib/rubocop/cop/gitlab_security/sql_injection
9
+ - ./lib/rubocop/cop/gitlab_security/system_command_injection
4
10
 
5
11
  # Checks for implementations of the hash method which combine values using
6
12
  # custom logic instead of delegating to Array#hash.
data/rubocop-style.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/avoid_return_from_blocks
4
+ - ./lib/rubocop/cop/custom_error_class
5
+ - ./lib/rubocop/cop/style/hash_transformation
6
+ - ./lib/rubocop/cop/style/iso8601_date
4
7
 
5
8
  # Checks for grouping of accessors in class and module bodies.
6
9
  # https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleaccessorgrouping
data/rubocop-tailwind.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  require:
3
- - ./lib/gitlab/styles/rubocop
3
+ - ./lib/rubocop/cop/tailwind/max_width_media_queries
4
+ - ./lib/rubocop/cop/tailwind/string_interpolation
4
5
 
5
6
  # Prevent string interpolation when building Tailwind CSS utils names
6
7
  Tailwind/StringInterpolation: