gitlab-styles 6.6.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab/changelog_config.yml +13 -0
- data/.gitlab/merge_request_templates/Release.md +9 -31
- data/.gitlab-ci.yml +3 -1
- data/Dangerfile +5 -0
- data/gitlab-styles.gemspec +1 -0
- 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 +77 -0
- data/lib/rubocop/cop/code_reuse/active_record.rb +80 -0
- data/lib/rubocop/cop/custom_error_class.rb +69 -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 +39 -0
- data/lib/rubocop/cop/line_break_after_guard_clauses.rb +100 -0
- data/lib/rubocop/cop/line_break_around_conditional_block.rb +128 -0
- data/lib/rubocop/cop/migration/update_large_table.rb +60 -0
- data/lib/rubocop/cop/performance/rubyzip.rb +35 -0
- data/lib/rubocop/cop/polymorphic_associations.rb +25 -0
- data/lib/rubocop/cop/rails/include_url_helper.rb +27 -0
- data/lib/rubocop/cop/redirect_with_status.rb +46 -0
- data/lib/rubocop/cop/rspec/base.rb +14 -0
- data/lib/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb +47 -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 +61 -0
- data/lib/rubocop/cop/rspec/example_starting_character.rb +120 -0
- data/lib/rubocop/cop/rspec/have_link_parameters.rb +44 -0
- data/lib/rubocop/cop/rspec/single_line_hook.rb +41 -0
- data/lib/rubocop/cop/rspec/verbose_include_metadata.rb +71 -0
- data/lib/rubocop/cop/style/hash_transformation.rb +83 -0
- data/lib/rubocop/cop/style/open_struct_use.rb +39 -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-rspec.yml +3 -2
- metadata +49 -27
- data/lib/gitlab/styles/rubocop/cop/active_record_dependent.rb +0 -32
- data/lib/gitlab/styles/rubocop/cop/active_record_serialize.rb +0 -24
- data/lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb +0 -130
- 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
@@ -0,0 +1,120 @@
|
|
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 common mistakes in example descriptions.
|
10
|
+
#
|
11
|
+
# This cop will correct docstrings that begin/end with space or words that start with a capital letter.
|
12
|
+
#
|
13
|
+
# @see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46336#note_442669518
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# # bad
|
17
|
+
# it 'Does something' do
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# # good
|
21
|
+
# it 'does nothing' do
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# # bad
|
26
|
+
# it ' does something' do
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# it 'does something' do
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# # bad
|
35
|
+
# it 'does something ' do
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# # good
|
39
|
+
# it 'does something' do
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# # bad
|
44
|
+
# it ' does something ' do
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# # good
|
48
|
+
# it 'does something' do
|
49
|
+
# end
|
50
|
+
class ExampleStartingCharacter < Base
|
51
|
+
extend RuboCop::Cop::AutoCorrector
|
52
|
+
|
53
|
+
MSG = 'Only start words with lowercase alpha with no leading/trailing spaces when describing your tests.'
|
54
|
+
|
55
|
+
def_node_matcher :it_description, <<-PATTERN
|
56
|
+
(block (send _ :it ${
|
57
|
+
(str $_)
|
58
|
+
(dstr (str $_ ) ...)
|
59
|
+
} ...) ...)
|
60
|
+
PATTERN
|
61
|
+
|
62
|
+
def on_block(node)
|
63
|
+
it_description(node) do |description_node, _message|
|
64
|
+
add_wording_offense(description_node, MSG) if invalid_description?(text(description_node))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def add_wording_offense(node, message)
|
71
|
+
docstring = docstring(node)
|
72
|
+
add_offense(docstring, message: message) do |corrector|
|
73
|
+
corrector.replace(docstring, replacement_text(node))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def docstring(node)
|
78
|
+
expr = node.loc.expression
|
79
|
+
|
80
|
+
Parser::Source::Range.new(
|
81
|
+
expr.source_buffer,
|
82
|
+
expr.begin_pos + 1,
|
83
|
+
expr.end_pos - 1
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def invalid_description?(message)
|
88
|
+
message.match?(/(^([A-Z]{1}[a-z]+\s|\s)|\s$)/)
|
89
|
+
end
|
90
|
+
|
91
|
+
def replacement_text(node)
|
92
|
+
text = text(node)
|
93
|
+
|
94
|
+
text.strip!
|
95
|
+
|
96
|
+
text = downcase_first_letter(text) if invalid_description?(text)
|
97
|
+
|
98
|
+
text
|
99
|
+
end
|
100
|
+
|
101
|
+
# Recursive processing is required to process nested dstr nodes
|
102
|
+
# that is the case for \-separated multiline strings with interpolation.
|
103
|
+
def text(node)
|
104
|
+
case node.type
|
105
|
+
when :dstr
|
106
|
+
node.node_parts.map { |child_node| text(child_node) }.join
|
107
|
+
when :str
|
108
|
+
node.value
|
109
|
+
when :begin
|
110
|
+
node.source
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def downcase_first_letter(str)
|
115
|
+
str[0].downcase + str[1..]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
# This cop 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
|
+
def_node_matcher :unused_parameters?, <<~PATTERN
|
25
|
+
(send nil? :have_link
|
26
|
+
_ !{hash nil}
|
27
|
+
)
|
28
|
+
PATTERN
|
29
|
+
|
30
|
+
def on_send(node)
|
31
|
+
return unless unused_parameters?(node)
|
32
|
+
|
33
|
+
location = node.arguments[1..]
|
34
|
+
.map(&:source_range)
|
35
|
+
.reduce(:join)
|
36
|
+
|
37
|
+
add_offense(location, message: MESSAGE) do |corrector|
|
38
|
+
corrector.insert_after(location.end, "\n")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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
|
+
# This cop 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
|
+
def_node_search :rspec_hook?, <<~PATTERN
|
29
|
+
(send nil? {:after :around :before} ...)
|
30
|
+
PATTERN
|
31
|
+
|
32
|
+
def on_block(node)
|
33
|
+
return unless node.single_line?
|
34
|
+
return unless rspec_hook?(node)
|
35
|
+
|
36
|
+
add_offense(node, message: MESSAGE)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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
|
+
def_node_matcher :include_metadata, <<-PATTERN
|
27
|
+
(send {(const nil? :RSpec) nil?} {#{SELECTORS.map(&:inspect).join(' ')}}
|
28
|
+
!const
|
29
|
+
...
|
30
|
+
(hash $...))
|
31
|
+
PATTERN
|
32
|
+
|
33
|
+
def_node_matcher :invalid_metadata?, <<-PATTERN
|
34
|
+
(pair
|
35
|
+
(sym $...)
|
36
|
+
(true))
|
37
|
+
PATTERN
|
38
|
+
|
39
|
+
def on_send(node)
|
40
|
+
invalid_metadata_matches(node) do |match|
|
41
|
+
add_offense(node, message: format(MSG, good(match), bad(match))) do |corrector|
|
42
|
+
invalid_metadata_matches(node) do |match|
|
43
|
+
corrector.replace(match.loc.expression, good(match))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def invalid_metadata_matches(node, &block)
|
52
|
+
include_metadata(node) do |matches|
|
53
|
+
matches.select { |match| invalid_metadata?(match) }.each(&block)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def bad(match)
|
58
|
+
"#{metadata_key(match)}: true"
|
59
|
+
end
|
60
|
+
|
61
|
+
def good(match)
|
62
|
+
":#{metadata_key(match)}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def metadata_key(match)
|
66
|
+
match.children[0].source
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubocop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# This cop 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::Cop
|
24
|
+
include RuboCop::Cop::RangeHelp
|
25
|
+
|
26
|
+
MSG = 'Use `to_h { ... }` instead of `%<current>s`.'
|
27
|
+
|
28
|
+
def_node_matcher :to_h_candidate?, <<~PATTERN
|
29
|
+
{
|
30
|
+
[(send
|
31
|
+
$(block $(send _ {:map :collect}) ...) :to_h) !block_literal?]
|
32
|
+
(send (const nil? :Hash) :[]
|
33
|
+
$(block $(send _ {:map :collect}) ...))
|
34
|
+
}
|
35
|
+
PATTERN
|
36
|
+
|
37
|
+
def on_send(node)
|
38
|
+
to_h_candidate?(node) do |_block, call|
|
39
|
+
range = offense_range(node, call)
|
40
|
+
message = message(node, call)
|
41
|
+
add_offense(node, location: range, message: message)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def autocorrect(node)
|
46
|
+
block, call = to_h_candidate?(node)
|
47
|
+
|
48
|
+
lambda do |corrector|
|
49
|
+
corrector.remove(after_block(node, block))
|
50
|
+
corrector.replace(call.loc.selector, 'to_h')
|
51
|
+
corrector.remove(before_block(node, block))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def offense_range(node, call)
|
58
|
+
return node.source_range if node.children.first.const_type?
|
59
|
+
|
60
|
+
range_between(call.loc.selector.begin_pos, node.loc.selector.end_pos)
|
61
|
+
end
|
62
|
+
|
63
|
+
def message(node, call)
|
64
|
+
current = if node.children.first.const_type?
|
65
|
+
"Hash[#{call.method_name} { ... }]"
|
66
|
+
else
|
67
|
+
"#{call.method_name} { ... }.to_h"
|
68
|
+
end
|
69
|
+
|
70
|
+
format(MSG, current: current)
|
71
|
+
end
|
72
|
+
|
73
|
+
def after_block(node, block)
|
74
|
+
block.source_range.end.join(node.source_range.end)
|
75
|
+
end
|
76
|
+
|
77
|
+
def before_block(node, block)
|
78
|
+
node.source_range.begin.join(block.source_range.begin)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubocop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# This cop 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::Cop
|
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
|
+
def_node_matcher :uses_open_struct?, <<-PATTERN
|
19
|
+
(const {nil? (cbase)} :OpenStruct)
|
20
|
+
PATTERN
|
21
|
+
|
22
|
+
def on_const(node)
|
23
|
+
return unless uses_open_struct?(node)
|
24
|
+
return if custom_class_or_module_definition?(node)
|
25
|
+
|
26
|
+
add_offense(node)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def custom_class_or_module_definition?(node)
|
32
|
+
parent = node.parent
|
33
|
+
|
34
|
+
(parent.class_type? || parent.module_type?) && node.left_siblings.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
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::Cop
|
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, location: :selector)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/rubocop-default.yml
CHANGED
data/rubocop-fips.yml
ADDED
data/rubocop-rspec.yml
CHANGED
@@ -95,8 +95,9 @@ RSpec/ImplicitExpect:
|
|
95
95
|
EnforcedStyle: is_expected
|
96
96
|
|
97
97
|
# Checks for the usage of instance variables.
|
98
|
+
# https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#subject-and-let-variables
|
98
99
|
RSpec/InstanceVariable:
|
99
|
-
Enabled:
|
100
|
+
Enabled: true
|
100
101
|
|
101
102
|
# Checks for `subject` definitions that come after `let` definitions.
|
102
103
|
RSpec/LeadingSubject:
|
@@ -157,4 +158,4 @@ RSpec/SubjectStub:
|
|
157
158
|
|
158
159
|
# Prefer using verifying doubles over normal doubles.
|
159
160
|
RSpec/VerifiedDoubles:
|
160
|
-
Enabled:
|
161
|
+
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:
|
4
|
+
version: 8.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:
|
11
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '2.1'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: gitlab-dangerfiles
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 2.11.0
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 2.11.0
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
name: rake
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,12 +166,14 @@ files:
|
|
152
166
|
- ".editorconfig"
|
153
167
|
- ".gitignore"
|
154
168
|
- ".gitlab-ci.yml"
|
169
|
+
- ".gitlab/changelog_config.yml"
|
155
170
|
- ".gitlab/merge_request_templates/New Static Analysis Check.md"
|
156
171
|
- ".gitlab/merge_request_templates/Release.md"
|
157
172
|
- ".rspec"
|
158
173
|
- ".rubocop.yml"
|
159
174
|
- CODE_OF_CONDUCT.md
|
160
175
|
- CONTRIBUTING.md
|
176
|
+
- Dangerfile
|
161
177
|
- Gemfile
|
162
178
|
- LICENSE.md
|
163
179
|
- README.md
|
@@ -166,40 +182,46 @@ files:
|
|
166
182
|
- bin/setup
|
167
183
|
- gitlab-styles.gemspec
|
168
184
|
- lib/gitlab/styles.rb
|
185
|
+
- lib/gitlab/styles/common/banned_constants.rb
|
169
186
|
- lib/gitlab/styles/rubocop.rb
|
170
|
-
- lib/gitlab/styles/rubocop/cop/active_record_dependent.rb
|
171
|
-
- lib/gitlab/styles/rubocop/cop/active_record_serialize.rb
|
172
|
-
- lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb
|
173
|
-
- lib/gitlab/styles/rubocop/cop/custom_error_class.rb
|
174
|
-
- lib/gitlab/styles/rubocop/cop/gem_fetcher.rb
|
175
|
-
- lib/gitlab/styles/rubocop/cop/in_batches.rb
|
176
|
-
- lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
|
177
|
-
- lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb
|
178
|
-
- lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb
|
179
|
-
- lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
|
180
|
-
- lib/gitlab/styles/rubocop/cop/performance/rubyzip.rb
|
181
|
-
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
|
182
|
-
- lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb
|
183
|
-
- lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
|
184
|
-
- lib/gitlab/styles/rubocop/cop/rspec/base.rb
|
185
|
-
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb
|
186
|
-
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_let_block.rb
|
187
|
-
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
188
|
-
- lib/gitlab/styles/rubocop/cop/rspec/example_starting_character.rb
|
189
|
-
- lib/gitlab/styles/rubocop/cop/rspec/have_link_parameters.rb
|
190
|
-
- lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb
|
191
|
-
- lib/gitlab/styles/rubocop/cop/rspec/verbose_include_metadata.rb
|
192
|
-
- lib/gitlab/styles/rubocop/cop/style/hash_transformation.rb
|
193
|
-
- lib/gitlab/styles/rubocop/cop/style/open_struct_use.rb
|
194
|
-
- lib/gitlab/styles/rubocop/cop/without_reactive_cache.rb
|
195
187
|
- lib/gitlab/styles/rubocop/migration_helpers.rb
|
196
188
|
- lib/gitlab/styles/rubocop/model_helpers.rb
|
197
189
|
- lib/gitlab/styles/rubocop/rspec/helpers.rb
|
198
190
|
- lib/gitlab/styles/version.rb
|
191
|
+
- lib/rubocop/cop/active_record_dependent.rb
|
192
|
+
- lib/rubocop/cop/active_record_serialize.rb
|
193
|
+
- lib/rubocop/cop/avoid_return_from_blocks.rb
|
194
|
+
- lib/rubocop/cop/code_reuse/active_record.rb
|
195
|
+
- lib/rubocop/cop/custom_error_class.rb
|
196
|
+
- lib/rubocop/cop/fips/md5.rb
|
197
|
+
- lib/rubocop/cop/fips/open_ssl.rb
|
198
|
+
- lib/rubocop/cop/fips/sha1.rb
|
199
|
+
- lib/rubocop/cop/gem_fetcher.rb
|
200
|
+
- lib/rubocop/cop/in_batches.rb
|
201
|
+
- lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
|
202
|
+
- lib/rubocop/cop/line_break_after_guard_clauses.rb
|
203
|
+
- lib/rubocop/cop/line_break_around_conditional_block.rb
|
204
|
+
- lib/rubocop/cop/migration/update_large_table.rb
|
205
|
+
- lib/rubocop/cop/performance/rubyzip.rb
|
206
|
+
- lib/rubocop/cop/polymorphic_associations.rb
|
207
|
+
- lib/rubocop/cop/rails/include_url_helper.rb
|
208
|
+
- lib/rubocop/cop/redirect_with_status.rb
|
209
|
+
- lib/rubocop/cop/rspec/base.rb
|
210
|
+
- lib/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb
|
211
|
+
- lib/rubocop/cop/rspec/empty_line_after_let_block.rb
|
212
|
+
- lib/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
213
|
+
- lib/rubocop/cop/rspec/example_starting_character.rb
|
214
|
+
- lib/rubocop/cop/rspec/have_link_parameters.rb
|
215
|
+
- lib/rubocop/cop/rspec/single_line_hook.rb
|
216
|
+
- lib/rubocop/cop/rspec/verbose_include_metadata.rb
|
217
|
+
- lib/rubocop/cop/style/hash_transformation.rb
|
218
|
+
- lib/rubocop/cop/style/open_struct_use.rb
|
219
|
+
- lib/rubocop/cop/without_reactive_cache.rb
|
199
220
|
- rubocop-all.yml
|
200
221
|
- rubocop-bundler.yml
|
201
222
|
- rubocop-code_reuse.yml
|
202
223
|
- rubocop-default.yml
|
224
|
+
- rubocop-fips.yml
|
203
225
|
- rubocop-gemspec.yml
|
204
226
|
- rubocop-graphql.yml
|
205
227
|
- rubocop-layout.yml
|
@@ -1,32 +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
|
-
|
18
|
-
def on_send(node)
|
19
|
-
return unless in_model?(node)
|
20
|
-
return unless METHOD_NAMES.include?(node.children[1])
|
21
|
-
|
22
|
-
node.children.last.each_node(:pair) do |pair|
|
23
|
-
key_name = pair.children[0].children[0]
|
24
|
-
|
25
|
-
add_offense(pair) if key_name == :dependent
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
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
|