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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50eab9da6dd93cfbda3c8a8877e6ac2f8ce8274d6f92116973e6c9c1ee590d5f
4
- data.tar.gz: f7e187d901c89bb4d4ba4a40d72523b10c5148ef965d60b243e8c09c9bc21642
3
+ metadata.gz: 2e3e06ef1557da413f41116af9b5b01733a309e35bcd2717e8d8ec2473470589
4
+ data.tar.gz: 704feb3fc08d96cde2a0cdadc8dbe5bbdde1bcb3b18a010f6b964462ec0f33aa
5
5
  SHA512:
6
- metadata.gz: a9d90f34b3a3e6d97c6a791c5f91a26318b956751a77b2827f5370e15f8717bdf30cf30ddad0c63afd1f2335707d76dd948d1c7898c0d762f9b19389dea55d49
7
- data.tar.gz: 9634b21fcc052557e12ebd277279089e4cfd325b88860c45a5250da554b0f14e378b7cdf8c9648d019649cd1396b327fc7cf10d48462622f00f1af888cd61b31
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. A new gem version is [published automatically](https://gitlab.com/gitlab-org/quality/pipeline-common/-/blob/master/ci/gem-release.yml) after the Merge Request has been merged.
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Styles
5
- VERSION = '9.1.0'
5
+ VERSION = '9.2.0'
6
6
  end
7
7
  end
@@ -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
- GIT_KEYS = [:git, :github].freeze
12
+ # See https://bundler.io/guides/git.html#custom-git-sources
13
+ GIT_SOURCES = %i[git github gist bitbucket].freeze
12
14
 
13
- def on_send(node)
14
- return unless gemfile?(node)
15
-
16
- func_name = node.children[1]
17
- return unless func_name == :gem
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
- node.children.last.each_node(:pair) do |pair|
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
- private
27
+ def on_send(node)
28
+ pair_node = gem_option(node)
29
+ return unless pair_node
26
30
 
27
- def gemfile?(node)
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
@@ -45,7 +45,7 @@ module Rubocop
45
45
 
46
46
  # @!method shared_examples(node)
47
47
  def_node_matcher :shared_examples,
48
- block_pattern('{#SharedGroups.all #Includes.all}')
48
+ block_pattern('{#SharedGroups.all #Includes.all}')
49
49
 
50
50
  def on_block(node)
51
51
  shared_examples(node) do
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
- Enabled: true
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
- Enabled: false
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: false
15
+ Enabled: true
16
16
 
17
17
  # This cop checks for assignments in the conditions of
18
18
  # if/while/until.
@@ -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
@@ -40,6 +40,7 @@ RSpec/DescribeSymbol:
40
40
  # Checks that tests use `described_class`.
41
41
  RSpec/DescribedClass:
42
42
  Enabled: true
43
+ SkipBlocks: true
43
44
 
44
45
  # Checks if an example group does not include any tests.
45
46
  RSpec/EmptyExampleGroup:
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.1.0
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-15 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop