gitlab-styles 7.0.0 → 9.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/.rubocop.yml +11 -0
- data/Gemfile +3 -3
- data/gitlab-styles.gemspec +6 -6
- data/lib/gitlab/styles/common/banned_constants.rb +28 -0
- data/lib/gitlab/styles/rubocop/model_helpers.rb +1 -1
- data/lib/gitlab/styles/rubocop.rb +2 -2
- data/lib/gitlab/styles/version.rb +1 -1
- data/lib/rubocop/cop/active_record_dependent.rb +32 -0
- data/lib/rubocop/cop/active_record_serialize.rb +20 -0
- data/lib/rubocop/cop/avoid_return_from_blocks.rb +79 -0
- data/lib/rubocop/cop/code_reuse/active_record.rb +80 -0
- data/lib/rubocop/cop/custom_error_class.rb +67 -0
- data/lib/rubocop/cop/fips/md5.rb +27 -0
- data/lib/rubocop/cop/fips/open_ssl.rb +31 -0
- data/lib/rubocop/cop/fips/sha1.rb +27 -0
- data/lib/rubocop/cop/gem_fetcher.rb +37 -0
- data/lib/rubocop/cop/in_batches.rb +18 -0
- data/lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb +42 -0
- data/lib/rubocop/cop/line_break_after_guard_clauses.rb +101 -0
- data/lib/rubocop/cop/line_break_around_conditional_block.rb +127 -0
- data/lib/rubocop/cop/migration/update_large_table.rb +61 -0
- data/lib/rubocop/cop/performance/rubyzip.rb +36 -0
- data/lib/rubocop/cop/polymorphic_associations.rb +25 -0
- data/lib/rubocop/cop/rails/include_url_helper.rb +28 -0
- data/lib/rubocop/cop/redirect_with_status.rb +46 -0
- data/lib/rubocop/cop/rspec/base.rb +12 -0
- data/lib/rubocop/cop/rspec/empty_line_after_let_block.rb +61 -0
- data/lib/rubocop/cop/rspec/empty_line_after_shared_example.rb +63 -0
- data/lib/rubocop/cop/rspec/example_starting_character.rb +122 -0
- data/lib/rubocop/cop/rspec/have_link_parameters.rb +45 -0
- data/lib/rubocop/cop/rspec/single_line_hook.rb +43 -0
- data/lib/rubocop/cop/rspec/verbose_include_metadata.rb +73 -0
- data/lib/rubocop/cop/style/hash_transformation.rb +81 -0
- data/lib/rubocop/cop/style/open_struct_use.rb +40 -0
- data/lib/rubocop/cop/without_reactive_cache.rb +16 -0
- data/rubocop-default.yml +1 -0
- data/rubocop-fips.yml +15 -0
- data/rubocop-layout.yml +1 -1
- data/rubocop-rspec.yml +13 -5
- metadata +44 -47
- data/lib/gitlab/styles/rubocop/cop/active_record_dependent.rb +0 -36
- data/lib/gitlab/styles/rubocop/cop/active_record_serialize.rb +0 -24
- data/lib/gitlab/styles/rubocop/cop/avoid_return_from_blocks.rb +0 -81
- data/lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb +0 -84
- data/lib/gitlab/styles/rubocop/cop/custom_error_class.rb +0 -73
- data/lib/gitlab/styles/rubocop/cop/gem_fetcher.rb +0 -41
- data/lib/gitlab/styles/rubocop/cop/in_batches.rb +0 -22
- data/lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb +0 -43
- data/lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb +0 -104
- data/lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb +0 -132
- data/lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb +0 -64
- data/lib/gitlab/styles/rubocop/cop/performance/rubyzip.rb +0 -39
- data/lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb +0 -29
- data/lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb +0 -31
- data/lib/gitlab/styles/rubocop/cop/redirect_with_status.rb +0 -50
- data/lib/gitlab/styles/rubocop/cop/rspec/base.rb +0 -18
- data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb +0 -51
- data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_let_block.rb +0 -65
- data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb +0 -65
- data/lib/gitlab/styles/rubocop/cop/rspec/example_starting_character.rb +0 -124
- data/lib/gitlab/styles/rubocop/cop/rspec/have_link_parameters.rb +0 -48
- data/lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb +0 -45
- data/lib/gitlab/styles/rubocop/cop/rspec/verbose_include_metadata.rb +0 -75
- data/lib/gitlab/styles/rubocop/cop/style/hash_transformation.rb +0 -87
- data/lib/gitlab/styles/rubocop/cop/style/open_struct_use.rb +0 -43
- data/lib/gitlab/styles/rubocop/cop/without_reactive_cache.rb +0 -20
- data/lib/gitlab/styles/rubocop/rspec/helpers.rb +0 -18
@@ -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
|
+
# Checks for unused parameters to the `have_link` matcher.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
#
|
13
|
+
# # bad
|
14
|
+
# expect(page).to have_link('Link', 'https://example.com')
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# expect(page).to have_link('Link', href: 'https://example.com')
|
18
|
+
# expect(page).to have_link('Example')
|
19
|
+
class HaveLinkParameters < Base
|
20
|
+
extend RuboCop::Cop::AutoCorrector
|
21
|
+
|
22
|
+
MESSAGE = "The second argument to `have_link` should be a Hash."
|
23
|
+
|
24
|
+
# @!method unused_parameters?(node)
|
25
|
+
def_node_matcher :unused_parameters?, <<~PATTERN
|
26
|
+
(send nil? :have_link
|
27
|
+
_ !{hash nil}
|
28
|
+
)
|
29
|
+
PATTERN
|
30
|
+
|
31
|
+
def on_send(node)
|
32
|
+
return unless unused_parameters?(node)
|
33
|
+
|
34
|
+
location = node.arguments[1..]
|
35
|
+
.map(&:source_range)
|
36
|
+
.reduce(:join)
|
37
|
+
|
38
|
+
add_offense(location, message: MESSAGE) do |corrector|
|
39
|
+
corrector.insert_after(location.end, "\n")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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
|
+
# Checks for single-line hook blocks
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
#
|
13
|
+
# # bad
|
14
|
+
# before { do_something }
|
15
|
+
# after(:each) { undo_something }
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# before do
|
19
|
+
# do_something
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# after(:each) do
|
23
|
+
# undo_something
|
24
|
+
# end
|
25
|
+
class SingleLineHook < Base
|
26
|
+
MESSAGE = "Don't use single-line hook blocks."
|
27
|
+
|
28
|
+
# @!method rspec_hook?(node)
|
29
|
+
def_node_search :rspec_hook?, <<~PATTERN
|
30
|
+
(send nil? {:after :around :before} ...)
|
31
|
+
PATTERN
|
32
|
+
|
33
|
+
def on_block(node)
|
34
|
+
return unless node.single_line?
|
35
|
+
return unless rspec_hook?(node)
|
36
|
+
|
37
|
+
add_offense(node, message: MESSAGE)
|
38
|
+
end
|
39
|
+
alias_method :on_numblock, :on_block
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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
|
+
# Checks for verbose include metadata used in the specs.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# # bad
|
13
|
+
# describe MyClass, js: true do
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# describe MyClass, :js do
|
18
|
+
# end
|
19
|
+
class VerboseIncludeMetadata < Base
|
20
|
+
extend RuboCop::Cop::AutoCorrector
|
21
|
+
|
22
|
+
MSG = 'Use `%s` instead of `%s`.'
|
23
|
+
|
24
|
+
SELECTORS = %i[describe context feature example_group it specify example scenario its].freeze
|
25
|
+
|
26
|
+
# @!method include_metadata(node)
|
27
|
+
def_node_matcher :include_metadata, <<-PATTERN
|
28
|
+
(send {(const nil? :RSpec) nil?} {#{SELECTORS.map(&:inspect).join(' ')}}
|
29
|
+
!const
|
30
|
+
...
|
31
|
+
(hash $...))
|
32
|
+
PATTERN
|
33
|
+
|
34
|
+
# @!method invalid_metadata?(node)
|
35
|
+
def_node_matcher :invalid_metadata?, <<-PATTERN
|
36
|
+
(pair
|
37
|
+
(sym $...)
|
38
|
+
(true))
|
39
|
+
PATTERN
|
40
|
+
|
41
|
+
def on_send(node)
|
42
|
+
invalid_metadata_matches(node) do |match|
|
43
|
+
add_offense(node, message: format(MSG, good(match), bad(match))) do |corrector|
|
44
|
+
invalid_metadata_matches(node) do |match|
|
45
|
+
corrector.replace(match.loc.expression, good(match))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def invalid_metadata_matches(node, &block)
|
54
|
+
include_metadata(node) do |matches|
|
55
|
+
matches.select { |match| invalid_metadata?(match) }.each(&block)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def bad(match)
|
60
|
+
"#{metadata_key(match)}: true"
|
61
|
+
end
|
62
|
+
|
63
|
+
def good(match)
|
64
|
+
":#{metadata_key(match)}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def metadata_key(match)
|
68
|
+
match.children[0].source
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubocop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# Identifies places where `map { ... }.to_h` or
|
7
|
+
# `Hash[map { ... }]` can be replaced with `to_h { ... }`,
|
8
|
+
# saving an intermediate array allocation.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# hash.map { |k, v| [v.upcase, k.downcase] }.to_h
|
13
|
+
# hash.collect { |k, v| [v.upcase, k.downcase] }.to_h
|
14
|
+
# Hash[hash.map { |k, v| [v.upcase, k.downcase] }]
|
15
|
+
# Hash[hash.collect { |k, v| [v.upcase, k.downcase] }]
|
16
|
+
# array.map { |x| [x, x + 1] }.to_h
|
17
|
+
#
|
18
|
+
# # good
|
19
|
+
# hash.to_h { |k, v| [v.upcase, k.downcase] }
|
20
|
+
# array.to_h { |x| [x, x + 1] }
|
21
|
+
#
|
22
|
+
# Full credit: https://github.com/eugeneius/rubocop-performance/blob/hash_transformation/lib/rubocop/cop/performance/hash_transformation.rb
|
23
|
+
class HashTransformation < RuboCop::Cop::Base
|
24
|
+
extend RuboCop::Cop::AutoCorrector
|
25
|
+
include RuboCop::Cop::RangeHelp
|
26
|
+
|
27
|
+
MSG = 'Use `to_h { ... }` instead of `%<current>s`.'
|
28
|
+
|
29
|
+
# @!method to_h_candidate?(node)
|
30
|
+
def_node_matcher :to_h_candidate?, <<~PATTERN
|
31
|
+
{
|
32
|
+
[(send
|
33
|
+
$(block $(send _ {:map :collect}) ...) :to_h) !block_literal?]
|
34
|
+
(send (const nil? :Hash) :[]
|
35
|
+
$(block $(send _ {:map :collect}) ...))
|
36
|
+
}
|
37
|
+
PATTERN
|
38
|
+
|
39
|
+
def on_send(node)
|
40
|
+
to_h_candidate?(node) do |_block, call|
|
41
|
+
range = offense_range(node, call)
|
42
|
+
message = message(node, call)
|
43
|
+
add_offense(range, message: message) do |corrector|
|
44
|
+
block, call = to_h_candidate?(node)
|
45
|
+
|
46
|
+
corrector.remove(after_block(node, block))
|
47
|
+
corrector.replace(call.loc.selector, 'to_h')
|
48
|
+
corrector.remove(before_block(node, block))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def offense_range(node, call)
|
56
|
+
return node.source_range if node.children.first.const_type?
|
57
|
+
|
58
|
+
range_between(call.loc.selector.begin_pos, node.loc.selector.end_pos)
|
59
|
+
end
|
60
|
+
|
61
|
+
def message(node, call)
|
62
|
+
current = if node.children.first.const_type?
|
63
|
+
"Hash[#{call.method_name} { ... }]"
|
64
|
+
else
|
65
|
+
"#{call.method_name} { ... }.to_h"
|
66
|
+
end
|
67
|
+
|
68
|
+
format(MSG, current: current)
|
69
|
+
end
|
70
|
+
|
71
|
+
def after_block(node, block)
|
72
|
+
block.source_range.end.join(node.source_range.end)
|
73
|
+
end
|
74
|
+
|
75
|
+
def before_block(node, block)
|
76
|
+
node.source_range.begin.join(block.source_range.begin)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubocop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# Flags uses of OpenStruct, as it is now officially discouraged
|
7
|
+
# to be used for performance, version compatibility, and potential security issues.
|
8
|
+
#
|
9
|
+
# See also:
|
10
|
+
# - https://rubyreferences.github.io/rubychanges/3.0.html#standard-library
|
11
|
+
# - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
|
12
|
+
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67855
|
13
|
+
class OpenStructUse < RuboCop::Cop::Base
|
14
|
+
MSG = 'Avoid using `OpenStruct`. It is officially discouraged. ' \
|
15
|
+
'Replace it with `Struct`, `Hash`, or RSpec doubles. ' \
|
16
|
+
'See https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats'
|
17
|
+
|
18
|
+
# @!method uses_open_struct?(node)
|
19
|
+
def_node_matcher :uses_open_struct?, <<-PATTERN
|
20
|
+
(const {nil? (cbase)} :OpenStruct)
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
def on_const(node)
|
24
|
+
return unless uses_open_struct?(node)
|
25
|
+
return if custom_class_or_module_definition?(node)
|
26
|
+
|
27
|
+
add_offense(node)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def custom_class_or_module_definition?(node)
|
33
|
+
parent = node.parent
|
34
|
+
|
35
|
+
(parent.class_type? || parent.module_type?) && node.left_siblings.empty?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubocop
|
4
|
+
module Cop
|
5
|
+
# Cop that prevents the use of `without_reactive_cache`
|
6
|
+
class WithoutReactiveCache < RuboCop::Cop::Base
|
7
|
+
MSG = 'without_reactive_cache is for debugging purposes only. Please use with_reactive_cache.'
|
8
|
+
|
9
|
+
def on_send(node)
|
10
|
+
return unless node.children[1] == :without_reactive_cache
|
11
|
+
|
12
|
+
add_offense(node.loc.selector)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/rubocop-default.yml
CHANGED
data/rubocop-fips.yml
ADDED
data/rubocop-layout.yml
CHANGED
@@ -135,7 +135,7 @@ Layout/LeadingCommentSpace:
|
|
135
135
|
Layout/LineLength:
|
136
136
|
Enabled: true
|
137
137
|
Max: 120
|
138
|
-
|
138
|
+
AllowedPatterns: ['\s#\srubocop']
|
139
139
|
|
140
140
|
# Checks that the closing brace in an array literal is either on the same line
|
141
141
|
# as the last array element, or a new line.
|
data/rubocop-rspec.yml
CHANGED
@@ -34,11 +34,6 @@ RSpec/DescribedClass:
|
|
34
34
|
# Checks if an example group does not include any tests.
|
35
35
|
RSpec/EmptyExampleGroup:
|
36
36
|
Enabled: true
|
37
|
-
CustomIncludeMethods:
|
38
|
-
- run_permission_checks
|
39
|
-
- run_group_permission_checks
|
40
|
-
- it_should_email!
|
41
|
-
- it_should_not_email!
|
42
37
|
|
43
38
|
# Checks if there is an empty line after let blocks.
|
44
39
|
RSpec/EmptyLineAfterLetBlock:
|
@@ -159,3 +154,16 @@ RSpec/SubjectStub:
|
|
159
154
|
# Prefer using verifying doubles over normal doubles.
|
160
155
|
RSpec/VerifiedDoubles:
|
161
156
|
Enabled: true
|
157
|
+
|
158
|
+
RSpec:
|
159
|
+
Language:
|
160
|
+
Helpers:
|
161
|
+
- let_it_be
|
162
|
+
- let_it_be_with_refind
|
163
|
+
- let_it_be_with_reload
|
164
|
+
Includes:
|
165
|
+
Examples:
|
166
|
+
- run_permission_checks
|
167
|
+
- run_group_permission_checks
|
168
|
+
- it_should_email!
|
169
|
+
- it_should_not_email!
|
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:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.91.1
|
19
|
+
version: 1.36.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.91.1
|
26
|
+
version: 1.36.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rubocop-gitlab-security
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,56 +44,56 @@ dependencies:
|
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
47
|
+
version: '0.14'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
54
|
+
version: '0.14'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: rubocop-performance
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: 1.
|
61
|
+
version: '1.14'
|
68
62
|
type: :runtime
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
66
|
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.
|
68
|
+
version: '1.14'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
70
|
name: rubocop-rails
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
73
|
- - "~>"
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: '2.
|
75
|
+
version: '2.15'
|
82
76
|
type: :runtime
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
80
|
- - "~>"
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '2.
|
82
|
+
version: '2.15'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: rubocop-rspec
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
87
|
- - "~>"
|
94
88
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
89
|
+
version: '2.12'
|
96
90
|
type: :runtime
|
97
91
|
prerelease: false
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
94
|
- - "~>"
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
96
|
+
version: '2.12'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
98
|
name: bundler
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +114,14 @@ dependencies:
|
|
120
114
|
requirements:
|
121
115
|
- - "~>"
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: 2.
|
117
|
+
version: 2.11.0
|
124
118
|
type: :development
|
125
119
|
prerelease: false
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
122
|
- - "~>"
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: 2.
|
124
|
+
version: 2.11.0
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
126
|
name: rake
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,41 +176,44 @@ files:
|
|
182
176
|
- bin/setup
|
183
177
|
- gitlab-styles.gemspec
|
184
178
|
- lib/gitlab/styles.rb
|
179
|
+
- lib/gitlab/styles/common/banned_constants.rb
|
185
180
|
- lib/gitlab/styles/rubocop.rb
|
186
|
-
- lib/gitlab/styles/rubocop/cop/active_record_dependent.rb
|
187
|
-
- lib/gitlab/styles/rubocop/cop/active_record_serialize.rb
|
188
|
-
- lib/gitlab/styles/rubocop/cop/avoid_return_from_blocks.rb
|
189
|
-
- lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb
|
190
|
-
- lib/gitlab/styles/rubocop/cop/custom_error_class.rb
|
191
|
-
- lib/gitlab/styles/rubocop/cop/gem_fetcher.rb
|
192
|
-
- lib/gitlab/styles/rubocop/cop/in_batches.rb
|
193
|
-
- lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
|
194
|
-
- lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb
|
195
|
-
- lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb
|
196
|
-
- lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
|
197
|
-
- lib/gitlab/styles/rubocop/cop/performance/rubyzip.rb
|
198
|
-
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
|
199
|
-
- lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb
|
200
|
-
- lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
|
201
|
-
- lib/gitlab/styles/rubocop/cop/rspec/base.rb
|
202
|
-
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb
|
203
|
-
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_let_block.rb
|
204
|
-
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
205
|
-
- lib/gitlab/styles/rubocop/cop/rspec/example_starting_character.rb
|
206
|
-
- lib/gitlab/styles/rubocop/cop/rspec/have_link_parameters.rb
|
207
|
-
- lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb
|
208
|
-
- lib/gitlab/styles/rubocop/cop/rspec/verbose_include_metadata.rb
|
209
|
-
- lib/gitlab/styles/rubocop/cop/style/hash_transformation.rb
|
210
|
-
- lib/gitlab/styles/rubocop/cop/style/open_struct_use.rb
|
211
|
-
- lib/gitlab/styles/rubocop/cop/without_reactive_cache.rb
|
212
181
|
- lib/gitlab/styles/rubocop/migration_helpers.rb
|
213
182
|
- lib/gitlab/styles/rubocop/model_helpers.rb
|
214
|
-
- lib/gitlab/styles/rubocop/rspec/helpers.rb
|
215
183
|
- lib/gitlab/styles/version.rb
|
184
|
+
- lib/rubocop/cop/active_record_dependent.rb
|
185
|
+
- lib/rubocop/cop/active_record_serialize.rb
|
186
|
+
- lib/rubocop/cop/avoid_return_from_blocks.rb
|
187
|
+
- lib/rubocop/cop/code_reuse/active_record.rb
|
188
|
+
- lib/rubocop/cop/custom_error_class.rb
|
189
|
+
- lib/rubocop/cop/fips/md5.rb
|
190
|
+
- lib/rubocop/cop/fips/open_ssl.rb
|
191
|
+
- lib/rubocop/cop/fips/sha1.rb
|
192
|
+
- lib/rubocop/cop/gem_fetcher.rb
|
193
|
+
- lib/rubocop/cop/in_batches.rb
|
194
|
+
- lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
|
195
|
+
- lib/rubocop/cop/line_break_after_guard_clauses.rb
|
196
|
+
- lib/rubocop/cop/line_break_around_conditional_block.rb
|
197
|
+
- lib/rubocop/cop/migration/update_large_table.rb
|
198
|
+
- lib/rubocop/cop/performance/rubyzip.rb
|
199
|
+
- lib/rubocop/cop/polymorphic_associations.rb
|
200
|
+
- lib/rubocop/cop/rails/include_url_helper.rb
|
201
|
+
- lib/rubocop/cop/redirect_with_status.rb
|
202
|
+
- lib/rubocop/cop/rspec/base.rb
|
203
|
+
- lib/rubocop/cop/rspec/empty_line_after_let_block.rb
|
204
|
+
- lib/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
205
|
+
- lib/rubocop/cop/rspec/example_starting_character.rb
|
206
|
+
- lib/rubocop/cop/rspec/have_link_parameters.rb
|
207
|
+
- lib/rubocop/cop/rspec/single_line_hook.rb
|
208
|
+
- lib/rubocop/cop/rspec/verbose_include_metadata.rb
|
209
|
+
- lib/rubocop/cop/style/hash_transformation.rb
|
210
|
+
- lib/rubocop/cop/style/open_struct_use.rb
|
211
|
+
- lib/rubocop/cop/without_reactive_cache.rb
|
216
212
|
- rubocop-all.yml
|
217
213
|
- rubocop-bundler.yml
|
218
214
|
- rubocop-code_reuse.yml
|
219
215
|
- rubocop-default.yml
|
216
|
+
- rubocop-fips.yml
|
220
217
|
- rubocop-gemspec.yml
|
221
218
|
- rubocop-graphql.yml
|
222
219
|
- rubocop-layout.yml
|
@@ -1,36 +0,0 @@
|
|
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
|
-
# Cop that prevents the use of `dependent: ...` in ActiveRecord models.
|
10
|
-
class ActiveRecordDependent < RuboCop::Cop::Cop
|
11
|
-
include ModelHelpers
|
12
|
-
|
13
|
-
MSG = 'Do not use `dependent:` to remove associated data, ' \
|
14
|
-
'use foreign keys with cascading deletes instead.'
|
15
|
-
|
16
|
-
METHOD_NAMES = [:has_many, :has_one, :belongs_to].freeze
|
17
|
-
ALLOWED_OPTIONS = [:restrict_with_error].freeze
|
18
|
-
|
19
|
-
def on_send(node)
|
20
|
-
return unless in_model?(node)
|
21
|
-
return unless METHOD_NAMES.include?(node.children[1])
|
22
|
-
|
23
|
-
node.children.last.each_node(:pair) do |pair|
|
24
|
-
key_name = pair.children[0].children[0]
|
25
|
-
option_name = pair.children[1].children[0]
|
26
|
-
|
27
|
-
break if ALLOWED_OPTIONS.include?(option_name)
|
28
|
-
|
29
|
-
add_offense(pair) if key_name == :dependent
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,24 +0,0 @@
|
|
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
|
-
# Cop that prevents the use of `serialize` in ActiveRecord models.
|
10
|
-
class ActiveRecordSerialize < RuboCop::Cop::Cop
|
11
|
-
include ModelHelpers
|
12
|
-
|
13
|
-
MSG = 'Do not store serialized data in the database, use separate columns and/or tables instead'
|
14
|
-
|
15
|
-
def on_send(node)
|
16
|
-
return unless in_model?(node)
|
17
|
-
|
18
|
-
add_offense(node, location: :selector) if node.children[1] == :serialize
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|