gitlab-styles 14.0.0 → 14.1.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/.rubocop_todo.yml +1 -9
- data/Gemfile.lock +1 -1
- data/lib/gitlab/styles/version.rb +1 -1
- data/lib/rubocop/cop/gitlab_security/deep_munge.rb +10 -0
- data/lib/rubocop/cop/internal_affairs/use_restrict_on_send.rb +17 -16
- data/lib/rubocop/cop/line_break_around_conditional_block.rb +30 -30
- data/lib/rubocop/cop/migration/update_large_table.rb +24 -1
- data/lib/rubocop/cop/rspec/feature_spec_max_examples.rb +45 -0
- data/rubocop-rspec.yml +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97c5d02f5527dfe3cfecf408460d9613ca6b2d820d21ebd95d39dbc79f3b94b8
|
|
4
|
+
data.tar.gz: 92ade99f8c31fa1617d47c80a575fe572d67a03f113c2aff9417932bca74b305
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d189c88f35cf67f0c211f40a27cd2bcac2b6964e0719279bcb4ae28601c98381150752332a0f894aedd1c7e0a57a3160ca44cc1877629594fa1eea737668e36
|
|
7
|
+
data.tar.gz: 30b2281cdb5ec7b966065ed926cdacbbcd7bdd9de66b85be0e7eb1758057759add13080e7a7c4c0c63ba5f2603c6ad8f863e8b7ccc44e412bb40bd2e0fc27ccf
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config --exclude-limit 10000`
|
|
3
|
-
# on
|
|
3
|
+
# on 2026-01-26 16:12:08 UTC using RuboCop version 1.81.7.
|
|
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
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count: 3
|
|
10
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
-
InternalAffairs/CopDescriptionWithExample:
|
|
12
|
-
Exclude:
|
|
13
|
-
- 'lib/rubocop/cop/gitlab_security/deep_munge.rb'
|
|
14
|
-
- 'lib/rubocop/cop/line_break_around_conditional_block.rb'
|
|
15
|
-
- 'lib/rubocop/cop/migration/update_large_table.rb'
|
|
16
|
-
|
|
17
9
|
# Offense count: 10
|
|
18
10
|
InternalAffairs/MissingCopDepartment:
|
|
19
11
|
Exclude:
|
data/Gemfile.lock
CHANGED
|
@@ -13,7 +13,17 @@ module RuboCop
|
|
|
13
13
|
# # bad
|
|
14
14
|
# config.action_dispatch.perform_deep_munge = false
|
|
15
15
|
#
|
|
16
|
+
# # bad
|
|
17
|
+
# config.action_dispatch.perform_deep_munge = !true
|
|
18
|
+
#
|
|
19
|
+
# # good
|
|
20
|
+
# config.action_dispatch.perform_deep_munge = true
|
|
21
|
+
#
|
|
22
|
+
# # good
|
|
23
|
+
# # Deep munge is not explicitly disabled
|
|
24
|
+
#
|
|
16
25
|
# See CVE-2012-2660, CVE-2012-2694, and CVE-2013-0155.
|
|
26
|
+
|
|
17
27
|
class DeepMunge < RuboCop::Cop::Base
|
|
18
28
|
MSG = 'Never disable the deep munge security option.'
|
|
19
29
|
|
|
@@ -45,37 +45,35 @@ module RuboCop
|
|
|
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
|
-
# @!method method_name_plain(node)
|
|
48
|
+
# @!method method_name_plain(node, send_param)
|
|
49
49
|
def_node_matcher :method_name_plain, <<~PATTERN
|
|
50
50
|
{
|
|
51
|
-
(send _ :method_name
|
|
52
|
-
(send
|
|
53
|
-
(send _ :children) :[] (int 1) # node.children[1]
|
|
54
|
-
)
|
|
51
|
+
(send _ :method_name (lvar %1) ...) # method_name(on_send_param)
|
|
52
|
+
(send (send (lvar %1) :children) :[] (int 1)) # on_send_param.children[1]
|
|
55
53
|
}
|
|
56
54
|
PATTERN
|
|
57
55
|
|
|
58
|
-
# @!method method_name_call(node)
|
|
56
|
+
# @!method method_name_call(node, send_param, local_assignments)
|
|
59
57
|
def_node_matcher :method_name_call, <<~PATTERN
|
|
60
58
|
{
|
|
61
|
-
#method_name_plain
|
|
62
|
-
(lvar %
|
|
59
|
+
#method_name_plain(%1) # direct method_name/children[1] call on the on_send param
|
|
60
|
+
(lvar %2) # local variable previously assigned from such a call
|
|
63
61
|
}
|
|
64
62
|
PATTERN
|
|
65
63
|
|
|
66
|
-
# @!method method_name_assignment(node)
|
|
64
|
+
# @!method method_name_assignment(node, send_param)
|
|
67
65
|
def_node_search :method_name_assignment, <<~PATTERN
|
|
68
|
-
(lvasgn $
|
|
66
|
+
(lvasgn $_ #method_name_plain(%1))
|
|
69
67
|
PATTERN
|
|
70
68
|
|
|
71
|
-
# @!method method_name_check(node)
|
|
69
|
+
# @!method method_name_check(node, send_param, local_assignments)
|
|
72
70
|
def_node_search :method_name_check, <<~PATTERN
|
|
73
71
|
(if
|
|
74
72
|
${
|
|
75
|
-
(send #method_name_call(%1) {:== :!=} _) # method_name(
|
|
76
|
-
(send _ :include? #method_name_call(%1)) # a.include?(method_name(
|
|
73
|
+
(send #method_name_call(%1, %2) {:== :!=} _) # method_name(on_send_param) == foo
|
|
74
|
+
(send _ :include? #method_name_call(%1, %2)) # a.include?(method_name(on_send_param))
|
|
77
75
|
}
|
|
78
|
-
{!nil? nil? | nil? !nil?}
|
|
76
|
+
{!nil? nil? | nil? !nil?} # has either `if` or `else` branch - not both
|
|
79
77
|
)
|
|
80
78
|
PATTERN
|
|
81
79
|
|
|
@@ -83,9 +81,12 @@ module RuboCop
|
|
|
83
81
|
return unless node.method?(:on_send)
|
|
84
82
|
return if @restrict_on_send_set
|
|
85
83
|
|
|
86
|
-
|
|
84
|
+
send_param = node.first_argument&.name
|
|
85
|
+
return unless send_param
|
|
87
86
|
|
|
88
|
-
|
|
87
|
+
local_assignments = method_name_assignment(node, send_param).to_set
|
|
88
|
+
|
|
89
|
+
method_name_check(node, send_param, local_assignments) do |call_node|
|
|
89
90
|
add_offense(call_node)
|
|
90
91
|
end
|
|
91
92
|
end
|
|
@@ -5,43 +5,43 @@ module Rubocop
|
|
|
5
5
|
# Ensures a line break around conditional blocks.
|
|
6
6
|
#
|
|
7
7
|
# @example
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
8
|
+
# # bad
|
|
9
|
+
# do_something
|
|
10
|
+
# if condition
|
|
11
|
+
# do_extra_stuff
|
|
12
|
+
# end
|
|
13
|
+
# do_something_more
|
|
14
14
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
15
|
+
# # good
|
|
16
|
+
# do_something
|
|
17
17
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
18
|
+
# if condition
|
|
19
|
+
# do_extra_stuff
|
|
20
|
+
# end
|
|
21
21
|
#
|
|
22
|
-
#
|
|
22
|
+
# do_something_more
|
|
23
23
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
24
|
+
# # bad
|
|
25
|
+
# do_something
|
|
26
|
+
# unless condition
|
|
27
|
+
# do_extra_stuff
|
|
28
|
+
# end
|
|
29
29
|
#
|
|
30
|
-
#
|
|
30
|
+
# do_something_more
|
|
31
31
|
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
32
|
+
# # good
|
|
33
|
+
# def a_method
|
|
34
|
+
# if condition
|
|
35
|
+
# do_something
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
38
38
|
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
39
|
+
# # good
|
|
40
|
+
# on_block do
|
|
41
|
+
# if condition
|
|
42
|
+
# do_something
|
|
43
|
+
# end
|
|
44
|
+
# end
|
|
45
45
|
class LineBreakAroundConditionalBlock < RuboCop::Cop::Base
|
|
46
46
|
extend RuboCop::Cop::AutoCorrector
|
|
47
47
|
include RuboCop::Cop::RangeHelp
|
|
@@ -8,10 +8,33 @@ module Rubocop
|
|
|
8
8
|
# Checks for methods that may lead to batch type issues on a table that's been
|
|
9
9
|
# explicitly denied because of its size.
|
|
10
10
|
#
|
|
11
|
-
# Even though
|
|
11
|
+
# Even though these methods perform functions to avoid
|
|
12
12
|
# downtime, using it with tables with millions of rows still causes a
|
|
13
13
|
# significant delay in the deploy process and is best avoided.
|
|
14
14
|
#
|
|
15
|
+
# @example
|
|
16
|
+
#
|
|
17
|
+
# # bad
|
|
18
|
+
# class ExampleMigration < ActiveRecord::Migration[7.0]
|
|
19
|
+
# def change
|
|
20
|
+
# denied_method(:denied_table, column: :value)
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# # good
|
|
25
|
+
# class ExampleMigration < ActiveRecord::Migration[7.0]
|
|
26
|
+
# def change
|
|
27
|
+
# denied_method(:allowed_table, column: :value)
|
|
28
|
+
# end
|
|
29
|
+
# end
|
|
30
|
+
#
|
|
31
|
+
# # good
|
|
32
|
+
# class ExampleMigration < ActiveRecord::Migration[7.0]
|
|
33
|
+
# def change
|
|
34
|
+
# allowed_method(:denied_table, column: :value)
|
|
35
|
+
# end
|
|
36
|
+
# end
|
|
37
|
+
#
|
|
15
38
|
# See https://gitlab.com/gitlab-com/infrastructure/issues/1602 for more
|
|
16
39
|
# information.
|
|
17
40
|
class UpdateLargeTable < RuboCop::Cop::Base
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
# Limits the number of examples in feature spec files.
|
|
10
|
+
#
|
|
11
|
+
# Feature specs with too many examples are slow to run, hard to maintain,
|
|
12
|
+
# and often indicate the file should be split into smaller, focused specs.
|
|
13
|
+
#
|
|
14
|
+
# The maximum number of examples can be configured with the `Max` option
|
|
15
|
+
# (default: 25).
|
|
16
|
+
#
|
|
17
|
+
# @example Max: 25 (default)
|
|
18
|
+
#
|
|
19
|
+
# # bad
|
|
20
|
+
# # A feature spec file with more than 25 examples.
|
|
21
|
+
#
|
|
22
|
+
# # good
|
|
23
|
+
# # A feature spec file with 25 or fewer examples.
|
|
24
|
+
class FeatureSpecMaxExamples < Base
|
|
25
|
+
MSG = 'Feature spec file has %<count>d examples, which exceeds the maximum of %<max>d. ' \
|
|
26
|
+
'Consider splitting into smaller, focused files grouped by user flow or feature area.'
|
|
27
|
+
|
|
28
|
+
def on_new_investigation
|
|
29
|
+
super
|
|
30
|
+
@example_count = 0
|
|
31
|
+
@max = cop_config['Max'] || 25
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def on_block(node)
|
|
35
|
+
@example_count += 1 if example?(node)
|
|
36
|
+
end
|
|
37
|
+
alias_method :on_numblock, :on_block
|
|
38
|
+
|
|
39
|
+
def on_investigation_end
|
|
40
|
+
add_global_offense(format(MSG, count: @example_count, max: @max)) if @example_count > @max
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/rubocop-rspec.yml
CHANGED
|
@@ -96,6 +96,12 @@ RSpec/ExpectChange:
|
|
|
96
96
|
RSpec/ExpectOutput:
|
|
97
97
|
Enabled: true
|
|
98
98
|
|
|
99
|
+
# Limits the number of examples in feature spec files to encourage splitting
|
|
100
|
+
# large specs into smaller, focused files.
|
|
101
|
+
RSpec/FeatureSpecMaxExamples:
|
|
102
|
+
Enabled: false
|
|
103
|
+
Max: 25
|
|
104
|
+
|
|
99
105
|
# Checks if there are focused specs.
|
|
100
106
|
RSpec/Focus:
|
|
101
107
|
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: 14.
|
|
4
|
+
version: 14.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GitLab
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -357,6 +357,7 @@ files:
|
|
|
357
357
|
- lib/rubocop/cop/rspec/empty_line_after_let_block.rb
|
|
358
358
|
- lib/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
|
359
359
|
- lib/rubocop/cop/rspec/example_starting_character.rb
|
|
360
|
+
- lib/rubocop/cop/rspec/feature_spec_max_examples.rb
|
|
360
361
|
- lib/rubocop/cop/rspec/have_link_parameters.rb
|
|
361
362
|
- lib/rubocop/cop/rspec/rails_controller_testing.rb
|
|
362
363
|
- lib/rubocop/cop/rspec/single_line_hook.rb
|