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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -3
- data/.rubocop.yml +2 -23
- data/.rubocop_todo.yml +1 -2
- data/Gemfile.lock +243 -132
- data/README.md +21 -10
- data/gitlab-styles.gemspec +21 -22
- data/lib/gitlab/styles/rubocop/rspec.rb +4 -0
- data/lib/gitlab/styles/rubocop.rb +6 -3
- data/lib/gitlab/styles/version.rb +1 -1
- data/lib/rubocop/cop/avoid_return_from_blocks.rb +4 -3
- data/lib/rubocop/cop/rspec/base.rb +1 -0
- data/lib/rubocop/cop/rspec/empty_line_after_let_block.rb +1 -0
- data/lib/rubocop/cop/rspec/empty_line_after_shared_example.rb +3 -2
- data/lib/rubocop/cop/rspec/example_starting_character.rb +3 -4
- data/lib/rubocop/cop/rspec/feature_spec_max_examples.rb +1 -0
- data/lib/rubocop/cop/rspec/single_line_hook.rb +1 -0
- data/rubocop-all.yml +1 -1
- data/rubocop-capybara.yml +1 -2
- data/rubocop-code_reuse.yml +1 -1
- data/rubocop-default.yml +0 -3
- data/rubocop-factory_bot.yml +1 -2
- data/rubocop-fips.yml +3 -1
- data/rubocop-graphql.yml +1 -1
- data/rubocop-internal-affairs.yml +4 -1
- data/rubocop-layout.yml +6 -1
- data/rubocop-migrations.yml +1 -1
- data/rubocop-performance.yml +3 -8
- data/rubocop-rails.yml +8 -2
- data/rubocop-rspec.yml +19 -2
- data/rubocop-security.yml +7 -1
- data/rubocop-style.yml +4 -1
- data/rubocop-tailwind.yml +2 -1
- metadata +42 -57
- data/lib/rubocop/cop/line_break_after_guard_clauses.rb +0 -99
- data/lib/rubocop/cop/style/open_struct_use.rb +0 -49
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 = '>= 3.
|
|
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
|
|
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.
|
|
26
|
-
spec.add_dependency 'rubocop-capybara', '
|
|
27
|
-
spec.add_dependency 'rubocop-factory_bot', '2.
|
|
28
|
-
spec.add_dependency 'rubocop-graphql', '1.
|
|
29
|
-
spec.add_dependency 'rubocop-performance', '1.
|
|
30
|
-
spec.add_dependency 'rubocop-rails', '2.
|
|
31
|
-
spec.add_dependency 'rubocop-rspec', '3.
|
|
32
|
-
spec.add_dependency 'rubocop-rspec_rails', '2.
|
|
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', '~>
|
|
35
|
-
spec.add_development_dependency 'gitlab-dangerfiles', '~> 4.
|
|
36
|
-
spec.add_development_dependency 'lefthook', '~>
|
|
37
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.
|
|
38
|
-
spec.add_development_dependency 'rake', '~> 13.
|
|
39
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
|
40
|
-
spec.add_development_dependency 'rspec-parameterized-table_syntax', '~> 1
|
|
41
|
-
spec.add_development_dependency 'rubocop-rake', '~> 0.
|
|
42
|
-
spec.add_development_dependency 'simplecov', '~>
|
|
43
|
-
spec.add_development_dependency 'simplecov-cobertura', '~>
|
|
44
|
-
spec.add_development_dependency '
|
|
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
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Auto-require all cops under `rubocop/cop/**/*.rb
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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)
|
|
@@ -46,9 +46,9 @@ module Rubocop
|
|
|
46
46
|
# @!method shared_examples(node)
|
|
47
47
|
def_node_matcher :shared_examples, <<~PATTERN
|
|
48
48
|
{
|
|
49
|
-
(
|
|
49
|
+
(any_block (send #rspec? #SharedGroups.all ...) ...)
|
|
50
50
|
{
|
|
51
|
-
(
|
|
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
|
-
(
|
|
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
|
data/rubocop-all.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
AllCops:
|
|
3
3
|
# The oldest supported Ruby version.
|
|
4
|
-
TargetRubyVersion: 3.
|
|
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
data/rubocop-code_reuse.yml
CHANGED
data/rubocop-default.yml
CHANGED
data/rubocop-factory_bot.yml
CHANGED
data/rubocop-fips.yml
CHANGED
data/rubocop-graphql.yml
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
require:
|
|
3
|
-
- ./lib/
|
|
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/
|
|
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
|
data/rubocop-migrations.yml
CHANGED
data/rubocop-performance.yml
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
plugins:
|
|
3
3
|
- rubocop-performance
|
|
4
|
-
|
|
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
|
-
|
|
2
|
+
plugins:
|
|
3
3
|
- rubocop-rails
|
|
4
|
-
|
|
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
|
-
|
|
2
|
+
plugins:
|
|
3
3
|
- rubocop-rspec
|
|
4
4
|
- rubocop-rspec_rails
|
|
5
|
-
|
|
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/
|
|
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/
|
|
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