gitlab-styles 9.1.0 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -8
- data/lib/gitlab/styles/version.rb +1 -1
- data/lib/rubocop/cop/gem_fetcher.rb +18 -20
- data/lib/rubocop/cop/line_break_around_conditional_block.rb +5 -0
- data/lib/rubocop/cop/rspec/empty_line_after_shared_example.rb +1 -1
- data/rubocop-bundler.yml +10 -0
- data/rubocop-layout.yml +46 -2
- data/rubocop-lint.yml +1 -1
- data/rubocop-performance.yml +32 -0
- data/rubocop-rspec.yml +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e3e06ef1557da413f41116af9b5b01733a309e35bcd2717e8d8ec2473470589
|
4
|
+
data.tar.gz: 704feb3fc08d96cde2a0cdadc8dbe5bbdde1bcb3b18a010f6b964462ec0f33aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dcbe74347c735155eed09bfd24923dff24013454269d8edc7d5e62c4b35ebf7413958bd3b4cff55192bdc51f01dbdfdf438f853dfab322e20b96f6ed283142c
|
7
|
+
data.tar.gz: 74ce09358878dd2deca30b2af8698eb46f3417b9f041794c00ee5e97bda90719548fb86250ef8718a7969c23361d256e7acf5669abaaaf6d60ed23eb5608e516
|
data/README.md
CHANGED
@@ -80,13 +80,6 @@ bundle exec rubocop -c .rubocop.yml
|
|
80
80
|
lefthook install
|
81
81
|
```
|
82
82
|
|
83
|
-
## Contributing
|
84
|
-
|
85
|
-
Bug reports and merge requests are welcome on GitLab at
|
86
|
-
https://gitlab.com/gitlab-org/gitlab-styles. This project is intended to be a
|
87
|
-
safe, welcoming space for collaboration, and contributors are expected to adhere
|
88
|
-
to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
89
|
-
|
90
83
|
## Release Process
|
91
84
|
|
92
85
|
We release `gitlab-styles` on an ad-hoc basis. There is no regularity to when
|
@@ -98,10 +91,18 @@ To release a new version:
|
|
98
91
|
1. Create a Merge Request.
|
99
92
|
1. Use Merge Request template [Release.md](https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/blob/master/.gitlab/merge_request_templates/Release.md).
|
100
93
|
1. Follow the instructions.
|
101
|
-
1.
|
94
|
+
1. (Optional, but appreciated) Create an MR on `gitlab-org/gitlab` project [with the `New Version of gitlab-styles.md` template](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/merge_request_templates/New%20Version%20of%20gitlab-styles.md) to test the new version of `gitlab-styles`, and follow the MR instructions.
|
95
|
+
1. After the Merge Request has been merged, a new gem version is [published automatically](https://gitlab.com/gitlab-org/quality/pipeline-common/-/blob/master/ci/gem-release.yml)
|
102
96
|
|
103
97
|
See [!123](https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/merge_requests/123) as an example.
|
104
98
|
|
99
|
+
## Contributing
|
100
|
+
|
101
|
+
Bug reports and merge requests are welcome on GitLab at
|
102
|
+
https://gitlab.com/gitlab-org/gitlab-styles. This project is intended to be a
|
103
|
+
safe, welcoming space for collaboration, and contributors are expected to adhere
|
104
|
+
to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
105
|
+
|
105
106
|
## License
|
106
107
|
|
107
108
|
The gem is available as open source under the terms of the
|
@@ -6,31 +6,29 @@ module Rubocop
|
|
6
6
|
# `Gemfile` in order to avoid additional points of failure beyond
|
7
7
|
# rubygems.org.
|
8
8
|
class GemFetcher < RuboCop::Cop::Base
|
9
|
-
MSG = 'Do not use gems from git repositories, only use gems from RubyGems.'
|
9
|
+
MSG = 'Do not use gems from git repositories, only use gems from RubyGems or vendored gems. ' \
|
10
|
+
'See https://docs.gitlab.com/ee/development/gemfile.html#no-gems-fetched-from-git-repositories'
|
10
11
|
|
11
|
-
|
12
|
+
# See https://bundler.io/guides/git.html#custom-git-sources
|
13
|
+
GIT_SOURCES = %i[git github gist bitbucket].freeze
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
# @!method gem_option(node)
|
16
|
+
def_node_matcher :gem_option, <<~PATTERN
|
17
|
+
(send nil? :gem _
|
18
|
+
(hash
|
19
|
+
<$(pair (sym {#{GIT_SOURCES.map(&:inspect).join(' ')}}) _)
|
20
|
+
...>
|
21
|
+
)
|
22
|
+
)
|
23
|
+
PATTERN
|
18
24
|
|
19
|
-
|
20
|
-
key_name = pair.children[0].children[0].to_sym
|
21
|
-
add_offense(pair.source_range) if GIT_KEYS.include?(key_name)
|
22
|
-
end
|
23
|
-
end
|
25
|
+
RESTRICT_ON_SEND = %i[gem].freeze
|
24
26
|
|
25
|
-
|
27
|
+
def on_send(node)
|
28
|
+
pair_node = gem_option(node)
|
29
|
+
return unless pair_node
|
26
30
|
|
27
|
-
|
28
|
-
node
|
29
|
-
.location
|
30
|
-
.expression
|
31
|
-
.source_buffer
|
32
|
-
.name
|
33
|
-
.end_with?("Gemfile")
|
31
|
+
add_offense(pair_node)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
@@ -70,6 +70,7 @@ module Rubocop
|
|
70
70
|
def previous_line_valid?(node)
|
71
71
|
previous_line(node).empty? ||
|
72
72
|
start_clause_line?(previous_line(node)) ||
|
73
|
+
method_def_end?(node.parent, previous_line(node)) ||
|
73
74
|
block_start?(previous_line(node)) ||
|
74
75
|
begin_line?(previous_line(node)) ||
|
75
76
|
assignment_line?(previous_line(node)) ||
|
@@ -94,6 +95,10 @@ module Rubocop
|
|
94
95
|
line =~ /^\s*(def|=end|#|module|class|if|unless|else|elsif|ensure|when)/
|
95
96
|
end
|
96
97
|
|
98
|
+
def method_def_end?(node, line)
|
99
|
+
node.def_type? && /\)\s*(#.*)?$/.match?(line)
|
100
|
+
end
|
101
|
+
|
97
102
|
def end_clause_line?(line)
|
98
103
|
line =~ /^\s*(#|rescue|else|elsif|when)/
|
99
104
|
end
|
data/rubocop-bundler.yml
CHANGED
@@ -1,4 +1,14 @@
|
|
1
1
|
---
|
2
|
+
require:
|
3
|
+
- ./lib/rubocop/cop/gem_fetcher
|
4
|
+
|
2
5
|
# Gems in consecutive lines should be alphabetically sorted
|
3
6
|
Bundler/OrderedGems:
|
4
7
|
Enabled: false
|
8
|
+
|
9
|
+
Cop/GemFetcher:
|
10
|
+
Enabled: true
|
11
|
+
Include:
|
12
|
+
- '**/*.gemfile'
|
13
|
+
- '**/Gemfile'
|
14
|
+
- '**/gems.rb'
|
data/rubocop-layout.yml
CHANGED
@@ -3,9 +3,15 @@
|
|
3
3
|
Layout/AccessModifierIndentation:
|
4
4
|
Enabled: true
|
5
5
|
|
6
|
+
# Check if the arguments on a multi-line method definition are aligned.
|
7
|
+
Layout/ArgumentAlignment:
|
8
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/42
|
9
|
+
EnforcedStyle: with_fixed_indentation
|
10
|
+
|
6
11
|
# Align the elements of an array literal if they span more than one line.
|
7
12
|
Layout/ArrayAlignment:
|
8
|
-
|
13
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/42
|
14
|
+
EnforcedStyle: with_fixed_indentation
|
9
15
|
|
10
16
|
# Checks the indentation of the first line of the right-hand-side of a
|
11
17
|
# multi-line assignment.
|
@@ -102,6 +108,23 @@ Layout/EndOfLine:
|
|
102
108
|
Layout/ExtraSpacing:
|
103
109
|
Enabled: true
|
104
110
|
|
111
|
+
# Checks the indentation of the first argument in a method call.
|
112
|
+
Layout/FirstArgumentIndentation:
|
113
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/42
|
114
|
+
EnforcedStyle: consistent
|
115
|
+
|
116
|
+
# Checks the indentation of the first element in an array literal where the
|
117
|
+
# opening bracket and the first element are on separate lines.
|
118
|
+
Layout/FirstArrayElementIndentation:
|
119
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/42
|
120
|
+
EnforcedStyle: consistent
|
121
|
+
|
122
|
+
# Checks the indentation of the first key in a hash literal where the opening
|
123
|
+
# brace and the first key are on separate lines.
|
124
|
+
Layout/FirstHashElementIndentation:
|
125
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/42
|
126
|
+
EnforcedStyle: consistent
|
127
|
+
|
105
128
|
# Checks for a line break before the first parameter in a multi-line method
|
106
129
|
# parameter definition.
|
107
130
|
Layout/FirstMethodParameterLineBreak:
|
@@ -137,6 +160,17 @@ Layout/LineLength:
|
|
137
160
|
Max: 120
|
138
161
|
AllowedPatterns: ['\s#\srubocop']
|
139
162
|
|
163
|
+
# Checks that strings broken over multiple lines (by a backslash) contain
|
164
|
+
# trailing spaces instead of leading spaces (default) or leading spaces instead
|
165
|
+
# of trailing spaces.
|
166
|
+
Layout/LineContinuationLeadingSpace:
|
167
|
+
Enabled: true
|
168
|
+
|
169
|
+
# Checks that the backslash of a line continuation is separated from preceding
|
170
|
+
# text by exactly one space (default) or zero spaces.
|
171
|
+
Layout/LineContinuationSpacing:
|
172
|
+
Enabled: true
|
173
|
+
|
140
174
|
# Checks that the closing brace in an array literal is either on the same line
|
141
175
|
# as the last array element, or a new line.
|
142
176
|
Layout/MultilineArrayBraceLayout:
|
@@ -147,6 +181,11 @@ Layout/MultilineArrayBraceLayout:
|
|
147
181
|
Layout/MultilineBlockLayout:
|
148
182
|
Enabled: true
|
149
183
|
|
184
|
+
# Checks the indentation of the next line after a line that ends with a string
|
185
|
+
# literal and a backslash.
|
186
|
+
Layout/LineEndStringConcatenationIndentation:
|
187
|
+
Enabled: true
|
188
|
+
|
150
189
|
# Checks that the closing brace in a hash literal is either on the same line as
|
151
190
|
# the last hash element, or a new line.
|
152
191
|
Layout/MultilineHashBraceLayout:
|
@@ -177,7 +216,8 @@ Layout/MultilineOperationIndentation:
|
|
177
216
|
# Here we check if the parameters on a multi-line method call or
|
178
217
|
# definition are aligned.
|
179
218
|
Layout/ParameterAlignment:
|
180
|
-
|
219
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/42
|
220
|
+
EnforcedStyle: with_fixed_indentation
|
181
221
|
|
182
222
|
# Use spaces after colons.
|
183
223
|
Layout/SpaceAfterColon:
|
@@ -223,6 +263,10 @@ Layout/SpaceAroundOperators:
|
|
223
263
|
Layout/SpaceBeforeBlockBraces:
|
224
264
|
Enabled: true
|
225
265
|
|
266
|
+
# Checks for space between the name of a receiver and a left brackets.
|
267
|
+
Layout/SpaceBeforeBrackets:
|
268
|
+
Enabled: true
|
269
|
+
|
226
270
|
# No spaces before commas.
|
227
271
|
Layout/SpaceBeforeComma:
|
228
272
|
Enabled: true
|
data/rubocop-lint.yml
CHANGED
@@ -12,7 +12,7 @@ Lint/AmbiguousOperator:
|
|
12
12
|
# This cop checks for ambiguous regexp literals in the first argument of
|
13
13
|
# a method invocation without parentheses.
|
14
14
|
Lint/AmbiguousRegexpLiteral:
|
15
|
-
Enabled:
|
15
|
+
Enabled: true
|
16
16
|
|
17
17
|
# This cop checks for assignments in the conditions of
|
18
18
|
# if/while/until.
|
data/rubocop-performance.yml
CHANGED
@@ -28,6 +28,11 @@ Performance/Casecmp:
|
|
28
28
|
Performance/CollectionLiteralInLoop: # (new in 1.8)
|
29
29
|
Enabled: true
|
30
30
|
|
31
|
+
# Identifies places where Concurrent.monotonic_time can be replaced by
|
32
|
+
# Process.clock_gettime(Process::CLOCK_MONOTONIC).
|
33
|
+
Performance/ConcurrentMonotonicTime:
|
34
|
+
Enabled: true
|
35
|
+
|
31
36
|
Performance/ConstantRegexp: # (new in 1.9)
|
32
37
|
Enabled: true
|
33
38
|
|
@@ -36,6 +41,17 @@ Performance/ConstantRegexp: # (new in 1.9)
|
|
36
41
|
Performance/DoubleStartEndWith:
|
37
42
|
Enabled: true
|
38
43
|
|
44
|
+
# Identifies usages of map { ... }.flatten and change them to use
|
45
|
+
# flat_map { ... } instead.
|
46
|
+
Performance/FlatMap:
|
47
|
+
Enabled: true
|
48
|
+
EnabledForFlattenWithoutParams: true
|
49
|
+
|
50
|
+
# This cop identifies places where map { … }.compact can be replaced by
|
51
|
+
# filter_map.
|
52
|
+
Performance/MapCompact:
|
53
|
+
Enabled: true
|
54
|
+
|
39
55
|
Performance/MethodObjectAsBlock: # (new in 1.9)
|
40
56
|
Enabled: true
|
41
57
|
|
@@ -52,6 +68,11 @@ Performance/RangeInclude:
|
|
52
68
|
Performance/RedundantBlockCall:
|
53
69
|
Enabled: true
|
54
70
|
|
71
|
+
# Checks for uses Enumerable#all?, Enumerable#any?, Enumerable#one?, and
|
72
|
+
# Enumerable#none? are compared with === or similar methods in block.
|
73
|
+
Performance/RedundantEqualityComparisonBlock:
|
74
|
+
Enabled: true
|
75
|
+
|
55
76
|
# This cop identifies use of `Regexp#match` or `String#match in a context
|
56
77
|
# where the integral return value of `=~` would do just as well.
|
57
78
|
Performance/RedundantMatch:
|
@@ -73,6 +94,11 @@ Performance/RedundantSortBlock:
|
|
73
94
|
Performance/RedundantStringChars:
|
74
95
|
Enabled: true
|
75
96
|
|
97
|
+
# Identifies places where split argument can be replaced from a deterministic
|
98
|
+
# regexp to a string.
|
99
|
+
Performance/RedundantSplitRegexpArgument:
|
100
|
+
Enabled: true
|
101
|
+
|
76
102
|
# Identifies places where reverse.first(n) and reverse.first can be replaced by last(n).reverse and last.
|
77
103
|
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performancereversefirst
|
78
104
|
Performance/ReverseFirst:
|
@@ -98,6 +124,12 @@ Performance/StartWith:
|
|
98
124
|
Performance/StringInclude:
|
99
125
|
Enabled: true
|
100
126
|
|
127
|
+
# Identifies places where string identifier argument can be replaced by symbol
|
128
|
+
# identifier argument. It prevents the redundancy of the internal
|
129
|
+
# string-to-symbol conversion.
|
130
|
+
Performance/StringIdentifierArgument:
|
131
|
+
Enabled: true
|
132
|
+
|
101
133
|
# Use `tr` instead of `gsub` when you are replacing the same number of
|
102
134
|
# characters. Use `delete` instead of `gsub` when you are deleting
|
103
135
|
# characters.
|
data/rubocop-rspec.yml
CHANGED
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: 9.
|
4
|
+
version: 9.2.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-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|