rubocop 0.75.0 → 0.75.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +1 -1
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +22 -7
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -2
- data/lib/rubocop/cop/layout/indent_assignment.rb +2 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +22 -6
- data/lib/rubocop/cop/lint/unused_method_argument.rb +23 -5
- data/lib/rubocop/cop/lint/void.rb +3 -22
- data/lib/rubocop/cop/style/documentation_method.rb +44 -0
- data/lib/rubocop/cop/style/expand_path_arguments.rb +1 -1
- data/lib/rubocop/cop/style/format_string_token.rb +13 -34
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +20 -20
- data/lib/rubocop/cop/style/redundant_return.rb +12 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +12 -4
- data/lib/rubocop/cop/style/semicolon.rb +11 -0
- data/lib/rubocop/formatter/clang_style_formatter.rb +8 -3
- data/lib/rubocop/formatter/emacs_style_formatter.rb +22 -12
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +16 -16
- data/lib/rubocop/formatter/pacman_formatter.rb +3 -3
- data/lib/rubocop/formatter/simple_text_formatter.rb +7 -3
- data/lib/rubocop/formatter/tap_formatter.rb +8 -3
- data/lib/rubocop/options.rb +4 -16
- data/lib/rubocop/version.rb +1 -1
- 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: 354a14aa737b4743d04d65393e8caae409513d2302b31aca36090441100f1bdb
|
4
|
+
data.tar.gz: 7bdbb625ae97e5e0f1a5ca6bfe0d93c71ac4a86a566ba13b987a293949486e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf54a562c567c28f118f5bf6bf0a9fb9e5987351559a001f80de025cb08793cd546731e80d3690dcce3ce8e0eda96381563ae307a5b0df303322c75331b8f14b
|
7
|
+
data.tar.gz: 76fb85901be4d90de0697874bf0bea52c2a23e2b39fa9607ec797d6768465c4f903bc2645ebf41a504f526064aee2e0000f7bbd2701735787425770682b79ec8
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
53
53
|
might want to use a conservative version lock in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 0.75.
|
56
|
+
gem 'rubocop', '~> 0.75.1', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
## Quickstart
|
data/config/default.yml
CHANGED
@@ -1815,7 +1815,7 @@ Metrics/LineLength:
|
|
1815
1815
|
- https
|
1816
1816
|
# The IgnoreCopDirectives option causes the LineLength rule to ignore cop
|
1817
1817
|
# directives like '# rubocop: enable ...' when calculating a line's length.
|
1818
|
-
IgnoreCopDirectives:
|
1818
|
+
IgnoreCopDirectives: true
|
1819
1819
|
# The IgnoredPatterns option is a list of !ruby/regexp and/or string
|
1820
1820
|
# elements. Strings will be converted to Regexp objects. A line that matches
|
1821
1821
|
# any regular expression listed in this option will be ignored by LineLength.
|
@@ -98,7 +98,7 @@ module RuboCop
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def fix_escaped_content(word_node, escape, delimiters)
|
101
|
-
content = word_node.children.first.to_s
|
101
|
+
content = +word_node.children.first.to_s
|
102
102
|
content = escape_string(content) if escape
|
103
103
|
substitute_escaped_delimiters(content, delimiters)
|
104
104
|
content
|
@@ -45,7 +45,7 @@ module RuboCop
|
|
45
45
|
return if correct_style?(node)
|
46
46
|
|
47
47
|
if node.modifier_form? && last_argument_is_heredoc?(node)
|
48
|
-
heredoc_node =
|
48
|
+
heredoc_node = last_heredoc_argument(node)
|
49
49
|
|
50
50
|
return if next_line_empty?(heredoc_line(node, heredoc_node))
|
51
51
|
|
@@ -109,16 +109,27 @@ module RuboCop
|
|
109
109
|
|
110
110
|
def last_argument_is_heredoc?(node)
|
111
111
|
last_children = node.if_branch
|
112
|
-
|
113
112
|
return false unless last_children&.send_type?
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
last_argument.respond_to?(:heredoc?) && last_argument.heredoc?
|
114
|
+
heredoc?(last_heredoc_argument(node))
|
118
115
|
end
|
119
116
|
|
120
|
-
def
|
121
|
-
node.if_branch
|
117
|
+
def last_heredoc_argument(node)
|
118
|
+
n = if node.respond_to?(:if_branch)
|
119
|
+
node.if_branch.children.last
|
120
|
+
else
|
121
|
+
node
|
122
|
+
end
|
123
|
+
|
124
|
+
return n if heredoc?(n)
|
125
|
+
return unless n.respond_to?(:arguments)
|
126
|
+
|
127
|
+
n.arguments.each do |argument|
|
128
|
+
node = last_heredoc_argument(argument)
|
129
|
+
return node if node
|
130
|
+
end
|
131
|
+
|
132
|
+
return last_heredoc_argument(n.receiver) if n.respond_to?(:receiver)
|
122
133
|
end
|
123
134
|
|
124
135
|
def heredoc_line(node, heredoc_node)
|
@@ -129,6 +140,10 @@ module RuboCop
|
|
129
140
|
node.last_line + num_of_heredoc_lines + END_OF_HEREDOC_LINE
|
130
141
|
end
|
131
142
|
|
143
|
+
def heredoc?(node)
|
144
|
+
node.respond_to?(:heredoc?) && node.heredoc?
|
145
|
+
end
|
146
|
+
|
132
147
|
def offense_location(node)
|
133
148
|
if node.loc.respond_to?(:end) && node.loc.end
|
134
149
|
:end
|
@@ -55,8 +55,8 @@ module RuboCop
|
|
55
55
|
source
|
56
56
|
.comments
|
57
57
|
.take_while { |comment| comment.loc.line < source.ast.loc.line }
|
58
|
-
.
|
59
|
-
.
|
58
|
+
.reverse
|
59
|
+
.find { |comment| MagicComment.parse(comment.text).any? }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
#
|
37
37
|
# end
|
38
38
|
#
|
39
|
-
# @example
|
39
|
+
# @example EnforcedStyle: beginning_only
|
40
40
|
# # good
|
41
41
|
#
|
42
42
|
# class Foo
|
@@ -46,7 +46,7 @@ module RuboCop
|
|
46
46
|
# end
|
47
47
|
# end
|
48
48
|
#
|
49
|
-
# @example
|
49
|
+
# @example EnforcedStyle: ending_only
|
50
50
|
# # good
|
51
51
|
#
|
52
52
|
# class Foo
|
@@ -6,9 +6,7 @@ module RuboCop
|
|
6
6
|
# This cop checks for unused block arguments.
|
7
7
|
#
|
8
8
|
# @example
|
9
|
-
#
|
10
9
|
# # bad
|
11
|
-
#
|
12
10
|
# do_something do |used, unused|
|
13
11
|
# puts used
|
14
12
|
# end
|
@@ -21,10 +19,7 @@ module RuboCop
|
|
21
19
|
# puts :baz
|
22
20
|
# end
|
23
21
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# #good
|
27
|
-
#
|
22
|
+
# # good
|
28
23
|
# do_something do |used, _unused|
|
29
24
|
# puts used
|
30
25
|
# end
|
@@ -36,6 +31,27 @@ module RuboCop
|
|
36
31
|
# define_method(:foo) do |_bar|
|
37
32
|
# puts :baz
|
38
33
|
# end
|
34
|
+
#
|
35
|
+
# @example IgnoreEmptyBlocks: true (default)
|
36
|
+
# # good
|
37
|
+
# do_something { |unused| }
|
38
|
+
#
|
39
|
+
# @example IgnoreEmptyBlocks: false
|
40
|
+
# # bad
|
41
|
+
# do_something { |unused| }
|
42
|
+
#
|
43
|
+
# @example AllowUnusedKeywordArguments: false (default)
|
44
|
+
# # bad
|
45
|
+
# do_something do |unused: 42|
|
46
|
+
# foo
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# @example AllowUnusedKeywordArguments: true
|
50
|
+
# # good
|
51
|
+
# do_something do |unused: 42|
|
52
|
+
# foo
|
53
|
+
# end
|
54
|
+
#
|
39
55
|
class UnusedBlockArgument < Cop
|
40
56
|
include UnusedArgument
|
41
57
|
|
@@ -6,20 +6,38 @@ module RuboCop
|
|
6
6
|
# This cop checks for unused method arguments.
|
7
7
|
#
|
8
8
|
# @example
|
9
|
-
#
|
10
9
|
# # bad
|
11
|
-
#
|
12
10
|
# def some_method(used, unused, _unused_but_allowed)
|
13
11
|
# puts used
|
14
12
|
# end
|
15
13
|
#
|
16
|
-
# @example
|
17
|
-
#
|
18
14
|
# # good
|
19
|
-
#
|
20
15
|
# def some_method(used, _unused, _unused_but_allowed)
|
21
16
|
# puts used
|
22
17
|
# end
|
18
|
+
#
|
19
|
+
# @example AllowUnusedKeywordArguments: false (default)
|
20
|
+
# # bad
|
21
|
+
# def do_something(used, unused: 42)
|
22
|
+
# used
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# @example AllowUnusedKeywordArguments: true
|
26
|
+
# # good
|
27
|
+
# def do_something(used, unused: 42)
|
28
|
+
# used
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# @example IgnoreEmptyMethods: true (default)
|
32
|
+
# # good
|
33
|
+
# def do_something(unused)
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# @example IgnoreEmptyMethods: false
|
37
|
+
# # bad
|
38
|
+
# def do_something(unused)
|
39
|
+
# end
|
40
|
+
#
|
23
41
|
class UnusedMethodArgument < Cop
|
24
42
|
include UnusedArgument
|
25
43
|
|
@@ -6,55 +6,36 @@ module RuboCop
|
|
6
6
|
# This cop checks for operators, variables, literals, and nonmutating
|
7
7
|
# methods used in void context.
|
8
8
|
#
|
9
|
-
# @example
|
10
|
-
#
|
9
|
+
# @example CheckForMethodsWithNoSideEffects: false (default)
|
11
10
|
# # bad
|
12
|
-
#
|
13
11
|
# def some_method
|
14
12
|
# some_num * 10
|
15
13
|
# do_something
|
16
14
|
# end
|
17
15
|
#
|
18
|
-
# @example
|
19
|
-
#
|
20
|
-
# # bad
|
21
|
-
#
|
22
16
|
# def some_method(some_var)
|
23
17
|
# some_var
|
24
18
|
# do_something
|
25
19
|
# end
|
26
20
|
#
|
27
|
-
# @example
|
28
|
-
#
|
29
|
-
# # bad, when CheckForMethodsWithNoSideEffects is set true
|
30
|
-
#
|
21
|
+
# @example CheckForMethodsWithNoSideEffects: true
|
22
|
+
# # bad
|
31
23
|
# def some_method(some_array)
|
32
24
|
# some_array.sort
|
33
25
|
# do_something(some_array)
|
34
26
|
# end
|
35
27
|
#
|
36
|
-
# @example
|
37
|
-
#
|
38
28
|
# # good
|
39
|
-
#
|
40
29
|
# def some_method
|
41
30
|
# do_something
|
42
31
|
# some_num * 10
|
43
32
|
# end
|
44
33
|
#
|
45
|
-
# @example
|
46
|
-
#
|
47
|
-
# # good
|
48
|
-
#
|
49
34
|
# def some_method(some_var)
|
50
35
|
# do_something
|
51
36
|
# some_var
|
52
37
|
# end
|
53
38
|
#
|
54
|
-
# @example
|
55
|
-
#
|
56
|
-
# # good, when CheckForMethodsWithNoSideEffects is set true
|
57
|
-
#
|
58
39
|
# def some_method(some_array)
|
59
40
|
# some_array.sort!
|
60
41
|
# do_something(some_array)
|
@@ -47,6 +47,50 @@ module RuboCop
|
|
47
47
|
# def foo.bar
|
48
48
|
# puts baz
|
49
49
|
# end
|
50
|
+
#
|
51
|
+
# @example RequireForNonPublicMethods: false (default)
|
52
|
+
# # good
|
53
|
+
# class Foo
|
54
|
+
# protected
|
55
|
+
# def do_something
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# class Foo
|
60
|
+
# private
|
61
|
+
# def do_something
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# @example RequireForNonPublicMethods: true
|
66
|
+
# # bad
|
67
|
+
# class Foo
|
68
|
+
# protected
|
69
|
+
# def do_something
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# class Foo
|
74
|
+
# private
|
75
|
+
# def do_something
|
76
|
+
# end
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# # good
|
80
|
+
# class Foo
|
81
|
+
# protected
|
82
|
+
# # Documentation
|
83
|
+
# def do_something
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# class Foo
|
88
|
+
# private
|
89
|
+
# # Documentation
|
90
|
+
# def do_something
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
#
|
50
94
|
class DocumentationMethod < Cop
|
51
95
|
include DocumentationComment
|
52
96
|
include DefNode
|
@@ -8,7 +8,7 @@ module RuboCop
|
|
8
8
|
# **Note:**
|
9
9
|
# `unannotated` style cop only works for strings
|
10
10
|
# which are passed as arguments to those methods:
|
11
|
-
# `sprintf`, `format`, `%`.
|
11
|
+
# `printf`, `sprintf`, `format`, `%`.
|
12
12
|
# The reason is that *unannotated* format is very similar
|
13
13
|
# to encoded URLs or Date/Time formatting strings.
|
14
14
|
#
|
@@ -41,10 +41,7 @@ module RuboCop
|
|
41
41
|
class FormatStringToken < Cop
|
42
42
|
include ConfigurableEnforcedStyle
|
43
43
|
|
44
|
-
FORMAT_STRING_METHODS = %i[sprintf format %].freeze
|
45
|
-
|
46
44
|
def on_str(node)
|
47
|
-
return if placeholder_argument?(node)
|
48
45
|
return if node.each_ancestor(:xstr, :regexp).any?
|
49
46
|
|
50
47
|
tokens(node) do |detected_style, token_range|
|
@@ -61,14 +58,16 @@ module RuboCop
|
|
61
58
|
|
62
59
|
private
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
def_node_matcher :format_string_in_typical_context?, <<~PATTERN
|
62
|
+
{
|
63
|
+
^(send _ {:format :sprintf :printf} %0 ...)
|
64
|
+
^(send %0 :% _)
|
65
|
+
}
|
66
|
+
PATTERN
|
69
67
|
|
70
68
|
def unannotated_format?(node, detected_style)
|
71
|
-
detected_style == :unannotated &&
|
69
|
+
detected_style == :unannotated &&
|
70
|
+
!format_string_in_typical_context?(node)
|
72
71
|
end
|
73
72
|
|
74
73
|
def message(detected_style)
|
@@ -95,11 +94,7 @@ module RuboCop
|
|
95
94
|
if source_map.is_a?(Parser::Source::Map::Heredoc)
|
96
95
|
source_map.heredoc_body
|
97
96
|
elsif source_map.begin
|
98
|
-
|
99
|
-
source_map.expression,
|
100
|
-
source_map.expression.begin_pos + 1,
|
101
|
-
source_map.expression.end_pos - 1
|
102
|
-
)
|
97
|
+
source_map.expression.adjust(begin_pos: +1, end_pos: -1)
|
103
98
|
else
|
104
99
|
source_map.expression
|
105
100
|
end
|
@@ -110,30 +105,14 @@ module RuboCop
|
|
110
105
|
|
111
106
|
format_string.format_sequences.each do |seq|
|
112
107
|
detected_style = seq.style
|
113
|
-
token =
|
114
|
-
|
115
|
-
|
116
|
-
contents.begin_pos + seq.end_pos
|
108
|
+
token = contents.begin.adjust(
|
109
|
+
begin_pos: seq.begin_pos,
|
110
|
+
end_pos: seq.end_pos
|
117
111
|
)
|
118
112
|
|
119
113
|
yield(detected_style, token)
|
120
114
|
end
|
121
115
|
end
|
122
|
-
|
123
|
-
def slice_source(source_range, new_begin, new_end)
|
124
|
-
Parser::Source::Range.new(
|
125
|
-
source_range.source_buffer,
|
126
|
-
new_begin,
|
127
|
-
new_end
|
128
|
-
)
|
129
|
-
end
|
130
|
-
|
131
|
-
def placeholder_argument?(node)
|
132
|
-
return false unless node.parent
|
133
|
-
return true if node.parent.pair_type?
|
134
|
-
|
135
|
-
placeholder_argument?(node.parent)
|
136
|
-
end
|
137
116
|
end
|
138
117
|
end
|
139
118
|
end
|
@@ -64,20 +64,6 @@ module RuboCop
|
|
64
64
|
# # okay with `^assert` listed in `IgnoredPatterns`
|
65
65
|
# assert_equal 'test', x
|
66
66
|
#
|
67
|
-
# # IgnoreMacros: true (default)
|
68
|
-
#
|
69
|
-
# # good
|
70
|
-
# class Foo
|
71
|
-
# bar :baz
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
# # IgnoreMacros: false
|
75
|
-
#
|
76
|
-
# # bad
|
77
|
-
# class Foo
|
78
|
-
# bar :baz
|
79
|
-
# end
|
80
|
-
#
|
81
67
|
# @example EnforcedStyle: omit_parentheses
|
82
68
|
#
|
83
69
|
# # bad
|
@@ -92,7 +78,21 @@ module RuboCop
|
|
92
78
|
# # good
|
93
79
|
# foo.enforce strict: true
|
94
80
|
#
|
95
|
-
#
|
81
|
+
# @example IgnoreMacros: true (default)
|
82
|
+
#
|
83
|
+
# # good
|
84
|
+
# class Foo
|
85
|
+
# bar :baz
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# @example IgnoreMacros: false
|
89
|
+
#
|
90
|
+
# # bad
|
91
|
+
# class Foo
|
92
|
+
# bar :baz
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# @example AllowParenthesesInMultilineCall: false (default)
|
96
96
|
#
|
97
97
|
# # bad
|
98
98
|
# foo.enforce(
|
@@ -103,7 +103,7 @@ module RuboCop
|
|
103
103
|
# foo.enforce \
|
104
104
|
# strict: true
|
105
105
|
#
|
106
|
-
#
|
106
|
+
# @example AllowParenthesesInMultilineCall: true
|
107
107
|
#
|
108
108
|
# # good
|
109
109
|
# foo.enforce(
|
@@ -114,7 +114,7 @@ module RuboCop
|
|
114
114
|
# foo.enforce \
|
115
115
|
# strict: true
|
116
116
|
#
|
117
|
-
#
|
117
|
+
# @example AllowParenthesesInChaining: false (default)
|
118
118
|
#
|
119
119
|
# # bad
|
120
120
|
# foo().bar(1)
|
@@ -122,7 +122,7 @@ module RuboCop
|
|
122
122
|
# # good
|
123
123
|
# foo().bar 1
|
124
124
|
#
|
125
|
-
#
|
125
|
+
# @example AllowParenthesesInChaining: true
|
126
126
|
#
|
127
127
|
# # good
|
128
128
|
# foo().bar(1)
|
@@ -130,7 +130,7 @@ module RuboCop
|
|
130
130
|
# # good
|
131
131
|
# foo().bar 1
|
132
132
|
#
|
133
|
-
#
|
133
|
+
# @example AllowParenthesesInCamelCaseMethod: false (default)
|
134
134
|
#
|
135
135
|
# # bad
|
136
136
|
# Array(1)
|
@@ -138,7 +138,7 @@ module RuboCop
|
|
138
138
|
# # good
|
139
139
|
# Array 1
|
140
140
|
#
|
141
|
-
#
|
141
|
+
# @example AllowParenthesesInCamelCaseMethod: true
|
142
142
|
#
|
143
143
|
# # good
|
144
144
|
# Array(1)
|
@@ -35,6 +35,18 @@ module RuboCop
|
|
35
35
|
# end
|
36
36
|
# end
|
37
37
|
#
|
38
|
+
# @example AllowMultipleReturnValues: false (default)
|
39
|
+
# # bad
|
40
|
+
# def test
|
41
|
+
# return x, y
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# @example AllowMultipleReturnValues: true
|
45
|
+
# # good
|
46
|
+
# def test
|
47
|
+
# return x, y
|
48
|
+
# end
|
49
|
+
#
|
38
50
|
class RedundantReturn < Cop
|
39
51
|
include RangeHelp
|
40
52
|
|
@@ -120,7 +120,7 @@ module RuboCop
|
|
120
120
|
corrector.remove(begin_range(node, body))
|
121
121
|
corrector.remove(end_range(node, body))
|
122
122
|
corrector.insert_before(method_call.loc.dot, '&')
|
123
|
-
handle_comments(corrector, method_call)
|
123
|
+
handle_comments(corrector, node, method_call)
|
124
124
|
|
125
125
|
add_safe_nav_to_all_methods_in_chain(corrector, method_call, body)
|
126
126
|
end
|
@@ -128,12 +128,20 @@ module RuboCop
|
|
128
128
|
|
129
129
|
private
|
130
130
|
|
131
|
-
def handle_comments(corrector, method_call)
|
131
|
+
def handle_comments(corrector, node, method_call)
|
132
132
|
return if processed_source.comments.empty?
|
133
133
|
|
134
|
-
comments = processed_source.comments.map(&:text).join("\n")
|
135
134
|
corrector.insert_before(method_call.loc.expression,
|
136
|
-
comments
|
135
|
+
"#{comments(node).join("\n")}\n")
|
136
|
+
end
|
137
|
+
|
138
|
+
def comments(node)
|
139
|
+
comments = processed_source.comments.select do |comment|
|
140
|
+
comment.loc.first_line >= node.loc.first_line &&
|
141
|
+
comment.loc.last_line <= node.loc.last_line
|
142
|
+
end
|
143
|
+
|
144
|
+
comments.map(&:text)
|
137
145
|
end
|
138
146
|
|
139
147
|
def allowed_if_condition?(node)
|
@@ -6,6 +6,9 @@ module RuboCop
|
|
6
6
|
# This cop checks for multiple expressions placed on the same line.
|
7
7
|
# It also checks for lines terminated with a semicolon.
|
8
8
|
#
|
9
|
+
# This cop has `AllowAsExpressionSeparator` configuration option.
|
10
|
+
# It allows `;` to separate several expressions on the same line.
|
11
|
+
#
|
9
12
|
# @example
|
10
13
|
# # bad
|
11
14
|
# foo = 1; bar = 2;
|
@@ -15,6 +18,14 @@ module RuboCop
|
|
15
18
|
# foo = 1
|
16
19
|
# bar = 2
|
17
20
|
# baz = 3
|
21
|
+
#
|
22
|
+
# @example AllowAsExpressionSeparator: false (default)
|
23
|
+
# # bad
|
24
|
+
# foo = 1; bar = 2
|
25
|
+
#
|
26
|
+
# @example AllowAsExpressionSeparator: true
|
27
|
+
# # good
|
28
|
+
# foo = 1; bar = 2
|
18
29
|
class Semicolon < Cop
|
19
30
|
include RangeHelp
|
20
31
|
|
@@ -15,9 +15,14 @@ module RuboCop
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def report_offense(file, offense)
|
18
|
-
output.printf(
|
19
|
-
|
20
|
-
|
18
|
+
output.printf(
|
19
|
+
"%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
|
20
|
+
path: cyan(smart_path(file)),
|
21
|
+
line: offense.line,
|
22
|
+
column: offense.real_column,
|
23
|
+
severity: colored_severity_code(offense),
|
24
|
+
message: message(offense)
|
25
|
+
)
|
21
26
|
|
22
27
|
# rubocop:disable Lint/HandleExceptions
|
23
28
|
begin
|
@@ -8,20 +8,30 @@ module RuboCop
|
|
8
8
|
class EmacsStyleFormatter < BaseFormatter
|
9
9
|
def file_finished(file, offenses)
|
10
10
|
offenses.each do |o|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
output.printf("%s:%d:%d: %s: %s\n",
|
21
|
-
file, o.line, o.real_column, o.severity.code,
|
22
|
-
message.tr("\n", ' '))
|
11
|
+
output.printf(
|
12
|
+
"%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
|
13
|
+
path: file,
|
14
|
+
line: o.line,
|
15
|
+
column: o.real_column,
|
16
|
+
severity: o.severity.code,
|
17
|
+
message: message(o)
|
18
|
+
)
|
23
19
|
end
|
24
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def message(offense)
|
25
|
+
message =
|
26
|
+
if offense.corrected_with_todo?
|
27
|
+
"[Todo] #{offense.message}"
|
28
|
+
elsif offense.corrected?
|
29
|
+
"[Corrected] #{offense.message}"
|
30
|
+
else
|
31
|
+
offense.message
|
32
|
+
end
|
33
|
+
message.tr("\n", ' ')
|
34
|
+
end
|
25
35
|
end
|
26
36
|
end
|
27
37
|
end
|
@@ -9,21 +9,21 @@ module RuboCop
|
|
9
9
|
# which invoke same method of each formatters.
|
10
10
|
class FormatterSet < Array
|
11
11
|
BUILTIN_FORMATTERS_FOR_KEYS = {
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
12
|
+
'[a]utogenconf' => AutoGenConfigFormatter,
|
13
|
+
'[c]lang' => ClangStyleFormatter,
|
14
|
+
'[d]isabled' => DisabledLinesFormatter,
|
15
|
+
'[e]macs' => EmacsStyleFormatter,
|
16
|
+
'[fi]les' => FileListFormatter,
|
17
|
+
'[fu]ubar' => FuubarStyleFormatter,
|
18
|
+
'[h]tml' => HTMLFormatter,
|
19
|
+
'[j]son' => JSONFormatter,
|
20
|
+
'[o]ffenses' => OffenseCountFormatter,
|
21
|
+
'[pa]cman' => PacmanFormatter,
|
22
|
+
'[p]rogress' => ProgressFormatter,
|
23
|
+
'[q]uiet' => QuietFormatter,
|
24
|
+
'[s]imple' => SimpleTextFormatter,
|
25
|
+
'[t]ap' => TapFormatter,
|
26
|
+
'[w]orst' => WorstOffendersFormatter
|
27
27
|
}.freeze
|
28
28
|
|
29
29
|
FORMATTER_APIS = %i[started finished].freeze
|
@@ -82,7 +82,7 @@ module RuboCop
|
|
82
82
|
|
83
83
|
def builtin_formatter_class(specified_key)
|
84
84
|
matching_keys = BUILTIN_FORMATTERS_FOR_KEYS.keys.select do |key|
|
85
|
-
key.
|
85
|
+
key =~ /^\[#{specified_key}\]/ || specified_key == key.delete('[]')
|
86
86
|
end
|
87
87
|
|
88
88
|
raise %(No formatter for "#{specified_key}") if matching_keys.empty?
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Formatter
|
5
|
-
# This formatter prints a PACDOT per every file to be
|
5
|
+
# This formatter prints a PACDOT per every file to be analyzed.
|
6
6
|
# Pacman will "eat" one PACDOT per file when no offense is detected.
|
7
7
|
# Otherwise it will print a Ghost.
|
8
8
|
# This is inspired by the Pacman formatter for RSpec by Carlos Rojas.
|
@@ -49,7 +49,7 @@ module RuboCop
|
|
49
49
|
|
50
50
|
def cols
|
51
51
|
@cols ||= begin
|
52
|
-
width =
|
52
|
+
_height, width = $stdout.winsize
|
53
53
|
width.nil? || width.zero? ? FALLBACK_TERMINAL_WIDTH : width
|
54
54
|
end
|
55
55
|
end
|
@@ -68,7 +68,7 @@ module RuboCop
|
|
68
68
|
def step(character)
|
69
69
|
regex = /#{Regexp.quote(PACMAN)}|#{Regexp.quote(PACDOT)}/
|
70
70
|
@progress_line = @progress_line.sub(regex, character)
|
71
|
-
output.printf("
|
71
|
+
output.printf("%<line>s\r", line: @progress_line)
|
72
72
|
return unless @progress_line[-1] =~ /ᗣ|\./
|
73
73
|
|
74
74
|
@repetitions += 1
|
@@ -42,9 +42,13 @@ module RuboCop
|
|
42
42
|
output.puts yellow("== #{smart_path(file)} ==")
|
43
43
|
|
44
44
|
offenses.each do |o|
|
45
|
-
output.printf(
|
46
|
-
|
47
|
-
|
45
|
+
output.printf(
|
46
|
+
"%<severity>s:%3<line>d:%3<column>d: %<message>s\n",
|
47
|
+
severity: colored_severity_code(o),
|
48
|
+
line: o.line,
|
49
|
+
column: o.real_column,
|
50
|
+
message: message(o)
|
51
|
+
)
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
@@ -42,9 +42,14 @@ module RuboCop
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def report_offense(file, offense)
|
45
|
-
output.printf(
|
46
|
-
|
47
|
-
|
45
|
+
output.printf(
|
46
|
+
"# %<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
|
47
|
+
path: cyan(smart_path(file)),
|
48
|
+
line: offense.line,
|
49
|
+
column: offense.real_column,
|
50
|
+
severity: colored_severity_code(offense),
|
51
|
+
message: message(offense)
|
52
|
+
)
|
48
53
|
|
49
54
|
# rubocop:disable Lint/HandleExceptions
|
50
55
|
begin
|
data/lib/rubocop/options.rb
CHANGED
@@ -367,8 +367,9 @@ module RuboCop
|
|
367
367
|
# This module contains help texts for command line options.
|
368
368
|
module OptionsHelp
|
369
369
|
MAX_EXCL = RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS.to_s
|
370
|
-
|
371
370
|
# rubocop:disable Metrics/LineLength
|
371
|
+
FORMATTER_OPTION_LIST = RuboCop::Formatter::FormatterSet::BUILTIN_FORMATTERS_FOR_KEYS.keys
|
372
|
+
|
372
373
|
TEXT = {
|
373
374
|
only: 'Run only the given cop(s).',
|
374
375
|
only_guide_cops: ['Run only cops for rules that link to a',
|
@@ -407,21 +408,8 @@ module RuboCop
|
|
407
408
|
format: ['Choose an output formatter. This option',
|
408
409
|
'can be specified multiple times to enable',
|
409
410
|
'multiple formatters at the same time.',
|
410
|
-
'
|
411
|
-
|
412
|
-
' [c]lang',
|
413
|
-
' [d]isabled cops via inline comments',
|
414
|
-
' [fu]ubar',
|
415
|
-
' [pa]cman',
|
416
|
-
' [e]macs',
|
417
|
-
' [j]son',
|
418
|
-
' [h]tml',
|
419
|
-
' [fi]les',
|
420
|
-
' [o]ffenses',
|
421
|
-
' [w]orst',
|
422
|
-
' [t]ap',
|
423
|
-
' [q]uiet',
|
424
|
-
' [a]utogenconf',
|
411
|
+
'[p]rogress is used by default',
|
412
|
+
*FORMATTER_OPTION_LIST.map { |item| " #{item}" },
|
425
413
|
' custom formatter class name'],
|
426
414
|
out: ['Write output to a file instead of STDOUT.',
|
427
415
|
'This option applies to the previously',
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.75.
|
4
|
+
version: 0.75.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-10-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jaro_winkler
|