rubocop 1.18.1 → 1.18.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 716224a3d34c433671a2cb5ffc66f617d96bc6180e8f015e281a0ed4a81025a5
|
4
|
+
data.tar.gz: 8702da6fbac8c2abaabdfbade5d200cac743f591cc73d3e921dc6e37d6a11155
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb87420e2dc381febd58d3bb0960c675622818d5e47a402e8d22592ad2b4ad5262fc381cb69d87263f3c9e3049dd3c87f4da6abfa82c0fd4782d6e0ad44ee7ab
|
7
|
+
data.tar.gz: ab26c4549a6a3037fc8de874b2a60c2a53e270412c3c091d43917d4656ed08fb114a7c1bba30b58d07cbe144e6df361a187f723555224665c5b971023bb1625e
|
data/config/default.yml
CHANGED
@@ -86,10 +86,15 @@ module RuboCop
|
|
86
86
|
|
87
87
|
def strings_concatenated_with_backslash?(dstr_node)
|
88
88
|
!dstr_node.heredoc? &&
|
89
|
+
!single_string_literal?(dstr_node) &&
|
89
90
|
dstr_node.children.length > 1 &&
|
90
91
|
dstr_node.children.all? { |c| c.str_type? || c.dstr_type? }
|
91
92
|
end
|
92
93
|
|
94
|
+
def single_string_literal?(dstr_node)
|
95
|
+
dstr_node.loc.respond_to?(:begin) && dstr_node.loc.begin
|
96
|
+
end
|
97
|
+
|
93
98
|
def always_indented?(dstr_node)
|
94
99
|
PARENT_TYPES_FOR_INDENTED.include?(dstr_node.parent&.type)
|
95
100
|
end
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
# incorrect registering of keywords (eg. `review`) inside a paragraph as an
|
13
13
|
# annotation.
|
14
14
|
#
|
15
|
-
# @example
|
15
|
+
# @example RequireColon: true (default)
|
16
16
|
# # bad
|
17
17
|
# # TODO make better
|
18
18
|
#
|
@@ -36,14 +36,36 @@ module RuboCop
|
|
36
36
|
#
|
37
37
|
# # good
|
38
38
|
# # OPTIMIZE: does not work
|
39
|
+
#
|
40
|
+
# @example RequireColon: false
|
41
|
+
# # bad
|
42
|
+
# # TODO: make better
|
43
|
+
#
|
44
|
+
# # good
|
45
|
+
# # TODO make better
|
46
|
+
#
|
47
|
+
# # bad
|
48
|
+
# # fixme does not work
|
49
|
+
#
|
50
|
+
# # good
|
51
|
+
# # FIXME does not work
|
52
|
+
#
|
53
|
+
# # bad
|
54
|
+
# # Optimize does not work
|
55
|
+
#
|
56
|
+
# # good
|
57
|
+
# # OPTIMIZE does not work
|
39
58
|
class CommentAnnotation < Base
|
40
59
|
include AnnotationComment
|
41
60
|
include RangeHelp
|
42
61
|
extend AutoCorrector
|
43
62
|
|
44
|
-
|
45
|
-
|
46
|
-
|
63
|
+
MSG_COLON_STYLE = 'Annotation keywords like `%<keyword>s` should be all ' \
|
64
|
+
'upper case, followed by a colon, and a space, ' \
|
65
|
+
'then a note describing the problem.'
|
66
|
+
MSG_SPACE_STYLE = 'Annotation keywords like `%<keyword>s` should be all ' \
|
67
|
+
'upper case, followed by a space, ' \
|
68
|
+
'then a note describing the problem.'
|
47
69
|
MISSING_NOTE = 'Annotation comment, with keyword `%<keyword>s`, is missing a note.'
|
48
70
|
|
49
71
|
def on_new_investigation
|
@@ -63,13 +85,15 @@ module RuboCop
|
|
63
85
|
private
|
64
86
|
|
65
87
|
def register_offense(range, note, first_word)
|
88
|
+
message = requires_colon? ? MSG_COLON_STYLE : MSG_SPACE_STYLE
|
89
|
+
|
66
90
|
add_offense(
|
67
91
|
range,
|
68
|
-
message: format(note ?
|
92
|
+
message: format(note ? message : MISSING_NOTE, keyword: first_word)
|
69
93
|
) do |corrector|
|
70
94
|
next if note.nil?
|
71
95
|
|
72
|
-
corrector
|
96
|
+
correct_offense(corrector, range, first_word)
|
73
97
|
end
|
74
98
|
end
|
75
99
|
|
@@ -92,8 +116,28 @@ module RuboCop
|
|
92
116
|
end
|
93
117
|
|
94
118
|
def correct_annotation?(first_word, colon, space, note)
|
119
|
+
return correct_colon_annotation?(first_word, colon, space, note) if requires_colon?
|
120
|
+
|
121
|
+
correct_space_annotation?(first_word, colon, space, note)
|
122
|
+
end
|
123
|
+
|
124
|
+
def correct_colon_annotation?(first_word, colon, space, note)
|
95
125
|
keyword?(first_word) && (colon && space && note || !colon && !note)
|
96
126
|
end
|
127
|
+
|
128
|
+
def correct_space_annotation?(first_word, colon, space, note)
|
129
|
+
keyword?(first_word) && (!colon && space && note || !colon && !note)
|
130
|
+
end
|
131
|
+
|
132
|
+
def correct_offense(corrector, range, first_word)
|
133
|
+
return corrector.replace(range, "#{first_word.upcase}: ") if requires_colon?
|
134
|
+
|
135
|
+
corrector.replace(range, "#{first_word.upcase} ")
|
136
|
+
end
|
137
|
+
|
138
|
+
def requires_colon?
|
139
|
+
cop_config['RequireColon']
|
140
|
+
end
|
97
141
|
end
|
98
142
|
end
|
99
143
|
end
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.18.
|
4
|
+
version: 1.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
8
8
|
- Jonas Arvidsson
|
9
9
|
- Yuji Nakayama
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -885,7 +885,7 @@ metadata:
|
|
885
885
|
source_code_uri: https://github.com/rubocop/rubocop/
|
886
886
|
documentation_uri: https://docs.rubocop.org/rubocop/1.18/
|
887
887
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
888
|
-
post_install_message:
|
888
|
+
post_install_message:
|
889
889
|
rdoc_options: []
|
890
890
|
require_paths:
|
891
891
|
- lib
|
@@ -900,8 +900,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
900
900
|
- !ruby/object:Gem::Version
|
901
901
|
version: '0'
|
902
902
|
requirements: []
|
903
|
-
rubygems_version: 3.
|
904
|
-
signing_key:
|
903
|
+
rubygems_version: 3.2.18
|
904
|
+
signing_key:
|
905
905
|
specification_version: 4
|
906
906
|
summary: Automatic Ruby code style checking tool.
|
907
907
|
test_files: []
|