rubocop 1.60.2 → 1.61.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/assets/output.css.erb +159 -0
- data/assets/output.html.erb +1 -160
- data/config/default.yml +35 -12
- data/lib/rubocop/cli/command/lsp.rb +2 -2
- data/lib/rubocop/cli.rb +6 -1
- data/lib/rubocop/config_finder.rb +12 -2
- data/lib/rubocop/config_validator.rb +14 -5
- data/lib/rubocop/cop/autocorrect_logic.rb +6 -1
- data/lib/rubocop/cop/base.rb +12 -7
- data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +5 -13
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +2 -0
- data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
- data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/end_alignment.rb +3 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +14 -9
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -3
- data/lib/rubocop/cop/lint/script_permission.rb +3 -3
- data/lib/rubocop/cop/lint/syntax.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +6 -1
- data/lib/rubocop/cop/naming/predicate_name.rb +2 -2
- data/lib/rubocop/cop/registry.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +29 -8
- data/lib/rubocop/cop/style/case_like_if.rb +1 -1
- data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
- data/lib/rubocop/cop/style/conditional_assignment.rb +4 -5
- data/lib/rubocop/cop/style/hash_syntax.rb +6 -2
- data/lib/rubocop/cop/style/inverse_methods.rb +8 -8
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +10 -5
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +5 -8
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +4 -0
- data/lib/rubocop/cop/style/object_then.rb +5 -3
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -3
- data/lib/rubocop/cop/style/raise_args.rb +3 -0
- data/lib/rubocop/cop/style/redundant_argument.rb +2 -2
- data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +16 -5
- data/lib/rubocop/cop/style/redundant_return.rb +6 -0
- data/lib/rubocop/cop/style/sample.rb +1 -3
- data/lib/rubocop/cops_documentation_generator.rb +4 -2
- data/lib/rubocop/formatter/html_formatter.rb +30 -10
- data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
- data/lib/rubocop/lsp/logger.rb +1 -1
- data/lib/rubocop/lsp/routes.rb +1 -1
- data/lib/rubocop/lsp/runtime.rb +1 -1
- data/lib/rubocop/lsp/server.rb +5 -2
- data/lib/rubocop/lsp/severity.rb +1 -1
- data/lib/rubocop/lsp.rb +29 -0
- data/lib/rubocop/options.rb +11 -0
- data/lib/rubocop/path_util.rb +6 -2
- data/lib/rubocop/rspec/shared_contexts.rb +10 -6
- data/lib/rubocop/rspec/support.rb +1 -1
- data/lib/rubocop/target_ruby.rb +79 -79
- data/lib/rubocop/version.rb +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 506b140c491cce5d643f22ac7a58396d82f19162c8bc22b2741f67a551913b07
|
4
|
+
data.tar.gz: 51032873c1ce81903898c952ee828e6753a566faa204c7821f9d8a4cbbddf75d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aa5ca182c9a0905f8b7c45408722a9885e0ac2ac104ed03e57386afa2c8323a0ce8489ed12abfcd7e169faaac428901a83d2301aa1fcaff2a84c1a2897d81f7
|
7
|
+
data.tar.gz: 3f6d87ac3565d097f962bb24fa6b8c32851e622548a7b603e2c801ef27e1002ff816ec25aff8e461799fa1ee897b875409919f67120c9f9c47e0a19c881f9840
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
53
53
|
in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 1.
|
56
|
+
gem 'rubocop', '~> 1.61', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -0,0 +1,159 @@
|
|
1
|
+
* {
|
2
|
+
-webkit-box-sizing: border-box;
|
3
|
+
-moz-box-sizing: border-box;
|
4
|
+
box-sizing: border-box;
|
5
|
+
}
|
6
|
+
|
7
|
+
body, html {
|
8
|
+
font-size: 62.5%;
|
9
|
+
}
|
10
|
+
body {
|
11
|
+
background-color: #ecedf0;
|
12
|
+
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
13
|
+
margin: 0;
|
14
|
+
}
|
15
|
+
code {
|
16
|
+
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
17
|
+
font-size: 85%;
|
18
|
+
}
|
19
|
+
#header {
|
20
|
+
background: #f9f9f9;
|
21
|
+
color: #333;
|
22
|
+
border-bottom: 3px solid #ccc;
|
23
|
+
height: 50px;
|
24
|
+
padding: 0;
|
25
|
+
}
|
26
|
+
#header .logo {
|
27
|
+
float: left;
|
28
|
+
margin: 5px 12px 7px 20px;
|
29
|
+
width: 38px;
|
30
|
+
height: 38px;
|
31
|
+
}
|
32
|
+
#header .title {
|
33
|
+
display: inline-block;
|
34
|
+
float: left;
|
35
|
+
height: 50px;
|
36
|
+
font-size: 2.4rem;
|
37
|
+
letter-spacing: normal;
|
38
|
+
line-height: 50px;
|
39
|
+
margin: 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
.information, #offenses {
|
43
|
+
width: 100%;
|
44
|
+
padding: 20px;
|
45
|
+
color: #333;
|
46
|
+
}
|
47
|
+
#offenses {
|
48
|
+
padding: 0 20px;
|
49
|
+
}
|
50
|
+
|
51
|
+
.information .infobox {
|
52
|
+
border-left: 3px solid;
|
53
|
+
border-radius: 4px;
|
54
|
+
background-color: #fff;
|
55
|
+
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
56
|
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
57
|
+
padding: 15px;
|
58
|
+
border-color: #0088cc;
|
59
|
+
font-size: 1.4rem;
|
60
|
+
}
|
61
|
+
.information .infobox .info-title {
|
62
|
+
font-size: 1.8rem;
|
63
|
+
line-height: 2.2rem;
|
64
|
+
margin: 0 0 0.5em;
|
65
|
+
}
|
66
|
+
.information .offenses-list li {
|
67
|
+
line-height: 1.8rem
|
68
|
+
}
|
69
|
+
.information .offenses-list {
|
70
|
+
padding-left: 20px;
|
71
|
+
margin-bottom: 0;
|
72
|
+
}
|
73
|
+
|
74
|
+
#offenses .offense-box {
|
75
|
+
border-radius: 4px;
|
76
|
+
margin-bottom: 20px;
|
77
|
+
background-color: #fff;
|
78
|
+
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
79
|
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
80
|
+
}
|
81
|
+
.fixed .box-title {
|
82
|
+
position: fixed;
|
83
|
+
top: 0;
|
84
|
+
z-index: 10;
|
85
|
+
width: 100%;
|
86
|
+
}
|
87
|
+
.box-title-placeholder {
|
88
|
+
display: none;
|
89
|
+
}
|
90
|
+
.fixed .box-title-placeholder {
|
91
|
+
display: block;
|
92
|
+
}
|
93
|
+
#offenses .offense-box .box-title h3, #offenses .offense-box .box-title-placeholder h3 {
|
94
|
+
color: #33353f;
|
95
|
+
background-color: #f6f6f6;
|
96
|
+
font-size: 2rem;
|
97
|
+
line-height: 2rem;
|
98
|
+
display: block;
|
99
|
+
padding: 15px;
|
100
|
+
border-radius: 5px;
|
101
|
+
margin: 0;
|
102
|
+
}
|
103
|
+
#offenses .offense-box .offense-reports {
|
104
|
+
padding: 0 15px;
|
105
|
+
}
|
106
|
+
#offenses .offense-box .offense-reports .report {
|
107
|
+
border-bottom: 1px dotted #ddd;
|
108
|
+
padding: 15px 0px;
|
109
|
+
position: relative;
|
110
|
+
font-size: 1.3rem;
|
111
|
+
}
|
112
|
+
#offenses .offense-box .offense-reports .report:last-child {
|
113
|
+
border-bottom: none;
|
114
|
+
}
|
115
|
+
#offenses .offense-box .offense-reports .report pre code {
|
116
|
+
display: block;
|
117
|
+
background: #000;
|
118
|
+
color: #fff;
|
119
|
+
padding: 10px 15px;
|
120
|
+
border-radius: 5px;
|
121
|
+
line-height: 1.6rem;
|
122
|
+
}
|
123
|
+
#offenses .offense-box .offense-reports .report .location {
|
124
|
+
font-weight: bold;
|
125
|
+
}
|
126
|
+
#offenses .offense-box .offense-reports .report .message code {
|
127
|
+
padding: 0.3em;
|
128
|
+
background-color: rgba(0,0,0,0.07);
|
129
|
+
border-radius: 3px;
|
130
|
+
}
|
131
|
+
.severity {
|
132
|
+
text-transform: capitalize;
|
133
|
+
font-weight: bold;
|
134
|
+
}
|
135
|
+
.highlight {
|
136
|
+
padding: 2px;
|
137
|
+
border-radius: 2px;
|
138
|
+
font-weight: bold;
|
139
|
+
}
|
140
|
+
<%- SEVERITY_COLORS.each do |severity, color| %>
|
141
|
+
.severity.<%= severity %> {
|
142
|
+
color: <%= color %>;
|
143
|
+
}
|
144
|
+
.highlight.<%= severity %> {
|
145
|
+
background-color: <%= color.fade_out(0.4) %>;
|
146
|
+
border: 1px solid <%= color.fade_out(0.6) %>;
|
147
|
+
}
|
148
|
+
<%- end %>
|
149
|
+
footer {
|
150
|
+
margin-bottom: 20px;
|
151
|
+
margin-right: 20px;
|
152
|
+
font-size: 1.3rem;
|
153
|
+
color: #777;
|
154
|
+
text-align: right;
|
155
|
+
}
|
156
|
+
.extra-code {
|
157
|
+
color: #ED9C28
|
158
|
+
}
|
159
|
+
|
data/assets/output.html.erb
CHANGED
@@ -3,168 +3,9 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset='UTF-8' />
|
5
5
|
<title>RuboCop Inspection Report</title>
|
6
|
-
<%# TODO: Clean up the messy markup and style definitions. %>
|
7
6
|
<style>
|
8
|
-
|
9
|
-
-webkit-box-sizing: border-box;
|
10
|
-
-moz-box-sizing: border-box;
|
11
|
-
box-sizing: border-box;
|
12
|
-
}
|
13
|
-
|
14
|
-
body, html {
|
15
|
-
font-size: 62.5%;
|
16
|
-
}
|
17
|
-
body {
|
18
|
-
background-color: #ecedf0;
|
19
|
-
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
20
|
-
margin: 0;
|
21
|
-
}
|
22
|
-
code {
|
23
|
-
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
24
|
-
font-size: 85%;
|
25
|
-
}
|
26
|
-
#header {
|
27
|
-
background: #f9f9f9;
|
28
|
-
color: #333;
|
29
|
-
border-bottom: 3px solid #ccc;
|
30
|
-
height: 50px;
|
31
|
-
padding: 0;
|
32
|
-
}
|
33
|
-
#header .logo {
|
34
|
-
float: left;
|
35
|
-
margin: 5px 12px 7px 20px;
|
36
|
-
width: 38px;
|
37
|
-
height: 38px;
|
38
|
-
}
|
39
|
-
#header .title {
|
40
|
-
display: inline-block;
|
41
|
-
float: left;
|
42
|
-
height: 50px;
|
43
|
-
font-size: 2.4rem;
|
44
|
-
letter-spacing: normal;
|
45
|
-
line-height: 50px;
|
46
|
-
margin: 0;
|
47
|
-
}
|
48
|
-
|
49
|
-
.information, #offenses {
|
50
|
-
width: 100%;
|
51
|
-
padding: 20px;
|
52
|
-
color: #333;
|
53
|
-
}
|
54
|
-
#offenses {
|
55
|
-
padding: 0 20px;
|
56
|
-
}
|
57
|
-
|
58
|
-
.information .infobox {
|
59
|
-
border-left: 3px solid;
|
60
|
-
border-radius: 4px;
|
61
|
-
background-color: #fff;
|
62
|
-
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
63
|
-
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
64
|
-
padding: 15px;
|
65
|
-
border-color: #0088cc;
|
66
|
-
font-size: 1.4rem;
|
67
|
-
}
|
68
|
-
.information .infobox .info-title {
|
69
|
-
font-size: 1.8rem;
|
70
|
-
line-height: 2.2rem;
|
71
|
-
margin: 0 0 0.5em;
|
72
|
-
}
|
73
|
-
.information .offenses-list li {
|
74
|
-
line-height: 1.8rem
|
75
|
-
}
|
76
|
-
.information .offenses-list {
|
77
|
-
padding-left: 20px;
|
78
|
-
margin-bottom: 0;
|
79
|
-
}
|
80
|
-
|
81
|
-
#offenses .offense-box {
|
82
|
-
border-radius: 4px;
|
83
|
-
margin-bottom: 20px;
|
84
|
-
background-color: #fff;
|
85
|
-
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
86
|
-
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
87
|
-
}
|
88
|
-
.fixed .box-title {
|
89
|
-
position: fixed;
|
90
|
-
top: 0;
|
91
|
-
z-index: 10;
|
92
|
-
width: 100%;
|
93
|
-
}
|
94
|
-
.box-title-placeholder {
|
95
|
-
display: none;
|
96
|
-
}
|
97
|
-
.fixed .box-title-placeholder {
|
98
|
-
display: block;
|
99
|
-
}
|
100
|
-
#offenses .offense-box .box-title h3, #offenses .offense-box .box-title-placeholder h3 {
|
101
|
-
color: #33353f;
|
102
|
-
background-color: #f6f6f6;
|
103
|
-
font-size: 2rem;
|
104
|
-
line-height: 2rem;
|
105
|
-
display: block;
|
106
|
-
padding: 15px;
|
107
|
-
border-radius: 5px;
|
108
|
-
margin: 0;
|
109
|
-
}
|
110
|
-
#offenses .offense-box .offense-reports {
|
111
|
-
padding: 0 15px;
|
112
|
-
}
|
113
|
-
#offenses .offense-box .offense-reports .report {
|
114
|
-
border-bottom: 1px dotted #ddd;
|
115
|
-
padding: 15px 0px;
|
116
|
-
position: relative;
|
117
|
-
font-size: 1.3rem;
|
118
|
-
}
|
119
|
-
#offenses .offense-box .offense-reports .report:last-child {
|
120
|
-
border-bottom: none;
|
121
|
-
}
|
122
|
-
#offenses .offense-box .offense-reports .report pre code {
|
123
|
-
display: block;
|
124
|
-
background: #000;
|
125
|
-
color: #fff;
|
126
|
-
padding: 10px 15px;
|
127
|
-
border-radius: 5px;
|
128
|
-
line-height: 1.6rem;
|
129
|
-
}
|
130
|
-
#offenses .offense-box .offense-reports .report .location {
|
131
|
-
font-weight: bold;
|
132
|
-
}
|
133
|
-
#offenses .offense-box .offense-reports .report .message code {
|
134
|
-
padding: 0.3em;
|
135
|
-
background-color: rgba(0,0,0,0.07);
|
136
|
-
border-radius: 3px;
|
137
|
-
}
|
138
|
-
.severity {
|
139
|
-
text-transform: capitalize;
|
140
|
-
font-weight: bold;
|
141
|
-
}
|
142
|
-
.highlight {
|
143
|
-
padding: 2px;
|
144
|
-
border-radius: 2px;
|
145
|
-
font-weight: bold;
|
146
|
-
}
|
147
|
-
<%- SEVERITY_COLORS.each do |severity, color| %>
|
148
|
-
.severity.<%= severity %> {
|
149
|
-
color: <%= color %>;
|
150
|
-
}
|
151
|
-
.highlight.<%= severity %> {
|
152
|
-
background-color: <%= color.fade_out(0.4) %>;
|
153
|
-
border: 1px solid <%= color.fade_out(0.6) %>;
|
154
|
-
}
|
155
|
-
<%- end %>
|
156
|
-
footer {
|
157
|
-
margin-bottom: 20px;
|
158
|
-
margin-right: 20px;
|
159
|
-
font-size: 1.3rem;
|
160
|
-
color: #777;
|
161
|
-
text-align: right;
|
162
|
-
}
|
163
|
-
.extra-code {
|
164
|
-
color: #ED9C28
|
165
|
-
}
|
7
|
+
<%= render_css %>
|
166
8
|
</style>
|
167
|
-
|
168
9
|
<script>
|
169
10
|
(function() {
|
170
11
|
// floating headers. requires classList support.
|
data/config/default.yml
CHANGED
@@ -556,7 +556,9 @@ Layout/ElseAlignment:
|
|
556
556
|
Layout/EmptyComment:
|
557
557
|
Description: 'Checks empty comment.'
|
558
558
|
Enabled: true
|
559
|
+
AutoCorrect: contextual
|
559
560
|
VersionAdded: '0.53'
|
561
|
+
VersionChanged: '1.61'
|
560
562
|
AllowBorderComment: true
|
561
563
|
AllowMarginComment: true
|
562
564
|
|
@@ -1825,16 +1827,18 @@ Lint/EmptyClass:
|
|
1825
1827
|
Lint/EmptyConditionalBody:
|
1826
1828
|
Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
|
1827
1829
|
Enabled: true
|
1830
|
+
AutoCorrect: contextual
|
1828
1831
|
SafeAutoCorrect: false
|
1829
1832
|
AllowComments: true
|
1830
1833
|
VersionAdded: '0.89'
|
1831
|
-
VersionChanged: '1.
|
1834
|
+
VersionChanged: '1.61'
|
1832
1835
|
|
1833
1836
|
Lint/EmptyEnsure:
|
1834
1837
|
Description: 'Checks for empty ensure block.'
|
1835
1838
|
Enabled: true
|
1839
|
+
AutoCorrect: contextual
|
1836
1840
|
VersionAdded: '0.10'
|
1837
|
-
VersionChanged: '
|
1841
|
+
VersionChanged: '1.61'
|
1838
1842
|
|
1839
1843
|
Lint/EmptyExpression:
|
1840
1844
|
Description: 'Checks for empty expressions.'
|
@@ -1856,8 +1860,9 @@ Lint/EmptyInPattern:
|
|
1856
1860
|
Lint/EmptyInterpolation:
|
1857
1861
|
Description: 'Checks for empty string interpolation.'
|
1858
1862
|
Enabled: true
|
1863
|
+
AutoCorrect: contextual
|
1859
1864
|
VersionAdded: '0.20'
|
1860
|
-
VersionChanged: '
|
1865
|
+
VersionChanged: '1.61'
|
1861
1866
|
|
1862
1867
|
Lint/EmptyWhen:
|
1863
1868
|
Description: 'Checks for `when` branches with empty bodies.'
|
@@ -2395,7 +2400,9 @@ Lint/TopLevelReturnWithArgument:
|
|
2395
2400
|
Lint/TrailingCommaInAttributeDeclaration:
|
2396
2401
|
Description: 'Checks for trailing commas in attribute declarations.'
|
2397
2402
|
Enabled: true
|
2403
|
+
AutoCorrect: contextual
|
2398
2404
|
VersionAdded: '0.90'
|
2405
|
+
VersionChanged: '1.61'
|
2399
2406
|
|
2400
2407
|
Lint/TripleQuotes:
|
2401
2408
|
Description: 'Checks for useless triple quote constructs.'
|
@@ -2455,8 +2462,9 @@ Lint/UnusedBlockArgument:
|
|
2455
2462
|
Description: 'Checks for unused block arguments.'
|
2456
2463
|
StyleGuide: '#underscore-unused-vars'
|
2457
2464
|
Enabled: true
|
2465
|
+
AutoCorrect: contextual
|
2458
2466
|
VersionAdded: '0.21'
|
2459
|
-
VersionChanged: '
|
2467
|
+
VersionChanged: '1.61'
|
2460
2468
|
IgnoreEmptyBlocks: true
|
2461
2469
|
AllowUnusedKeywordArguments: false
|
2462
2470
|
|
@@ -2464,8 +2472,9 @@ Lint/UnusedMethodArgument:
|
|
2464
2472
|
Description: 'Checks for unused method arguments.'
|
2465
2473
|
StyleGuide: '#underscore-unused-vars'
|
2466
2474
|
Enabled: true
|
2475
|
+
AutoCorrect: contextual
|
2467
2476
|
VersionAdded: '0.21'
|
2468
|
-
VersionChanged: '
|
2477
|
+
VersionChanged: '1.61'
|
2469
2478
|
AllowUnusedKeywordArguments: false
|
2470
2479
|
IgnoreEmptyMethods: true
|
2471
2480
|
IgnoreNotImplementedMethods: true
|
@@ -2489,8 +2498,9 @@ Lint/UriRegexp:
|
|
2489
2498
|
Lint/UselessAccessModifier:
|
2490
2499
|
Description: 'Checks for useless access modifiers.'
|
2491
2500
|
Enabled: true
|
2501
|
+
AutoCorrect: contextual
|
2492
2502
|
VersionAdded: '0.20'
|
2493
|
-
VersionChanged: '
|
2503
|
+
VersionChanged: '1.61'
|
2494
2504
|
ContextCreatingMethods: []
|
2495
2505
|
MethodCreatingMethods: []
|
2496
2506
|
|
@@ -2498,8 +2508,9 @@ Lint/UselessAssignment:
|
|
2498
2508
|
Description: 'Checks for useless assignment to a local variable.'
|
2499
2509
|
StyleGuide: '#underscore-unused-vars'
|
2500
2510
|
Enabled: true
|
2511
|
+
AutoCorrect: contextual
|
2501
2512
|
VersionAdded: '0.11'
|
2502
|
-
VersionChanged: '1.
|
2513
|
+
VersionChanged: '1.61'
|
2503
2514
|
SafeAutoCorrect: false
|
2504
2515
|
|
2505
2516
|
Lint/UselessElseWithoutRescue:
|
@@ -2511,8 +2522,9 @@ Lint/UselessElseWithoutRescue:
|
|
2511
2522
|
Lint/UselessMethodDefinition:
|
2512
2523
|
Description: 'Checks for useless method definitions.'
|
2513
2524
|
Enabled: true
|
2525
|
+
AutoCorrect: contextual
|
2514
2526
|
VersionAdded: '0.90'
|
2515
|
-
VersionChanged: '
|
2527
|
+
VersionChanged: '1.61'
|
2516
2528
|
Safe: false
|
2517
2529
|
|
2518
2530
|
Lint/UselessRescue:
|
@@ -2535,13 +2547,17 @@ Lint/UselessSetterCall:
|
|
2535
2547
|
Lint/UselessTimes:
|
2536
2548
|
Description: 'Checks for useless `Integer#times` calls.'
|
2537
2549
|
Enabled: true
|
2538
|
-
VersionAdded: '0.91'
|
2539
2550
|
Safe: false
|
2551
|
+
AutoCorrect: contextual
|
2552
|
+
VersionAdded: '0.91'
|
2553
|
+
VersionChanged: '1.61'
|
2540
2554
|
|
2541
2555
|
Lint/Void:
|
2542
2556
|
Description: 'Possible use of operator/literal/variable in void context.'
|
2543
2557
|
Enabled: true
|
2558
|
+
AutoCorrect: contextual
|
2544
2559
|
VersionAdded: '0.9'
|
2560
|
+
VersionChanged: '1.61'
|
2545
2561
|
CheckForMethodsWithNoSideEffects: false
|
2546
2562
|
|
2547
2563
|
#################### Metrics ###############################
|
@@ -3701,8 +3717,9 @@ Style/EmptyCaseCondition:
|
|
3701
3717
|
Style/EmptyElse:
|
3702
3718
|
Description: 'Avoid empty else-clauses.'
|
3703
3719
|
Enabled: true
|
3720
|
+
AutoCorrect: contextual
|
3704
3721
|
VersionAdded: '0.28'
|
3705
|
-
VersionChanged: '
|
3722
|
+
VersionChanged: '1.61'
|
3706
3723
|
EnforcedStyle: both
|
3707
3724
|
# empty - warn only on empty `else`
|
3708
3725
|
# nil - warn on `else` with nil in it
|
@@ -3716,7 +3733,9 @@ Style/EmptyElse:
|
|
3716
3733
|
Style/EmptyHeredoc:
|
3717
3734
|
Description: 'Checks for using empty heredoc to reduce redundancy.'
|
3718
3735
|
Enabled: pending
|
3736
|
+
AutoCorrect: contextual
|
3719
3737
|
VersionAdded: '1.32'
|
3738
|
+
VersionChanged: '1.61'
|
3720
3739
|
|
3721
3740
|
Style/EmptyLambdaParameter:
|
3722
3741
|
Description: 'Omit parens for empty lambda parameters.'
|
@@ -3734,7 +3753,9 @@ Style/EmptyMethod:
|
|
3734
3753
|
Description: 'Checks the formatting of empty method definitions.'
|
3735
3754
|
StyleGuide: '#no-single-line-methods'
|
3736
3755
|
Enabled: true
|
3756
|
+
AutoCorrect: contextual
|
3737
3757
|
VersionAdded: '0.46'
|
3758
|
+
VersionChanged: '1.61'
|
3738
3759
|
EnforcedStyle: compact
|
3739
3760
|
SupportedStyles:
|
3740
3761
|
- compact
|
@@ -4835,8 +4856,9 @@ Style/RaiseArgs:
|
|
4835
4856
|
Description: 'Checks the arguments passed to raise/fail.'
|
4836
4857
|
StyleGuide: '#exception-class-messages'
|
4837
4858
|
Enabled: true
|
4859
|
+
Safe: false
|
4838
4860
|
VersionAdded: '0.14'
|
4839
|
-
VersionChanged: '1.
|
4861
|
+
VersionChanged: '1.61'
|
4840
4862
|
EnforcedStyle: exploded
|
4841
4863
|
SupportedStyles:
|
4842
4864
|
- compact # raise Exception.new(msg)
|
@@ -4977,10 +4999,11 @@ Style/RedundantHeredocDelimiterQuotes:
|
|
4977
4999
|
Style/RedundantInitialize:
|
4978
5000
|
Description: 'Checks for redundant `initialize` methods.'
|
4979
5001
|
Enabled: pending
|
5002
|
+
AutoCorrect: contextual
|
4980
5003
|
Safe: false
|
4981
5004
|
AllowComments: true
|
4982
5005
|
VersionAdded: '1.27'
|
4983
|
-
VersionChanged: '1.
|
5006
|
+
VersionChanged: '1.61'
|
4984
5007
|
|
4985
5008
|
Style/RedundantInterpolation:
|
4986
5009
|
Description: 'Checks for strings that are just an interpolated expression.'
|
@@ -7,11 +7,11 @@ module RuboCop
|
|
7
7
|
module Command
|
8
8
|
# Start Language Server Protocol of RuboCop.
|
9
9
|
# @api private
|
10
|
-
class
|
10
|
+
class LSP < Base
|
11
11
|
self.command_name = :lsp
|
12
12
|
|
13
13
|
def run
|
14
|
-
RuboCop::
|
14
|
+
RuboCop::LSP::Server.new(@config_store).start
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/rubocop/cli.rb
CHANGED
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
STATUS_INTERRUPTED = Signal.list['INT'] + 128
|
13
13
|
DEFAULT_PARALLEL_OPTIONS = %i[
|
14
14
|
color config debug display_style_guide display_time display_only_fail_level_offenses
|
15
|
-
display_only_failed except extra_details fail_level fix_layout format
|
15
|
+
display_only_failed editor_mode except extra_details fail_level fix_layout format
|
16
16
|
ignore_disable_comments lint only only_guide_cops require safe
|
17
17
|
autocorrect safe_autocorrect autocorrect_all
|
18
18
|
].freeze
|
@@ -151,6 +151,7 @@ module RuboCop
|
|
151
151
|
|
152
152
|
def act_on_options
|
153
153
|
set_options_to_config_loader
|
154
|
+
handle_editor_mode
|
154
155
|
|
155
156
|
@config_store.options_config = @options[:config] if @options[:config]
|
156
157
|
@config_store.force_default_config! if @options[:force_default_config]
|
@@ -174,6 +175,10 @@ module RuboCop
|
|
174
175
|
ConfigLoader.ignore_unrecognized_cops = @options[:ignore_unrecognized_cops]
|
175
176
|
end
|
176
177
|
|
178
|
+
def handle_editor_mode
|
179
|
+
RuboCop::LSP.enable if @options[:editor_mode]
|
180
|
+
end
|
181
|
+
|
177
182
|
# rubocop:disable Metrics/CyclomaticComplexity
|
178
183
|
def handle_exiting_options
|
179
184
|
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
|
@@ -17,8 +17,8 @@ module RuboCop
|
|
17
17
|
attr_writer :project_root
|
18
18
|
|
19
19
|
def find_config_path(target_dir)
|
20
|
-
find_project_dotfile(target_dir) ||
|
21
|
-
DEFAULT_FILE
|
20
|
+
find_project_dotfile(target_dir) || find_project_root_dot_config ||
|
21
|
+
find_user_dotfile || find_user_xdg_config || DEFAULT_FILE
|
22
22
|
end
|
23
23
|
|
24
24
|
# Returns the path RuboCop inferred as the root of the project. No file
|
@@ -41,6 +41,16 @@ module RuboCop
|
|
41
41
|
find_file_upwards(DOTFILE, target_dir, project_root)
|
42
42
|
end
|
43
43
|
|
44
|
+
def find_project_root_dot_config
|
45
|
+
return unless project_root
|
46
|
+
|
47
|
+
dotfile = File.join(project_root, '.config', DOTFILE)
|
48
|
+
return dotfile if File.exist?(dotfile)
|
49
|
+
|
50
|
+
xdg_config = File.join(project_root, '.config', 'rubocop', XDG_CONFIG)
|
51
|
+
xdg_config if File.exist?(xdg_config)
|
52
|
+
end
|
53
|
+
|
44
54
|
def find_user_dotfile
|
45
55
|
return unless ENV.key?('HOME')
|
46
56
|
|
@@ -18,6 +18,7 @@ module RuboCop
|
|
18
18
|
# @api private
|
19
19
|
CONFIG_CHECK_KEYS = %w[Enabled Safe SafeAutoCorrect AutoCorrect].to_set.freeze
|
20
20
|
CONFIG_CHECK_DEPARTMENTS = %w[pending override_department].freeze
|
21
|
+
CONFIG_CHECK_AUTOCORRECTS = %w[always contextual disabled].freeze
|
21
22
|
private_constant :CONFIG_CHECK_KEYS, :CONFIG_CHECK_DEPARTMENTS
|
22
23
|
|
23
24
|
def_delegators :@config, :smart_loaded_path, :for_all_cops
|
@@ -248,23 +249,31 @@ module RuboCop
|
|
248
249
|
end
|
249
250
|
end
|
250
251
|
|
252
|
+
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
251
253
|
def check_cop_config_value(hash, parent = nil)
|
252
254
|
hash.each do |key, value|
|
253
255
|
check_cop_config_value(value, key) if value.is_a?(Hash)
|
254
256
|
|
255
257
|
next unless CONFIG_CHECK_KEYS.include?(key) && value.is_a?(String)
|
256
258
|
|
257
|
-
|
259
|
+
if key == 'Enabled' && !CONFIG_CHECK_DEPARTMENTS.include?(value)
|
260
|
+
supposed_values = 'a boolean'
|
261
|
+
elsif key == 'AutoCorrect' && !CONFIG_CHECK_AUTOCORRECTS.include?(value)
|
262
|
+
supposed_values = '`always`, `contextual`, `disabled`, or a boolean'
|
263
|
+
else
|
264
|
+
next
|
265
|
+
end
|
258
266
|
|
259
|
-
raise ValidationError,
|
267
|
+
raise ValidationError, param_error_message(parent, key, value, supposed_values)
|
260
268
|
end
|
261
269
|
end
|
270
|
+
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
262
271
|
|
263
272
|
# FIXME: Handling colors in exception messages like this is ugly.
|
264
|
-
def
|
273
|
+
def param_error_message(parent, key, value, supposed_values)
|
265
274
|
"#{Rainbow('').reset}" \
|
266
|
-
"Property #{Rainbow(key).yellow} of
|
267
|
-
"is supposed to be
|
275
|
+
"Property #{Rainbow(key).yellow} of #{Rainbow(parent).yellow} cop " \
|
276
|
+
"is supposed to be #{supposed_values} and #{Rainbow(value).yellow} is not."
|
268
277
|
end
|
269
278
|
end
|
270
279
|
end
|
@@ -32,7 +32,12 @@ module RuboCop
|
|
32
32
|
# allow turning off autocorrect on a cop by cop basis
|
33
33
|
return true unless cop_config
|
34
34
|
|
35
|
-
|
35
|
+
# `false` is the same as `disabled` for backward compatibility.
|
36
|
+
return false if ['disabled', false].include?(cop_config['AutoCorrect'])
|
37
|
+
|
38
|
+
# When LSP is enabled, it is considered as editing source code,
|
39
|
+
# and autocorrection with `AutoCorrect: contextual` will not be performed.
|
40
|
+
return false if contextual_autocorrect? && LSP.enabled?
|
36
41
|
|
37
42
|
# :safe_autocorrect is a derived option based on several command-line
|
38
43
|
# arguments - see RuboCop::Options#add_autocorrection_options
|
data/lib/rubocop/cop/base.rb
CHANGED
@@ -305,6 +305,17 @@ module RuboCop
|
|
305
305
|
@current_original = original
|
306
306
|
end
|
307
307
|
|
308
|
+
# @api private
|
309
|
+
def always_autocorrect?
|
310
|
+
# `true` is the same as `'always'` for backward compatibility.
|
311
|
+
['always', true].include?(cop_config.fetch('AutoCorrect', 'always'))
|
312
|
+
end
|
313
|
+
|
314
|
+
# @api private
|
315
|
+
def contextual_autocorrect?
|
316
|
+
cop_config.fetch('AutoCorrect', 'always') == 'contextual'
|
317
|
+
end
|
318
|
+
|
308
319
|
def inspect # :nodoc:
|
309
320
|
"#<#{self.class.name}:#{object_id} @config=#{@config} @options=#{@options}>"
|
310
321
|
end
|
@@ -389,7 +400,7 @@ module RuboCop
|
|
389
400
|
def use_corrector(range, corrector)
|
390
401
|
if autocorrect?
|
391
402
|
attempt_correction(range, corrector)
|
392
|
-
elsif corrector &&
|
403
|
+
elsif corrector && (always_autocorrect? || (contextual_autocorrect? && !LSP.enabled?))
|
393
404
|
:uncorrected
|
394
405
|
else
|
395
406
|
:unsupported
|
@@ -481,12 +492,6 @@ module RuboCop
|
|
481
492
|
range.end_pos + @current_offset
|
482
493
|
)
|
483
494
|
end
|
484
|
-
|
485
|
-
# This experimental feature has been under consideration for a while.
|
486
|
-
# @api private
|
487
|
-
def lsp_mode?
|
488
|
-
ARGV.include?('--lsp')
|
489
|
-
end
|
490
495
|
end
|
491
496
|
end
|
492
497
|
end
|