gitlab-styles 13.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/merge_request_templates/New Static Analysis Check.md +26 -0
- data/.gitlab-ci.yml +3 -4
- data/.rubocop.yml +2 -23
- data/.rubocop_todo.yml +2 -19
- data/Gemfile.lock +248 -133
- data/README.md +34 -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 -4
- data/lib/rubocop/cop/fips/md5.rb +10 -0
- data/lib/rubocop/cop/fips/open_ssl.rb +11 -0
- data/lib/rubocop/cop/fips/sha1.rb +8 -0
- data/lib/rubocop/cop/gem_fetcher.rb +6 -0
- data/lib/rubocop/cop/gitlab_security/deep_munge.rb +10 -0
- data/lib/rubocop/cop/in_batches.rb +8 -0
- data/lib/rubocop/cop/internal_affairs/cop_description_with_example.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb +12 -0
- data/lib/rubocop/cop/internal_affairs/use_restrict_on_send.rb +17 -16
- data/lib/rubocop/cop/line_break_around_conditional_block.rb +31 -31
- data/lib/rubocop/cop/migration/update_large_table.rb +24 -1
- data/lib/rubocop/cop/performance/rubyzip.rb +6 -0
- data/lib/rubocop/cop/polymorphic_associations.rb +11 -0
- 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 +46 -0
- data/lib/rubocop/cop/rspec/single_line_hook.rb +1 -0
- data/lib/rubocop/cop/tailwind/max_width_media_queries.rb +2 -1
- 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-naming.yml +1 -1
- data/rubocop-performance.yml +3 -8
- data/rubocop-rails.yml +8 -2
- data/rubocop-rspec.yml +25 -2
- data/rubocop-security.yml +7 -1
- data/rubocop-style.yml +8 -1
- data/rubocop-tailwind.yml +2 -1
- metadata +58 -72
- data/lib/rubocop/cop/line_break_after_guard_clauses.rb +0 -99
- data/lib/rubocop/cop/style/open_struct_use.rb +0 -49
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
alias_method :on_itblock, :on_block
|
|
39
|
+
|
|
40
|
+
def on_investigation_end
|
|
41
|
+
add_global_offense(format(MSG, count: @example_count, max: @max)) if @example_count > @max
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -14,7 +14,8 @@ module Rubocop
|
|
|
14
14
|
# css_classes = ["gl-mt-3", "md:gl-mt-5"]
|
|
15
15
|
# %div{ class: ["gl-mt-3", "md:gl-mt-5"] }
|
|
16
16
|
class MaxWidthMediaQueries < RuboCop::Cop::Base
|
|
17
|
-
|
|
17
|
+
ALLOWLIST = ['hidden'].freeze
|
|
18
|
+
TAILWIND_CSS_CLASS = /max-(sm|md|lg|xl):gl-(?!#{ALLOWLIST.join('|')})/
|
|
18
19
|
MSG = 'Do not use max-width media query utility classes unless absolutely necessary. ' \
|
|
19
20
|
'Use min-width media query utility classes instead.'
|
|
20
21
|
|
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-naming.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:
|
|
@@ -96,6 +113,12 @@ RSpec/ExpectChange:
|
|
|
96
113
|
RSpec/ExpectOutput:
|
|
97
114
|
Enabled: true
|
|
98
115
|
|
|
116
|
+
# Limits the number of examples in feature spec files to encourage splitting
|
|
117
|
+
# large specs into smaller, focused files.
|
|
118
|
+
RSpec/FeatureSpecMaxExamples:
|
|
119
|
+
Enabled: false
|
|
120
|
+
Max: 25
|
|
121
|
+
|
|
99
122
|
# Checks if there are focused specs.
|
|
100
123
|
RSpec/Focus:
|
|
101
124
|
Enabled: true
|
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
|
|
@@ -475,6 +478,10 @@ Style/TrailingCommaInArguments:
|
|
|
475
478
|
Enabled: true
|
|
476
479
|
EnforcedStyleForMultiline: no_comma
|
|
477
480
|
|
|
481
|
+
# Checks for the use of logical operators in an unless condition.
|
|
482
|
+
Style/UnlessLogicalOperators:
|
|
483
|
+
Enabled: true
|
|
484
|
+
|
|
478
485
|
# Don't interpolate global, instance and class variables directly in strings.
|
|
479
486
|
Style/VariableInterpolation:
|
|
480
487
|
Enabled: true
|
data/rubocop-tailwind.yml
CHANGED