gitlab-styles 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +4 -15
- data/.gitlab/merge_request_templates/Release.md +4 -4
- data/.rubocop.yml +3 -1
- data/lib/gitlab/styles/rubocop.rb +1 -0
- data/lib/gitlab/styles/rubocop/cop/active_record_dependent.rb +1 -1
- data/lib/gitlab/styles/rubocop/cop/custom_error_class.rb +6 -3
- data/lib/gitlab/styles/rubocop/cop/gem_fetcher.rb +1 -1
- data/lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb +1 -1
- data/lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb +132 -0
- data/lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb +1 -1
- data/lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb +1 -1
- data/lib/gitlab/styles/rubocop/rspec/helpers.rb +1 -1
- data/lib/gitlab/styles/version.rb +1 -1
- metadata +7 -7
- data/.rubocop_todo.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30bceb716d5e39ed5e48f4d42fd4457eb0a0608be5419e03ac325a3db385da08
|
4
|
+
data.tar.gz: 50058ac5c12783bd57e55e9cf19973ffb9aec21c277e3ff20839849271feb64c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f700edd701ed7b465a1e5bac5971dee3e7f31df2603a03dc76fd048feb98ec23e4fb1e70b2704e5f3899eecb0c2f6817a1d508bcf1708a092587e9ba2a4f86
|
7
|
+
data.tar.gz: 3ba624b97b7bab08fa1fb26b82cae5f72494e639a1c7cc000d95098ad39807218e15e118654a2518076ae3409f31ee55caa980e3d88cac26394d26e10f079b0f
|
data/.gitlab-ci.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
stages:
|
2
|
-
- release
|
3
2
|
- test
|
3
|
+
- deploy
|
4
4
|
|
5
5
|
default:
|
6
6
|
image: ruby:2.6
|
@@ -29,17 +29,6 @@ specs:
|
|
29
29
|
script:
|
30
30
|
- bundle exec rspec
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
- if: '$CI_COMMIT_TAG'
|
36
|
-
script:
|
37
|
-
- gem update --system
|
38
|
-
- ruby --version
|
39
|
-
- gem env version
|
40
|
-
- gem build gitlab-styles.gemspec
|
41
|
-
- gem push gitlab-styles*.gem
|
42
|
-
artifacts:
|
43
|
-
paths:
|
44
|
-
- gitlab-styles*.gem
|
45
|
-
expire_in: 30 days
|
32
|
+
include:
|
33
|
+
- project: 'gitlab-org/quality/pipeline-common'
|
34
|
+
file: '/ci/gem-release.yml'
|
@@ -7,7 +7,7 @@ with the latest commit from https://gitlab.com/gitlab-org/gitlab-styles/commits/
|
|
7
7
|
<!-- Keep the sections order but remove the empty sections -->
|
8
8
|
|
9
9
|
```markdown
|
10
|
-
### New
|
10
|
+
### New features and features updates
|
11
11
|
|
12
12
|
- !aaa <Title of the aaa MR>.
|
13
13
|
|
@@ -19,7 +19,7 @@ with the latest commit from https://gitlab.com/gitlab-org/gitlab-styles/commits/
|
|
19
19
|
|
20
20
|
- !ccc <Title of the ccc MR>.
|
21
21
|
|
22
|
-
### Other changes (
|
22
|
+
### Other changes (tooling, technical debt)
|
23
23
|
|
24
24
|
- !ddd <Title of the ddd MR>.
|
25
25
|
```
|
@@ -30,6 +30,6 @@ with the latest commit from https://gitlab.com/gitlab-org/gitlab-styles/commits/
|
|
30
30
|
- [ ] Release notes are accurate.
|
31
31
|
|
32
32
|
- Checklist after merging:
|
33
|
-
- [ ] [
|
33
|
+
- [ ] [Update the release notes for the newly created tag](docs/release_process.md#how-to).
|
34
34
|
|
35
|
-
/label ~"Engineering Productivity" ~"
|
35
|
+
/label ~"Engineering Productivity" ~"feature" ~"feature::maintenance" ~"static code analysis"
|
data/.rubocop.yml
CHANGED
@@ -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/line_break_around_conditional_block'
|
11
12
|
require 'gitlab/styles/rubocop/cop/code_reuse/active_record'
|
12
13
|
require 'gitlab/styles/rubocop/cop/migration/update_large_table'
|
13
14
|
require 'gitlab/styles/rubocop/cop/without_reactive_cache'
|
@@ -21,7 +21,8 @@ module Gitlab
|
|
21
21
|
MSG = 'Use `Class.new(SuperClass)` to define an empty custom error class.'
|
22
22
|
|
23
23
|
def on_class(node)
|
24
|
-
|
24
|
+
parent = node.parent_class
|
25
|
+
body = node.body
|
25
26
|
|
26
27
|
return if body
|
27
28
|
|
@@ -29,11 +30,13 @@ module Gitlab
|
|
29
30
|
|
30
31
|
return unless parent_klass&.to_s&.end_with?('Error')
|
31
32
|
|
32
|
-
add_offense(node
|
33
|
+
add_offense(node)
|
33
34
|
end
|
34
35
|
|
35
36
|
def autocorrect(node)
|
36
|
-
klass
|
37
|
+
klass = node.identifier
|
38
|
+
parent = node.parent_class
|
39
|
+
|
37
40
|
replacement = "#{class_name_from_node(klass)} = Class.new(#{class_name_from_node(parent)})"
|
38
41
|
|
39
42
|
lambda do |corrector|
|
@@ -20,7 +20,7 @@ module Gitlab
|
|
20
20
|
|
21
21
|
node.children.last.each_node(:pair) do |pair|
|
22
22
|
key_name = pair.children[0].children[0].to_sym
|
23
|
-
add_offense(node, location: pair.source_range
|
23
|
+
add_offense(node, location: pair.source_range) if GIT_KEYS.include?(key_name)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -69,7 +69,7 @@ module Gitlab
|
|
69
69
|
return unless guard_clause?(node)
|
70
70
|
return if next_line(node).blank? || clause_last_line?(next_line(node)) || guard_clause?(next_sibling(node))
|
71
71
|
|
72
|
-
add_offense(node
|
72
|
+
add_offense(node)
|
73
73
|
end
|
74
74
|
|
75
75
|
def autocorrect(node)
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Styles
|
5
|
+
module Rubocop
|
6
|
+
module Cop
|
7
|
+
# Ensures a line break around conditional blocks.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# do_something
|
12
|
+
# if condition
|
13
|
+
# do_extra_stuff
|
14
|
+
# end
|
15
|
+
# do_something_more
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# do_something
|
19
|
+
#
|
20
|
+
# if condition
|
21
|
+
# do_extra_stuff
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# do_something_more
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# do_something
|
28
|
+
# unless condition
|
29
|
+
# do_extra_stuff
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# do_something_more
|
33
|
+
#
|
34
|
+
# # good
|
35
|
+
# def a_method
|
36
|
+
# if condition
|
37
|
+
# do_something
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# # good
|
42
|
+
# on_block do
|
43
|
+
# if condition
|
44
|
+
# do_something
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
class LineBreakAroundConditionalBlock < RuboCop::Cop::Cop
|
48
|
+
include RuboCop::Cop::RangeHelp
|
49
|
+
|
50
|
+
MSG = 'Add a line break around conditional blocks'
|
51
|
+
|
52
|
+
def on_if(node)
|
53
|
+
# This cop causes errors in haml files, so let's skip those
|
54
|
+
return if in_haml?(node)
|
55
|
+
return if node.single_line?
|
56
|
+
return unless node.if? || node.unless?
|
57
|
+
|
58
|
+
add_offense(node) unless previous_line_valid?(node)
|
59
|
+
add_offense(node) unless last_line_valid?(node)
|
60
|
+
end
|
61
|
+
|
62
|
+
def autocorrect(node)
|
63
|
+
lambda do |corrector|
|
64
|
+
line = range_by_whole_lines(node.source_range)
|
65
|
+
|
66
|
+
corrector.insert_before(line, "\n") unless previous_line_valid?(node)
|
67
|
+
corrector.insert_after(line, "\n") unless last_line_valid?(node)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def previous_line_valid?(node)
|
74
|
+
previous_line(node).empty? ||
|
75
|
+
start_clause_line?(previous_line(node)) ||
|
76
|
+
block_start?(previous_line(node)) ||
|
77
|
+
begin_line?(previous_line(node)) ||
|
78
|
+
assignment_line?(previous_line(node)) ||
|
79
|
+
rescue_line?(previous_line(node))
|
80
|
+
end
|
81
|
+
|
82
|
+
def last_line_valid?(node)
|
83
|
+
last_line(node).empty? ||
|
84
|
+
end_line?(last_line(node)) ||
|
85
|
+
end_clause_line?(last_line(node))
|
86
|
+
end
|
87
|
+
|
88
|
+
def previous_line(node)
|
89
|
+
processed_source[node.loc.line - 2]
|
90
|
+
end
|
91
|
+
|
92
|
+
def last_line(node)
|
93
|
+
processed_source[node.loc.last_line]
|
94
|
+
end
|
95
|
+
|
96
|
+
def start_clause_line?(line)
|
97
|
+
line =~ /^\s*(def|=end|#|module|class|if|unless|else|elsif|ensure|when)/
|
98
|
+
end
|
99
|
+
|
100
|
+
def end_clause_line?(line)
|
101
|
+
line =~ /^\s*(#|rescue|else|elsif|when)/
|
102
|
+
end
|
103
|
+
|
104
|
+
def begin_line?(line)
|
105
|
+
# an assignment followed by a begin or ust a begin
|
106
|
+
line =~ /^\s*(@?(\w|\|+|=|\[|\]|\s)+begin|begin)/
|
107
|
+
end
|
108
|
+
|
109
|
+
def assignment_line?(line)
|
110
|
+
line =~ /^\s*.*=/
|
111
|
+
end
|
112
|
+
|
113
|
+
def rescue_line?(line)
|
114
|
+
line =~ /^\s*rescue/
|
115
|
+
end
|
116
|
+
|
117
|
+
def block_start?(line)
|
118
|
+
line.match(/ (do|{)( \|.*?\|)?\s?(#.+)?\z/)
|
119
|
+
end
|
120
|
+
|
121
|
+
def end_line?(line)
|
122
|
+
line =~ /^\s*(end|})/
|
123
|
+
end
|
124
|
+
|
125
|
+
def in_haml?(node)
|
126
|
+
node.location.expression.source_buffer.name.end_with?('.haml.rb')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
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: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '3.0'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- gitlab_rubygems@gitlab.com
|
128
128
|
executables: []
|
@@ -135,7 +135,6 @@ files:
|
|
135
135
|
- ".gitlab/merge_request_templates/Release.md"
|
136
136
|
- ".rspec"
|
137
137
|
- ".rubocop.yml"
|
138
|
-
- ".rubocop_todo.yml"
|
139
138
|
- CODE_OF_CONDUCT.md
|
140
139
|
- CONTRIBUTING.md
|
141
140
|
- Gemfile
|
@@ -154,6 +153,7 @@ files:
|
|
154
153
|
- lib/gitlab/styles/rubocop/cop/gem_fetcher.rb
|
155
154
|
- lib/gitlab/styles/rubocop/cop/in_batches.rb
|
156
155
|
- lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb
|
156
|
+
- lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb
|
157
157
|
- lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
|
158
158
|
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
|
159
159
|
- lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
|
@@ -187,7 +187,7 @@ homepage: https://gitlab.com/gitlab-org/gitlab-styles
|
|
187
187
|
licenses:
|
188
188
|
- MIT
|
189
189
|
metadata: {}
|
190
|
-
post_install_message:
|
190
|
+
post_install_message:
|
191
191
|
rdoc_options: []
|
192
192
|
require_paths:
|
193
193
|
- lib
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
205
|
rubygems_version: 3.1.4
|
206
|
-
signing_key:
|
206
|
+
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: GitLab style guides and shared style configs.
|
209
209
|
test_files: []
|
data/.rubocop_todo.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2017-11-03 15:49:59 +0100 using RuboCop version 0.51.0.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|