gitlab-styles 4.3.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +18 -0
- data/Gemfile +2 -2
- data/gitlab-styles.gemspec +5 -4
- data/lib/gitlab/styles/rubocop.rb +1 -0
- data/lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb +131 -0
- data/lib/gitlab/styles/rubocop/cop/rspec/base.rb +18 -0
- data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_let_block.rb +7 -7
- data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb +6 -6
- data/lib/gitlab/styles/rubocop/cop/rspec/have_link_parameters.rb +10 -5
- data/lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb +3 -2
- data/lib/gitlab/styles/rubocop/cop/rspec/verbose_include_metadata.rb +10 -13
- data/lib/gitlab/styles/rubocop/model_helpers.rb +1 -1
- data/lib/gitlab/styles/rubocop/rspec/helpers.rb +17 -0
- data/lib/gitlab/styles/version.rb +1 -1
- data/rubocop-all.yml +1 -0
- data/rubocop-bundler.yml +1 -0
- data/rubocop-code_reuse.yml +24 -0
- data/rubocop-default.yml +1 -0
- data/rubocop-gemspec.yml +1 -0
- data/rubocop-layout.yml +6 -0
- data/rubocop-lint.yml +63 -5
- data/rubocop-metrics.yml +1 -0
- data/rubocop-migrations.yml +1 -0
- data/rubocop-naming.yml +1 -0
- data/rubocop-performance.yml +48 -0
- data/rubocop-rails.yml +79 -0
- data/rubocop-rspec.yml +6 -0
- data/rubocop-security.yml +1 -0
- data/rubocop-style.yml +90 -1
- metadata +16 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f34644596ecbfd782a8a8d5781251743cbe2f0ef079467416c4e15c784769693
|
4
|
+
data.tar.gz: 531fb802e1a50564fbbfad34e96f66b8a2227e6c182999750a39456f2ae17c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a4036572db91754b18045e0e9ec40d9747a633773c49fb3edcdc53d0ac8b6ae2743f94ffe5fc2ce6cc8a60a51216eb7b85c89dfb039f747370cca4831c9cc41
|
7
|
+
data.tar.gz: 78eb2aaec9c221dad33fb99c719c3ad838a39f4978381b2f99ef011f87c8c8ee67a24d9b6e26af2eea4d1b3a03e03e80aab5c2718afaa998764a3cf68d8153e4
|
data/.editorconfig
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# top-most EditorConfig file
|
2
|
+
root = true
|
3
|
+
|
4
|
+
# Unix-style newlines with a newline ending every file
|
5
|
+
[*]
|
6
|
+
end_of_line = lf
|
7
|
+
trim_trailing_whitespace = true
|
8
|
+
insert_final_newline = true
|
9
|
+
|
10
|
+
[*.{rb,yml}]
|
11
|
+
indent_size = 2
|
12
|
+
|
13
|
+
[*.{rb,yml,md}]
|
14
|
+
indent_style = space
|
15
|
+
charset = utf-8
|
16
|
+
|
17
|
+
[*.{md,markdown}]
|
18
|
+
trim_trailing_whitespace = false
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ gemspec
|
|
7
7
|
|
8
8
|
group :test do
|
9
9
|
# Pin these dependencies, otherwise a new rule could break the CI pipelines
|
10
|
-
gem 'rubocop', '0.
|
11
|
-
gem 'rubocop-rspec', '1.
|
10
|
+
gem 'rubocop', '0.89.1'
|
11
|
+
gem 'rubocop-rspec', '1.44.1'
|
12
12
|
gem 'rspec-parameterized', '0.4.2', require: false
|
13
13
|
end
|
data/gitlab-styles.gemspec
CHANGED
@@ -5,6 +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 = '>= 2.6'
|
8
9
|
spec.name = 'gitlab-styles'
|
9
10
|
spec.version = Gitlab::Styles::VERSION
|
10
11
|
spec.authors = ['GitLab']
|
@@ -21,11 +22,11 @@ Gem::Specification.new do |spec|
|
|
21
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
23
|
spec.require_paths = ['lib']
|
23
24
|
|
24
|
-
spec.add_dependency 'rubocop', '~> 0.
|
25
|
+
spec.add_dependency 'rubocop', '~> 0.89.1'
|
25
26
|
spec.add_dependency 'rubocop-gitlab-security', '~> 0.1.0'
|
26
|
-
spec.add_dependency 'rubocop-performance', '~> 1.
|
27
|
-
spec.add_dependency 'rubocop-rails', '~> 2.
|
28
|
-
spec.add_dependency 'rubocop-rspec', '~> 1.
|
27
|
+
spec.add_dependency 'rubocop-performance', '~> 1.8.1'
|
28
|
+
spec.add_dependency 'rubocop-rails', '~> 2.8'
|
29
|
+
spec.add_dependency 'rubocop-rspec', '~> 1.44'
|
29
30
|
|
30
31
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
31
32
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -8,6 +8,7 @@ require 'gitlab/styles/rubocop/cop/polymorphic_associations'
|
|
8
8
|
require 'gitlab/styles/rubocop/cop/active_record_dependent'
|
9
9
|
require 'gitlab/styles/rubocop/cop/in_batches'
|
10
10
|
require 'gitlab/styles/rubocop/cop/line_break_after_guard_clauses'
|
11
|
+
require 'gitlab/styles/rubocop/cop/code_reuse/active_record'
|
11
12
|
require 'gitlab/styles/rubocop/cop/migration/update_large_table'
|
12
13
|
require 'gitlab/styles/rubocop/cop/without_reactive_cache'
|
13
14
|
require 'gitlab/styles/rubocop/cop/rspec/single_line_hook'
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Styles
|
5
|
+
module Rubocop
|
6
|
+
module Cop
|
7
|
+
module CodeReuse
|
8
|
+
# Cop that denies the use of ActiveRecord methods outside of models.
|
9
|
+
class ActiveRecord < RuboCop::Cop::Cop
|
10
|
+
MSG = 'This method can only be used inside an ActiveRecord model: ' \
|
11
|
+
'https://gitlab.com/gitlab-org/gitlab-foss/issues/49653'
|
12
|
+
|
13
|
+
# Various methods from ActiveRecord::Querying that are denied. We
|
14
|
+
# exclude some generic ones such as `any?` and `first`, as these may
|
15
|
+
# lead to too many false positives, since `Array` also supports these
|
16
|
+
# methods.
|
17
|
+
#
|
18
|
+
# The keys of this Hash are the denied method names. The values are
|
19
|
+
# booleans that indicate if the method should only be denied if any
|
20
|
+
# arguments are provided.
|
21
|
+
NOT_ALLOWED = {
|
22
|
+
average: true,
|
23
|
+
calculate: true,
|
24
|
+
count_by_sql: true,
|
25
|
+
create_with: true,
|
26
|
+
distinct: false,
|
27
|
+
eager_load: true,
|
28
|
+
exists?: true,
|
29
|
+
find_by: true,
|
30
|
+
find_by!: true,
|
31
|
+
find_by_sql: true,
|
32
|
+
find_each: true,
|
33
|
+
find_in_batches: true,
|
34
|
+
find_or_create_by: true,
|
35
|
+
find_or_create_by!: true,
|
36
|
+
find_or_initialize_by: true,
|
37
|
+
first!: false,
|
38
|
+
first_or_create: true,
|
39
|
+
first_or_create!: true,
|
40
|
+
first_or_initialize: true,
|
41
|
+
from: true,
|
42
|
+
group: true,
|
43
|
+
having: true,
|
44
|
+
ids: false,
|
45
|
+
includes: true,
|
46
|
+
joins: true,
|
47
|
+
limit: true,
|
48
|
+
lock: false,
|
49
|
+
many?: false,
|
50
|
+
offset: true,
|
51
|
+
order: true,
|
52
|
+
pluck: true,
|
53
|
+
preload: true,
|
54
|
+
readonly: false,
|
55
|
+
references: true,
|
56
|
+
reorder: true,
|
57
|
+
rewhere: true,
|
58
|
+
take: false,
|
59
|
+
take!: false,
|
60
|
+
unscope: false,
|
61
|
+
where: false,
|
62
|
+
with: true
|
63
|
+
}.freeze
|
64
|
+
|
65
|
+
def on_send(node)
|
66
|
+
receiver = node.children[0]
|
67
|
+
send_name = node.children[1]
|
68
|
+
first_arg = node.children[2]
|
69
|
+
|
70
|
+
return unless receiver && NOT_ALLOWED.key?(send_name)
|
71
|
+
|
72
|
+
# If the rule requires an argument to be given, but none are
|
73
|
+
# provided, we won't register an offense. This prevents us from
|
74
|
+
# adding offenses for `project.group`, while still covering
|
75
|
+
# `Project.group(:name)`.
|
76
|
+
return if NOT_ALLOWED[send_name] && !first_arg
|
77
|
+
|
78
|
+
add_offense(node, location: :selector)
|
79
|
+
end
|
80
|
+
|
81
|
+
# We can not auto correct code like this, as it requires manual
|
82
|
+
# refactoring. Instead, we'll just allow the surrounding scope.
|
83
|
+
#
|
84
|
+
# Despite this method's presence, you should not use it. This method
|
85
|
+
# exists to make it possible to allow large chunks of offenses we
|
86
|
+
# can't fix in the short term. If you are writing new code, follow the
|
87
|
+
# code reuse guidelines, instead of allowing any new offenses.
|
88
|
+
def autocorrect(node)
|
89
|
+
scope = surrounding_scope_of(node)
|
90
|
+
indent = indentation_of(scope)
|
91
|
+
|
92
|
+
lambda do |corrector|
|
93
|
+
# This prevents us from inserting the same enable/disable comment
|
94
|
+
# for a method or block that has multiple offenses.
|
95
|
+
next if allowed_scopes.include?(scope)
|
96
|
+
|
97
|
+
corrector.insert_before(
|
98
|
+
scope.source_range,
|
99
|
+
"# rubocop: disable #{cop_name}\n#{indent}"
|
100
|
+
)
|
101
|
+
|
102
|
+
corrector.insert_after(
|
103
|
+
scope.source_range,
|
104
|
+
"\n#{indent}# rubocop: enable #{cop_name}"
|
105
|
+
)
|
106
|
+
|
107
|
+
allowed_scopes << scope
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def indentation_of(node)
|
112
|
+
' ' * node.loc.expression.source_line[/\A */].length
|
113
|
+
end
|
114
|
+
|
115
|
+
def surrounding_scope_of(node)
|
116
|
+
%i[def defs block begin].each do |type|
|
117
|
+
if (found = node.each_ancestor(type).first)
|
118
|
+
return found
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def allowed_scopes
|
124
|
+
@allowed_scopes ||= Set.new
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop-rspec'
|
4
|
+
require_relative '../../rspec/helpers'
|
5
|
+
|
6
|
+
module Gitlab
|
7
|
+
module Styles
|
8
|
+
module Rubocop
|
9
|
+
module Cop
|
10
|
+
module RSpec
|
11
|
+
class Base < RuboCop::Cop::RSpec::Base
|
12
|
+
include Rubocop::Rspec::Helpers
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubocop-rspec'
|
4
|
+
require_relative 'base'
|
4
5
|
|
5
6
|
module Gitlab
|
6
7
|
module Styles
|
@@ -38,22 +39,21 @@ module Gitlab
|
|
38
39
|
# let(:last_thing) { 'last thing' }
|
39
40
|
# end
|
40
41
|
#
|
41
|
-
class EmptyLineAfterLetBlock <
|
42
|
-
|
42
|
+
class EmptyLineAfterLetBlock < Base
|
43
|
+
extend RuboCop::Cop::AutoCorrector
|
44
|
+
include RuboCop::RSpec::EmptyLineSeparation
|
43
45
|
|
44
46
|
MSG = 'Add an empty line after `%<let>s` block.'
|
45
47
|
|
46
|
-
def_node_matcher :lets,
|
48
|
+
def_node_matcher :lets, LET.block_pattern
|
47
49
|
|
48
50
|
def on_block(node)
|
49
51
|
lets(node) do
|
50
52
|
break if last_child?(node)
|
51
53
|
next if node.single_line?
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
location: location,
|
56
|
-
message: format(MSG, let: node.method_name))
|
55
|
+
missing_separating_line_offense(node) do |method|
|
56
|
+
format(MSG, let: method)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubocop-rspec'
|
4
|
+
require_relative 'base'
|
4
5
|
|
5
6
|
module Gitlab
|
6
7
|
module Styles
|
@@ -38,8 +39,9 @@ module Gitlab
|
|
38
39
|
# it_behaves_like 'does this'
|
39
40
|
# end
|
40
41
|
#
|
41
|
-
class EmptyLineAfterSharedExample <
|
42
|
-
|
42
|
+
class EmptyLineAfterSharedExample < Base
|
43
|
+
extend RuboCop::Cop::AutoCorrector
|
44
|
+
include RuboCop::RSpec::EmptyLineSeparation
|
43
45
|
|
44
46
|
MSG = 'Add an empty line after `%<example>s` block.'
|
45
47
|
|
@@ -50,10 +52,8 @@ module Gitlab
|
|
50
52
|
shared_examples(node) do
|
51
53
|
break if last_child?(node)
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
location: location,
|
56
|
-
message: format(MSG, example: node.method_name))
|
55
|
+
missing_separating_line_offense(node) do |method|
|
56
|
+
format(MSG, example: method)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubocop-rspec'
|
4
|
+
require_relative 'base'
|
4
5
|
|
5
6
|
module Gitlab
|
6
7
|
module Styles
|
@@ -17,7 +18,9 @@ module Gitlab
|
|
17
18
|
# # good
|
18
19
|
# expect(page).to have_link('Link', href: 'https://example.com')
|
19
20
|
# expect(page).to have_link('Example')
|
20
|
-
class HaveLinkParameters <
|
21
|
+
class HaveLinkParameters < Base
|
22
|
+
extend RuboCop::Cop::AutoCorrector
|
23
|
+
|
21
24
|
MESSAGE = "The second argument to `have_link` should be a Hash."
|
22
25
|
|
23
26
|
def_node_matcher :unused_parameters?, <<~PATTERN
|
@@ -29,11 +32,13 @@ module Gitlab
|
|
29
32
|
def on_send(node)
|
30
33
|
return unless unused_parameters?(node)
|
31
34
|
|
32
|
-
location = node.arguments[1
|
33
|
-
|
34
|
-
|
35
|
+
location = node.arguments[1..]
|
36
|
+
.map(&:source_range)
|
37
|
+
.reduce(:join)
|
35
38
|
|
36
|
-
add_offense(
|
39
|
+
add_offense(location, message: MESSAGE) do |corrector|
|
40
|
+
corrector.insert_after(location.end, "\n")
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubocop-rspec'
|
4
|
+
require_relative 'base'
|
4
5
|
|
5
6
|
module Gitlab
|
6
7
|
module Styles
|
@@ -23,7 +24,7 @@ module Gitlab
|
|
23
24
|
# after(:each) do
|
24
25
|
# undo_something
|
25
26
|
# end
|
26
|
-
class SingleLineHook <
|
27
|
+
class SingleLineHook < Base
|
27
28
|
MESSAGE = "Don't use single-line hook blocks."
|
28
29
|
|
29
30
|
def_node_search :rspec_hook?, <<~PATTERN
|
@@ -34,7 +35,7 @@ module Gitlab
|
|
34
35
|
return unless node.single_line?
|
35
36
|
return unless rspec_hook?(node)
|
36
37
|
|
37
|
-
add_offense(node,
|
38
|
+
add_offense(node, message: MESSAGE)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubocop-rspec'
|
4
|
+
require_relative 'base'
|
4
5
|
|
5
6
|
module Gitlab
|
6
7
|
module Styles
|
@@ -17,7 +18,9 @@ module Gitlab
|
|
17
18
|
# # good
|
18
19
|
# describe MyClass, :js do
|
19
20
|
# end
|
20
|
-
class VerboseIncludeMetadata <
|
21
|
+
class VerboseIncludeMetadata < Base
|
22
|
+
extend RuboCop::Cop::AutoCorrector
|
23
|
+
|
21
24
|
MSG = 'Use `%s` instead of `%s`.'
|
22
25
|
|
23
26
|
SELECTORS = %i[describe context feature example_group it specify example scenario its].freeze
|
@@ -37,25 +40,19 @@ module Gitlab
|
|
37
40
|
|
38
41
|
def on_send(node)
|
39
42
|
invalid_metadata_matches(node) do |match|
|
40
|
-
add_offense(node,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def autocorrect(node)
|
45
|
-
lambda do |corrector|
|
46
|
-
invalid_metadata_matches(node) do |match|
|
47
|
-
corrector.replace(match.loc.expression, good(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
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
51
|
private
|
53
52
|
|
54
|
-
def invalid_metadata_matches(node)
|
53
|
+
def invalid_metadata_matches(node, &block)
|
55
54
|
include_metadata(node) do |matches|
|
56
|
-
matches.select(&method(:invalid_metadata?)).each
|
57
|
-
yield match
|
58
|
-
end
|
55
|
+
matches.select(&method(:invalid_metadata?)).each(&block)
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
@@ -7,7 +7,7 @@ module Gitlab
|
|
7
7
|
# Returns true if the given node originated from the models directory.
|
8
8
|
def in_model?(node)
|
9
9
|
path = node.location.expression.source_buffer.name
|
10
|
-
pwd =
|
10
|
+
pwd = Dir.pwd
|
11
11
|
models_path = File.join(pwd, 'app', 'models')
|
12
12
|
ee_models_path = File.join(pwd, 'ee', 'app', 'models')
|
13
13
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop-rspec'
|
4
|
+
|
5
|
+
module Gitlab
|
6
|
+
module Styles
|
7
|
+
module Rubocop
|
8
|
+
module Rspec
|
9
|
+
module Helpers
|
10
|
+
include RuboCop::RSpec::Language
|
11
|
+
|
12
|
+
LET = SelectorSet.new(%i[let_it_be]) + Helpers::ALL
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/rubocop-all.yml
CHANGED
data/rubocop-bundler.yml
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Denies the use of ActiveRecord methods outside of configured
|
2
|
+
# excluded directories
|
3
|
+
# Directories that allow the use of the denied methods.
|
4
|
+
# To start we provide a default configuration that matches
|
5
|
+
# a standard Rails app and enable.
|
6
|
+
# The default configuration can be overridden by
|
7
|
+
# providing your own Exclusion list as follows:
|
8
|
+
# CodeReuse/ActiveRecord:
|
9
|
+
# Enabled: true
|
10
|
+
# Exclude:
|
11
|
+
# - app/models/**/*.rb
|
12
|
+
# - config/**/*.rb
|
13
|
+
# - db/**/*.rb
|
14
|
+
# - lib/tasks/**/*.rb
|
15
|
+
# - spec/**/*.rb
|
16
|
+
# - lib/gitlab/**/*.rb
|
17
|
+
CodeReuse/ActiveRecord:
|
18
|
+
Enabled: true
|
19
|
+
Exclude:
|
20
|
+
- app/models/**/*.rb
|
21
|
+
- config/**/*.rb
|
22
|
+
- db/**/*.rb
|
23
|
+
- lib/tasks/**/*.rb
|
24
|
+
- spec/**/*.rb
|
data/rubocop-default.yml
CHANGED
data/rubocop-gemspec.yml
CHANGED
data/rubocop-layout.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
---
|
1
2
|
# Check indentation of private/protected visibility modifiers.
|
2
3
|
Layout/AccessModifierIndentation:
|
3
4
|
Enabled: true
|
@@ -60,6 +61,11 @@ Layout/EmptyLines:
|
|
60
61
|
Layout/EmptyLinesAroundAccessModifier:
|
61
62
|
Enabled: true
|
62
63
|
|
64
|
+
# Checks for a newline after an attribute accessor or a group of them
|
65
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_layout.html#layoutemptylinesaroundattributeaccessor
|
66
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
67
|
+
Enabled: true
|
68
|
+
|
63
69
|
# Keeps track of empty lines around block bodies.
|
64
70
|
Layout/EmptyLinesAroundBlockBody:
|
65
71
|
Enabled: true
|
data/rubocop-lint.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
---
|
1
2
|
# Checks for ambiguous block association with method when param passed without
|
2
3
|
# parentheses.
|
3
4
|
Lint/AmbiguousBlockAssociation:
|
@@ -18,6 +19,10 @@ Lint/AmbiguousRegexpLiteral:
|
|
18
19
|
Lint/AssignmentInCondition:
|
19
20
|
Enabled: false
|
20
21
|
|
22
|
+
# Checks for places where binary operator has identical operands
|
23
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
24
|
+
Enabled: true
|
25
|
+
|
21
26
|
# Default values in optional keyword arguments and optional ordinal arguments
|
22
27
|
# should not refer back to the name of the argument.
|
23
28
|
Lint/CircularArgumentReference:
|
@@ -31,6 +36,22 @@ Lint/Debugger:
|
|
31
36
|
Lint/DeprecatedClassMethods:
|
32
37
|
Enabled: true
|
33
38
|
|
39
|
+
# Algorithmic constants for OpenSSL::Cipher and OpenSSL::Digest deprecated since OpenSSL version 2.2.0.
|
40
|
+
# Prefer passing a string instead.
|
41
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintdeprecatedopensslconstant
|
42
|
+
Lint/DeprecatedOpenSSLConstant:
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
# Checks that there are no repeated conditions used in if 'elsif'.
|
46
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintduplicateelsifcondition
|
47
|
+
Lint/DuplicateElsifCondition:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
# Checks that there are no repeated exceptions used in 'rescue' expressions.
|
51
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintduplicaterescueexception
|
52
|
+
Lint/DuplicateRescueException:
|
53
|
+
Enabled: true
|
54
|
+
|
34
55
|
# Check for immutable argument given to each_with_object.
|
35
56
|
Lint/EachWithObjectArgument:
|
36
57
|
Enabled: true
|
@@ -39,6 +60,11 @@ Lint/EachWithObjectArgument:
|
|
39
60
|
Lint/ElseLayout:
|
40
61
|
Enabled: true
|
41
62
|
|
63
|
+
# Checks for the presence of if, elsif and unless branches without a body.
|
64
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintemptyconditionalbody
|
65
|
+
Lint/EmptyConditionalBody:
|
66
|
+
Enabled: true
|
67
|
+
|
42
68
|
# Checks for empty ensure block.
|
43
69
|
Lint/EmptyEnsure:
|
44
70
|
Enabled: true
|
@@ -55,6 +81,11 @@ Lint/EnsureReturn:
|
|
55
81
|
Lint/FlipFlop:
|
56
82
|
Enabled: true
|
57
83
|
|
84
|
+
# Checks for the presence of precise comparison of floating point numbers.
|
85
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintfloatcomparison
|
86
|
+
Lint/FloatComparison:
|
87
|
+
Enabled: true
|
88
|
+
|
58
89
|
# Catches floating-point literals too large or small for Ruby to represent.
|
59
90
|
Lint/FloatOutOfRange:
|
60
91
|
Enabled: true
|
@@ -81,10 +112,21 @@ Lint/LiteralAsCondition:
|
|
81
112
|
Lint/LiteralInInterpolation:
|
82
113
|
Enabled: true
|
83
114
|
|
84
|
-
#
|
115
|
+
# Checks for uses of *begin...end while/until something*.
|
85
116
|
Lint/Loop:
|
86
117
|
Enabled: false
|
87
118
|
|
119
|
+
# Checks for the presence of constructors and lifecycle callbacks without calls to super.
|
120
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintmissingsuper
|
121
|
+
Lint/MissingSuper:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
# Do not mix named captures and numbered captures in a Regexp literal
|
125
|
+
# because numbered capture is ignored if they’re mixed.
|
126
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintmixedregexpcapturetypes
|
127
|
+
Lint/MixedRegexpCaptureTypes:
|
128
|
+
Enabled: true
|
129
|
+
|
88
130
|
# Do not use nested method definitions.
|
89
131
|
Lint/NestedMethodDefinition:
|
90
132
|
Enabled: true
|
@@ -93,6 +135,11 @@ Lint/NestedMethodDefinition:
|
|
93
135
|
Lint/NextWithoutAccumulator:
|
94
136
|
Enabled: true
|
95
137
|
|
138
|
+
# Looks for references of Regexp captures that are out of range and thus always returns nil.
|
139
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintoutofrangeregexpref
|
140
|
+
Lint/OutOfRangeRegexpRef:
|
141
|
+
Enabled: true
|
142
|
+
|
96
143
|
# Checks for method calls with a space before the opening parenthesis.
|
97
144
|
Lint/ParenthesesAsGroupedExpression:
|
98
145
|
Enabled: true
|
@@ -126,6 +173,11 @@ Lint/RescueException:
|
|
126
173
|
Lint/SafeNavigationWithEmpty:
|
127
174
|
Enabled: true
|
128
175
|
|
176
|
+
# Checks for self-assignments.
|
177
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintselfassignment
|
178
|
+
Lint/SelfAssignment:
|
179
|
+
Enabled: true
|
180
|
+
|
129
181
|
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
|
130
182
|
Lint/ShadowedException:
|
131
183
|
Enabled: false
|
@@ -143,6 +195,11 @@ Lint/StructNewOverride:
|
|
143
195
|
Lint/SuppressedException:
|
144
196
|
Enabled: false
|
145
197
|
|
198
|
+
# Checks for top level return with arguments.
|
199
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#linttoplevelreturnwithargument
|
200
|
+
Lint/TopLevelReturnWithArgument:
|
201
|
+
Enabled: true
|
202
|
+
|
146
203
|
# Do not use prefix `_` for a variable that is used.
|
147
204
|
Lint/UnderscorePrefixedVariableName:
|
148
205
|
Enabled: true
|
@@ -155,6 +212,11 @@ Lint/UnifiedInteger:
|
|
155
212
|
Lint/UnreachableCode:
|
156
213
|
Enabled: true
|
157
214
|
|
215
|
+
# Checks for loops that will have at most one iteration.
|
216
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_lint.html#lintunreachableloop
|
217
|
+
Lint/UnreachableLoop:
|
218
|
+
Enabled: true
|
219
|
+
|
158
220
|
# This cop checks for unused block arguments.
|
159
221
|
Lint/UnusedBlockArgument:
|
160
222
|
Enabled: false
|
@@ -172,10 +234,6 @@ Lint/UselessAccessModifier:
|
|
172
234
|
Lint/UselessAssignment:
|
173
235
|
Enabled: true
|
174
236
|
|
175
|
-
# Checks for comparison of something with itself.
|
176
|
-
Lint/UselessComparison:
|
177
|
-
Enabled: true
|
178
|
-
|
179
237
|
# Checks for useless `else` in `begin..end` without `rescue`.
|
180
238
|
Lint/UselessElseWithoutRescue:
|
181
239
|
Enabled: true
|
data/rubocop-metrics.yml
CHANGED
data/rubocop-migrations.yml
CHANGED
data/rubocop-naming.yml
CHANGED
data/rubocop-performance.yml
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
---
|
2
|
+
# Used to identify usages of ancestors.include? and change them to use ⇐ instead.
|
3
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performanceancestorsinclude
|
4
|
+
Performance/AncestorsInclude:
|
5
|
+
Enabled: true
|
6
|
+
|
7
|
+
# Identifies places where numeric argument to BigDecimal should be converted to string.
|
8
|
+
# Initializing from String is faster than from Numeric for BigDecimal.
|
9
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancebigdecimalwithnumericargument
|
10
|
+
Performance/BigDecimalWithNumericArgument:
|
11
|
+
Enabled: true
|
12
|
+
|
1
13
|
# Use `caller(n..n)` instead of `caller`.
|
2
14
|
Performance/Caller:
|
3
15
|
Enabled: false
|
@@ -31,17 +43,53 @@ Performance/RedundantMerge:
|
|
31
43
|
Enabled: true
|
32
44
|
MaxKeyValuePairs: 1
|
33
45
|
|
46
|
+
# Identifies places where sort { |a, b| a <=> b } can be replaced with sort.
|
47
|
+
# https://docs.rubocop.org/rubocop-performance/1.7/cops_performance.html#performanceredundantsortblock
|
48
|
+
Performance/RedundantSortBlock:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
# Checks for redundant String#chars.
|
52
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performanceredundantstringchars
|
53
|
+
Performance/RedundantStringChars:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
# Identifies places where reverse.first(n) and reverse.first can be replaced by last(n).reverse and last.
|
57
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancereversefirst
|
58
|
+
Performance/ReverseFirst:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
# Identifies places where sort { |a, b| b <=> a } can be replaced by a faster sort.reverse.
|
62
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancesortreverse
|
63
|
+
Performance/SortReverse:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
# Identifies places where gsub(/a+/, 'a') and gsub!(/a+/, 'a') can be replaced by squeeze('a') and squeeze!('a').
|
67
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancesqueeze
|
68
|
+
Performance/Squeeze:
|
69
|
+
Enabled: true
|
70
|
+
|
34
71
|
# Use `start_with?` instead of a regex match anchored to the beginning of a
|
35
72
|
# string.
|
36
73
|
Performance/StartWith:
|
37
74
|
Enabled: true
|
38
75
|
|
76
|
+
# Identifies unnecessary use of a regex where String#include? would suffice.
|
77
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancestringinclude
|
78
|
+
Performance/StringInclude:
|
79
|
+
Enabled: true
|
80
|
+
|
39
81
|
# Use `tr` instead of `gsub` when you are replacing the same number of
|
40
82
|
# characters. Use `delete` instead of `gsub` when you are deleting
|
41
83
|
# characters.
|
42
84
|
Performance/StringReplacement:
|
43
85
|
Enabled: true
|
44
86
|
|
87
|
+
# Identifies places where custom code finding the sum of elements in some
|
88
|
+
# Enumerable object can be replaced by Enumerable#sum method.
|
89
|
+
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancesum
|
90
|
+
Performance/Sum:
|
91
|
+
Enabled: true
|
92
|
+
|
45
93
|
# Checks for `.times.map` calls.
|
46
94
|
Performance/TimesMap:
|
47
95
|
Enabled: true
|
data/rubocop-rails.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
---
|
1
2
|
# Enables Rails cops.
|
2
3
|
Rails:
|
3
4
|
Enabled: true
|
@@ -7,6 +8,18 @@ Rails/ActionFilter:
|
|
7
8
|
Enabled: true
|
8
9
|
EnforcedStyle: action
|
9
10
|
|
11
|
+
# Checks that Active Record callbacks are declared in the order in which they will be executed.
|
12
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsactiverecordcallbacksorder
|
13
|
+
Rails/ActiveRecordCallbacksOrder:
|
14
|
+
Enabled: true
|
15
|
+
|
16
|
+
# Enforces that there is only one call to after_commit
|
17
|
+
# (and its aliases - after_create_commit, after_update_commit, and after_destroy_commit)
|
18
|
+
# with the same callback name per model.
|
19
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsaftercommitoverride
|
20
|
+
Rails/AfterCommitOverride:
|
21
|
+
Enabled: true
|
22
|
+
|
10
23
|
# Check that models subclass ApplicationRecord.
|
11
24
|
Rails/ApplicationRecord:
|
12
25
|
Enabled: false
|
@@ -43,6 +56,12 @@ Rails/FindBy:
|
|
43
56
|
- 'app/**/*.rb'
|
44
57
|
- 'lib/**/*.rb'
|
45
58
|
|
59
|
+
# Enforces that ActiveRecord#find is used instead of where.take!, find_by!, and find_by_id!
|
60
|
+
# to retrieve a single record by primary key when you expect it to be found.
|
61
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsfindbyid
|
62
|
+
Rails/FindById:
|
63
|
+
Enabled: true
|
64
|
+
|
46
65
|
# Prefer `all.find_each` over `all.find`.
|
47
66
|
Rails/FindEach:
|
48
67
|
Enabled: true
|
@@ -57,6 +76,26 @@ Rails/HasAndBelongsToMany:
|
|
57
76
|
Rails/HttpPositionalArguments:
|
58
77
|
Enabled: true
|
59
78
|
|
79
|
+
# Checks that Active Support’s inquiry method is not used.
|
80
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsinquiry
|
81
|
+
Rails/Inquiry:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
# Enforces that mailer names end with Mailer suffix.
|
85
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsmailername
|
86
|
+
Rails/MailerName:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
# Identifies places where defining routes with match can be replaced with a specific HTTP method.
|
90
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsmatchroute
|
91
|
+
Rails/MatchRoute:
|
92
|
+
Enabled: true
|
93
|
+
|
94
|
+
# Enforces the use of collection.exclude?(obj) over !collection.include?(obj).
|
95
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsnegateinclude
|
96
|
+
Rails/NegateInclude:
|
97
|
+
Enabled: true
|
98
|
+
|
60
99
|
# Checks for calls to puts, print, etc.
|
61
100
|
Rails/Output:
|
62
101
|
Enabled: true
|
@@ -71,6 +110,16 @@ Rails/Output:
|
|
71
110
|
Rails/OutputSafety:
|
72
111
|
Enabled: false
|
73
112
|
|
113
|
+
# Enforces the use of pluck over map.
|
114
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railspluck
|
115
|
+
Rails/Pluck:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
# Identifies places where pluck is used in where query methods and can be replaced with select.
|
119
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railspluckinwhere
|
120
|
+
Rails/PluckInWhere:
|
121
|
+
Enabled: true
|
122
|
+
|
74
123
|
# Checks for incorrect grammar when using methods like `3.day.ago`.
|
75
124
|
Rails/PluralizationGrammar:
|
76
125
|
Enabled: true
|
@@ -87,10 +136,30 @@ Rails/ReadWriteAttribute:
|
|
87
136
|
Rails/RelativeDateConstant:
|
88
137
|
Enabled: false
|
89
138
|
|
139
|
+
# Looks for inline rendering within controller actions.
|
140
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsrenderinline
|
141
|
+
Rails/RenderInline:
|
142
|
+
Enabled: true
|
143
|
+
|
144
|
+
# Identifies places where render text: can be replaced with render plain:.
|
145
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsrenderplaintext
|
146
|
+
Rails/RenderPlainText:
|
147
|
+
Enabled: true
|
148
|
+
|
90
149
|
# Checks the arguments of ActiveRecord scopes.
|
91
150
|
Rails/ScopeArgs:
|
92
151
|
Enabled: true
|
93
152
|
|
153
|
+
# Enforces that short forms of I18n methods are used: t instead of translate and l instead of localize.
|
154
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railsshorti18n
|
155
|
+
Rails/ShortI18n:
|
156
|
+
Enabled: true
|
157
|
+
|
158
|
+
# Checks SQL heredocs to use .squish.
|
159
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railssquishedsqlheredocs
|
160
|
+
Rails/SquishedSQLHeredocs:
|
161
|
+
Enabled: true
|
162
|
+
|
94
163
|
# This cop checks for the use of Time methods without zone.
|
95
164
|
Rails/TimeZone:
|
96
165
|
Enabled: false
|
@@ -98,3 +167,13 @@ Rails/TimeZone:
|
|
98
167
|
# This cop checks for the use of old-style attribute validation macros.
|
99
168
|
Rails/Validation:
|
100
169
|
Enabled: true
|
170
|
+
|
171
|
+
# Enforces consistent style when using exists?.
|
172
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railswhereexists
|
173
|
+
Rails/WhereExists:
|
174
|
+
Enabled: true
|
175
|
+
|
176
|
+
# Identifies places where manually constructed SQL in where can be replaced with where.not(...).
|
177
|
+
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railswherenot
|
178
|
+
Rails/WhereNot:
|
179
|
+
Enabled: true
|
data/rubocop-rspec.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
---
|
1
2
|
# Check that instances are not being stubbed globally.
|
2
3
|
RSpec/AnyInstance:
|
3
4
|
Enabled: false
|
@@ -142,6 +143,11 @@ RSpec/SingleLineHook:
|
|
142
143
|
- 'spec/factories/*'
|
143
144
|
- 'spec/requests/api/v3/*'
|
144
145
|
|
146
|
+
# Checks that message expectations do not have a configured response.
|
147
|
+
# https://docs.rubocop.org/rubocop-rspec/1.44/cops_rspec.html#rspecstubbedmock
|
148
|
+
RSpec/StubbedMock:
|
149
|
+
Enabled: false
|
150
|
+
|
145
151
|
# Checks for stubbed test subjects.
|
146
152
|
RSpec/SubjectStub:
|
147
153
|
Enabled: false
|
data/rubocop-security.yml
CHANGED
data/rubocop-style.yml
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
---
|
2
|
+
# Checks for grouping of accessors in class and module bodies.
|
3
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleaccessorgrouping
|
4
|
+
Style/AccessorGrouping:
|
5
|
+
Enabled: true
|
6
|
+
|
1
7
|
# Use alias_method instead of alias.
|
2
8
|
Style/Alias:
|
3
9
|
EnforcedStyle: prefer_alias_method
|
@@ -8,6 +14,11 @@ Style/Alias:
|
|
8
14
|
Style/AndOr:
|
9
15
|
Enabled: true
|
10
16
|
|
17
|
+
# Enforces the use of Array() instead of explicit Array check or [*var]
|
18
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylearraycoercion
|
19
|
+
Style/ArrayCoercion:
|
20
|
+
Enabled: true
|
21
|
+
|
11
22
|
# Use `Array#join` instead of `Array#*`.
|
12
23
|
Style/ArrayJoin:
|
13
24
|
Enabled: true
|
@@ -24,6 +35,11 @@ Style/Attr:
|
|
24
35
|
Style/BeginBlock:
|
25
36
|
Enabled: true
|
26
37
|
|
38
|
+
# Checks for places where attr_reader and attr_writer for the same method can be combined into single attr_accessor.
|
39
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylebisectedattraccessor
|
40
|
+
Style/BisectedAttrAccessor:
|
41
|
+
Enabled: true
|
42
|
+
|
27
43
|
# Do not use block comments.
|
28
44
|
Style/BlockComments:
|
29
45
|
Enabled: true
|
@@ -33,10 +49,15 @@ Style/BlockComments:
|
|
33
49
|
Style/BlockDelimiters:
|
34
50
|
Enabled: true
|
35
51
|
|
36
|
-
#
|
52
|
+
# Checks for uses of the case equality operator(===).
|
37
53
|
Style/CaseEquality:
|
38
54
|
Enabled: false
|
39
55
|
|
56
|
+
# Identifies places where if-elsif constructions can be replaced with case-when.
|
57
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylecaselikeif
|
58
|
+
Style/CaseLikeIf:
|
59
|
+
Enabled: true
|
60
|
+
|
40
61
|
# Checks for uses of character literals.
|
41
62
|
Style/CharacterLiteral:
|
42
63
|
Enabled: true
|
@@ -95,6 +116,12 @@ Style/EndBlock:
|
|
95
116
|
Style/EvenOdd:
|
96
117
|
Enabled: true
|
97
118
|
|
119
|
+
# Enforces the use of explicit block argument to avoid writing block literal that
|
120
|
+
# just passes its arguments to another block.
|
121
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleexplicitblockargument
|
122
|
+
Style/ExplicitBlockArgument:
|
123
|
+
Enabled: true
|
124
|
+
|
98
125
|
# Enforces consistency when using exponential notation for numbers in the code
|
99
126
|
Style/ExponentialNotation:
|
100
127
|
Enabled: true
|
@@ -111,6 +138,13 @@ Style/FormatStringToken:
|
|
111
138
|
Style/FrozenStringLiteralComment:
|
112
139
|
Enabled: true
|
113
140
|
|
141
|
+
# Enforces the use of $stdout/$stderr/$stdin instead of STDOUT/STDERR/STDIN. STDOUT/STDERR/STDIN are constants,
|
142
|
+
# and while you can actually reassign (possibly to redirect some stream) constants in Ruby,
|
143
|
+
# you’ll get an interpreter warning if you do so.
|
144
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleglobalstdstream
|
145
|
+
Style/GlobalStdStream:
|
146
|
+
Enabled: true
|
147
|
+
|
114
148
|
# Do not introduce global variables.
|
115
149
|
Style/GlobalVars:
|
116
150
|
Enabled: true
|
@@ -118,10 +152,20 @@ Style/GlobalVars:
|
|
118
152
|
- 'lib/backup/**/*'
|
119
153
|
- 'lib/tasks/**/*'
|
120
154
|
|
155
|
+
# Checks for presence or absence of braces around hash literal as a last array item depending on configuration.
|
156
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylehashaslastarrayitem
|
157
|
+
Style/HashAsLastArrayItem:
|
158
|
+
Enabled: true
|
159
|
+
|
121
160
|
# Checks for uses of each_key and each_value Hash methods.
|
122
161
|
Style/HashEachMethods:
|
123
162
|
Enabled: true
|
124
163
|
|
164
|
+
# Checks for places where case-when represents a simple 1:1 mapping and can be replaced with a hash lookup.
|
165
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylehashlikecase
|
166
|
+
Style/HashLikeCase:
|
167
|
+
Enabled: false
|
168
|
+
|
125
169
|
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
|
126
170
|
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
|
127
171
|
Style/HashSyntax:
|
@@ -161,6 +205,11 @@ Style/InverseMethods:
|
|
161
205
|
Style/LambdaCall:
|
162
206
|
Enabled: true
|
163
207
|
|
208
|
+
# Checks for places where keyword arguments can be used instead of boolean arguments when defining methods.
|
209
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleoptionalbooleanparameter
|
210
|
+
Style/OptionalBooleanParameter:
|
211
|
+
Enabled: false
|
212
|
+
|
164
213
|
# Use `strip` instead of `lstrip.rstrip`.
|
165
214
|
Style/Strip:
|
166
215
|
Enabled: true
|
@@ -248,10 +297,25 @@ Style/PreferredHashMethods:
|
|
248
297
|
Style/RedundantCapitalW:
|
249
298
|
Enabled: true
|
250
299
|
|
300
|
+
# Checks for redundant assignment before returning.
|
301
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleredundantassignment
|
302
|
+
Style/RedundantAssignment:
|
303
|
+
Enabled: true
|
304
|
+
|
251
305
|
# Checks for an obsolete RuntimeException argument in raise/fail.
|
252
306
|
Style/RedundantException:
|
253
307
|
Enabled: true
|
254
308
|
|
309
|
+
# Identifies places where fetch(key) { value } can be replaced by fetch(key, value).
|
310
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleredundantfetchblock
|
311
|
+
Style/RedundantFetchBlock:
|
312
|
+
Enabled: true
|
313
|
+
|
314
|
+
# Checks for the presence of superfluous .rb extension in the filename provided to require and require_relative.
|
315
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleredundantfileextensioninrequire
|
316
|
+
Style/RedundantFileExtensionInRequire:
|
317
|
+
Enabled: true
|
318
|
+
|
255
319
|
# Checks for parentheses that seem not to serve any purpose.
|
256
320
|
Style/RedundantParentheses:
|
257
321
|
Enabled: true
|
@@ -260,6 +324,16 @@ Style/RedundantParentheses:
|
|
260
324
|
Style/RedundantPercentQ:
|
261
325
|
Enabled: false
|
262
326
|
|
327
|
+
# Checks for unnecessary single-element Regexp character classes.
|
328
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleredundantregexpcharacterclass
|
329
|
+
Style/RedundantRegexpCharacterClass:
|
330
|
+
Enabled: true
|
331
|
+
|
332
|
+
# Checks for redundant escapes inside Regexp literals.
|
333
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleredundantregexpescape
|
334
|
+
Style/RedundantRegexpEscape:
|
335
|
+
Enabled: true
|
336
|
+
|
263
337
|
# Use `sort` instead of `sort_by { |x| x }`.
|
264
338
|
Style/RedundantSortBy:
|
265
339
|
Enabled: true
|
@@ -268,16 +342,31 @@ Style/RedundantSortBy:
|
|
268
342
|
Style/Semicolon:
|
269
343
|
Enabled: true
|
270
344
|
|
345
|
+
# Sometimes using dig method ends up with just a single argument. In such cases, dig should be replaced with [].
|
346
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylesingleargumentdig
|
347
|
+
Style/SingleArgumentDig:
|
348
|
+
Enabled: true
|
349
|
+
|
271
350
|
# Checks for proper usage of fail and raise.
|
272
351
|
Style/SignalException:
|
273
352
|
EnforcedStyle: only_raise
|
274
353
|
Enabled: true
|
275
354
|
|
355
|
+
# Checks that arrays are sliced with endless ranges instead of ary[start..-1] on Ruby 2.6+.
|
356
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#styleslicingwithrange
|
357
|
+
Style/SlicingWithRange:
|
358
|
+
Enabled: true
|
359
|
+
|
276
360
|
# Check for the usage of parentheses around stabby lambda arguments.
|
277
361
|
Style/StabbyLambdaParentheses:
|
278
362
|
EnforcedStyle: require_parentheses
|
279
363
|
Enabled: true
|
280
364
|
|
365
|
+
# Checks for places where string concatenation can be replaced with string interpolation.
|
366
|
+
# https://docs.rubocop.org/rubocop/0.89/cops_style.html#stylestringconcatenation
|
367
|
+
Style/StringConcatenation:
|
368
|
+
Enabled: true
|
369
|
+
|
281
370
|
# Checks if uses of quotes match the configured preference.
|
282
371
|
Style/StringLiterals:
|
283
372
|
Enabled: false
|
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: 5.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: 2020-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.89.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.89.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-gitlab-security
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,42 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.8.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.8.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2.
|
61
|
+
version: '2.8'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '2.
|
68
|
+
version: '2.8'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.44'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.44'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +129,7 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".editorconfig"
|
132
133
|
- ".gitignore"
|
133
134
|
- ".gitlab-ci.yml"
|
134
135
|
- ".gitlab/merge_request_templates/Release.md"
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- lib/gitlab/styles/rubocop.rb
|
149
150
|
- lib/gitlab/styles/rubocop/cop/active_record_dependent.rb
|
150
151
|
- lib/gitlab/styles/rubocop/cop/active_record_serialize.rb
|
152
|
+
- lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb
|
151
153
|
- lib/gitlab/styles/rubocop/cop/custom_error_class.rb
|
152
154
|
- lib/gitlab/styles/rubocop/cop/gem_fetcher.rb
|
153
155
|
- lib/gitlab/styles/rubocop/cop/in_batches.rb
|
@@ -155,6 +157,7 @@ files:
|
|
155
157
|
- lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
|
156
158
|
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
|
157
159
|
- lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
|
160
|
+
- lib/gitlab/styles/rubocop/cop/rspec/base.rb
|
158
161
|
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_let_block.rb
|
159
162
|
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb
|
160
163
|
- lib/gitlab/styles/rubocop/cop/rspec/have_link_parameters.rb
|
@@ -163,9 +166,11 @@ files:
|
|
163
166
|
- lib/gitlab/styles/rubocop/cop/without_reactive_cache.rb
|
164
167
|
- lib/gitlab/styles/rubocop/migration_helpers.rb
|
165
168
|
- lib/gitlab/styles/rubocop/model_helpers.rb
|
169
|
+
- lib/gitlab/styles/rubocop/rspec/helpers.rb
|
166
170
|
- lib/gitlab/styles/version.rb
|
167
171
|
- rubocop-all.yml
|
168
172
|
- rubocop-bundler.yml
|
173
|
+
- rubocop-code_reuse.yml
|
169
174
|
- rubocop-default.yml
|
170
175
|
- rubocop-gemspec.yml
|
171
176
|
- rubocop-layout.yml
|
@@ -190,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
195
|
requirements:
|
191
196
|
- - ">="
|
192
197
|
- !ruby/object:Gem::Version
|
193
|
-
version: '
|
198
|
+
version: '2.6'
|
194
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
200
|
requirements:
|
196
201
|
- - ">="
|