rubocop 1.60.2 → 1.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +41 -12
- data/lib/rubocop/cli/command/auto_generate_config.rb +12 -3
- data/lib/rubocop/cli/command/lsp.rb +2 -2
- data/lib/rubocop/cli.rb +6 -1
- data/lib/rubocop/config.rb +4 -0
- 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 +17 -8
- 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 +5 -1
- data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +122 -28
- 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/empty_line_after_magic_comment.rb +14 -7
- data/lib/rubocop/cop/layout/end_alignment.rb +3 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +11 -3
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
- 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/redundant_with_index.rb +1 -0
- 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/to_enum_arguments.rb +7 -2
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +6 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -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/class_vars.rb +3 -3
- 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/for.rb +2 -0
- data/lib/rubocop/cop/style/hash_each_methods.rb +1 -1
- 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_method_signature.rb +10 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +4 -0
- data/lib/rubocop/cop/style/nil_comparison.rb +2 -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 +4 -1
- 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_current_directory_in_path.rb +4 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +17 -6
- data/lib/rubocop/cop/style/redundant_return.rb +6 -0
- data/lib/rubocop/cop/style/sample.rb +1 -3
- data/lib/rubocop/cop/utils/regexp_ranges.rb +1 -1
- data/lib/rubocop/cops_documentation_generator.rb +4 -2
- data/lib/rubocop/directive_comment.rb +10 -8
- 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/magic_comment.rb +1 -1
- data/lib/rubocop/options.rb +11 -0
- data/lib/rubocop/path_util.rb +6 -2
- data/lib/rubocop/rspec/cop_helper.rb +8 -2
- data/lib/rubocop/rspec/expect_offense.rb +8 -8
- data/lib/rubocop/rspec/shared_contexts.rb +36 -17
- data/lib/rubocop/rspec/support.rb +2 -1
- data/lib/rubocop/runner.rb +9 -2
- data/lib/rubocop/target_finder.rb +84 -78
- data/lib/rubocop/target_ruby.rb +82 -80
- data/lib/rubocop/version.rb +18 -3
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8daa4ef7dd74b8608039d7dfda5f1e3fe739738949390a6f1347acaccf7bd1c4
|
4
|
+
data.tar.gz: 271a978db956def596a5b06a7fd69d189d807b27db0acdda03fd6200b95ef541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484294f43781f114ba01470b22331ef17648219e26dc4ba2f28073f609c909af2997c47e1f1aad62860124f6f4594a2e536cd793f05352a78d588f979732a290
|
7
|
+
data.tar.gz: 6a8313e61422bcd568eea747c0f9a88f61f50620b4dd4f478da0bdd3e067c1aa8bcf70e15744e02118d4c525eb0632fae3cc19caf73db6db1f63ea76dbb84b45
|
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.62', 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
@@ -144,6 +144,12 @@ AllCops:
|
|
144
144
|
# Ruby version is still unresolved, RuboCop will use the oldest officially
|
145
145
|
# supported Ruby version (currently Ruby 2.7).
|
146
146
|
TargetRubyVersion: ~
|
147
|
+
# You can specify the parser engine. There are two options available:
|
148
|
+
# - `parser_whitequark` ... https://github.com/whitequark/parser
|
149
|
+
# - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
|
150
|
+
# By default, `parser` is used. For the `TargetRubyVersion` value, `parser` can be specified for versions `2.0` and above.
|
151
|
+
# `parser_prism` can be specified for versions `3.3` and above. `parser_prism` is faster but still considered experimental.
|
152
|
+
ParserEngine: parser_whitequark
|
147
153
|
# Determines if a notification for extension libraries should be shown when
|
148
154
|
# rubocop is run. Keys are the name of the extension, and values are an array
|
149
155
|
# of gems in the Gemfile that the extension is suggested for, if not already
|
@@ -556,7 +562,9 @@ Layout/ElseAlignment:
|
|
556
562
|
Layout/EmptyComment:
|
557
563
|
Description: 'Checks empty comment.'
|
558
564
|
Enabled: true
|
565
|
+
AutoCorrect: contextual
|
559
566
|
VersionAdded: '0.53'
|
567
|
+
VersionChanged: '1.61'
|
560
568
|
AllowBorderComment: true
|
561
569
|
AllowMarginComment: true
|
562
570
|
|
@@ -1825,16 +1833,18 @@ Lint/EmptyClass:
|
|
1825
1833
|
Lint/EmptyConditionalBody:
|
1826
1834
|
Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
|
1827
1835
|
Enabled: true
|
1836
|
+
AutoCorrect: contextual
|
1828
1837
|
SafeAutoCorrect: false
|
1829
1838
|
AllowComments: true
|
1830
1839
|
VersionAdded: '0.89'
|
1831
|
-
VersionChanged: '1.
|
1840
|
+
VersionChanged: '1.61'
|
1832
1841
|
|
1833
1842
|
Lint/EmptyEnsure:
|
1834
1843
|
Description: 'Checks for empty ensure block.'
|
1835
1844
|
Enabled: true
|
1845
|
+
AutoCorrect: contextual
|
1836
1846
|
VersionAdded: '0.10'
|
1837
|
-
VersionChanged: '
|
1847
|
+
VersionChanged: '1.61'
|
1838
1848
|
|
1839
1849
|
Lint/EmptyExpression:
|
1840
1850
|
Description: 'Checks for empty expressions.'
|
@@ -1856,8 +1866,9 @@ Lint/EmptyInPattern:
|
|
1856
1866
|
Lint/EmptyInterpolation:
|
1857
1867
|
Description: 'Checks for empty string interpolation.'
|
1858
1868
|
Enabled: true
|
1869
|
+
AutoCorrect: contextual
|
1859
1870
|
VersionAdded: '0.20'
|
1860
|
-
VersionChanged: '
|
1871
|
+
VersionChanged: '1.61'
|
1861
1872
|
|
1862
1873
|
Lint/EmptyWhen:
|
1863
1874
|
Description: 'Checks for `when` branches with empty bodies.'
|
@@ -2395,7 +2406,9 @@ Lint/TopLevelReturnWithArgument:
|
|
2395
2406
|
Lint/TrailingCommaInAttributeDeclaration:
|
2396
2407
|
Description: 'Checks for trailing commas in attribute declarations.'
|
2397
2408
|
Enabled: true
|
2409
|
+
AutoCorrect: contextual
|
2398
2410
|
VersionAdded: '0.90'
|
2411
|
+
VersionChanged: '1.61'
|
2399
2412
|
|
2400
2413
|
Lint/TripleQuotes:
|
2401
2414
|
Description: 'Checks for useless triple quote constructs.'
|
@@ -2455,8 +2468,9 @@ Lint/UnusedBlockArgument:
|
|
2455
2468
|
Description: 'Checks for unused block arguments.'
|
2456
2469
|
StyleGuide: '#underscore-unused-vars'
|
2457
2470
|
Enabled: true
|
2471
|
+
AutoCorrect: contextual
|
2458
2472
|
VersionAdded: '0.21'
|
2459
|
-
VersionChanged: '
|
2473
|
+
VersionChanged: '1.61'
|
2460
2474
|
IgnoreEmptyBlocks: true
|
2461
2475
|
AllowUnusedKeywordArguments: false
|
2462
2476
|
|
@@ -2464,8 +2478,9 @@ Lint/UnusedMethodArgument:
|
|
2464
2478
|
Description: 'Checks for unused method arguments.'
|
2465
2479
|
StyleGuide: '#underscore-unused-vars'
|
2466
2480
|
Enabled: true
|
2481
|
+
AutoCorrect: contextual
|
2467
2482
|
VersionAdded: '0.21'
|
2468
|
-
VersionChanged: '
|
2483
|
+
VersionChanged: '1.61'
|
2469
2484
|
AllowUnusedKeywordArguments: false
|
2470
2485
|
IgnoreEmptyMethods: true
|
2471
2486
|
IgnoreNotImplementedMethods: true
|
@@ -2489,8 +2504,9 @@ Lint/UriRegexp:
|
|
2489
2504
|
Lint/UselessAccessModifier:
|
2490
2505
|
Description: 'Checks for useless access modifiers.'
|
2491
2506
|
Enabled: true
|
2507
|
+
AutoCorrect: contextual
|
2492
2508
|
VersionAdded: '0.20'
|
2493
|
-
VersionChanged: '
|
2509
|
+
VersionChanged: '1.61'
|
2494
2510
|
ContextCreatingMethods: []
|
2495
2511
|
MethodCreatingMethods: []
|
2496
2512
|
|
@@ -2498,8 +2514,9 @@ Lint/UselessAssignment:
|
|
2498
2514
|
Description: 'Checks for useless assignment to a local variable.'
|
2499
2515
|
StyleGuide: '#underscore-unused-vars'
|
2500
2516
|
Enabled: true
|
2517
|
+
AutoCorrect: contextual
|
2501
2518
|
VersionAdded: '0.11'
|
2502
|
-
VersionChanged: '1.
|
2519
|
+
VersionChanged: '1.61'
|
2503
2520
|
SafeAutoCorrect: false
|
2504
2521
|
|
2505
2522
|
Lint/UselessElseWithoutRescue:
|
@@ -2511,8 +2528,9 @@ Lint/UselessElseWithoutRescue:
|
|
2511
2528
|
Lint/UselessMethodDefinition:
|
2512
2529
|
Description: 'Checks for useless method definitions.'
|
2513
2530
|
Enabled: true
|
2531
|
+
AutoCorrect: contextual
|
2514
2532
|
VersionAdded: '0.90'
|
2515
|
-
VersionChanged: '
|
2533
|
+
VersionChanged: '1.61'
|
2516
2534
|
Safe: false
|
2517
2535
|
|
2518
2536
|
Lint/UselessRescue:
|
@@ -2535,13 +2553,17 @@ Lint/UselessSetterCall:
|
|
2535
2553
|
Lint/UselessTimes:
|
2536
2554
|
Description: 'Checks for useless `Integer#times` calls.'
|
2537
2555
|
Enabled: true
|
2538
|
-
VersionAdded: '0.91'
|
2539
2556
|
Safe: false
|
2557
|
+
AutoCorrect: contextual
|
2558
|
+
VersionAdded: '0.91'
|
2559
|
+
VersionChanged: '1.61'
|
2540
2560
|
|
2541
2561
|
Lint/Void:
|
2542
2562
|
Description: 'Possible use of operator/literal/variable in void context.'
|
2543
2563
|
Enabled: true
|
2564
|
+
AutoCorrect: contextual
|
2544
2565
|
VersionAdded: '0.9'
|
2566
|
+
VersionChanged: '1.61'
|
2545
2567
|
CheckForMethodsWithNoSideEffects: false
|
2546
2568
|
|
2547
2569
|
#################### Metrics ###############################
|
@@ -3701,8 +3723,9 @@ Style/EmptyCaseCondition:
|
|
3701
3723
|
Style/EmptyElse:
|
3702
3724
|
Description: 'Avoid empty else-clauses.'
|
3703
3725
|
Enabled: true
|
3726
|
+
AutoCorrect: contextual
|
3704
3727
|
VersionAdded: '0.28'
|
3705
|
-
VersionChanged: '
|
3728
|
+
VersionChanged: '1.61'
|
3706
3729
|
EnforcedStyle: both
|
3707
3730
|
# empty - warn only on empty `else`
|
3708
3731
|
# nil - warn on `else` with nil in it
|
@@ -3716,7 +3739,9 @@ Style/EmptyElse:
|
|
3716
3739
|
Style/EmptyHeredoc:
|
3717
3740
|
Description: 'Checks for using empty heredoc to reduce redundancy.'
|
3718
3741
|
Enabled: pending
|
3742
|
+
AutoCorrect: contextual
|
3719
3743
|
VersionAdded: '1.32'
|
3744
|
+
VersionChanged: '1.61'
|
3720
3745
|
|
3721
3746
|
Style/EmptyLambdaParameter:
|
3722
3747
|
Description: 'Omit parens for empty lambda parameters.'
|
@@ -3734,7 +3759,9 @@ Style/EmptyMethod:
|
|
3734
3759
|
Description: 'Checks the formatting of empty method definitions.'
|
3735
3760
|
StyleGuide: '#no-single-line-methods'
|
3736
3761
|
Enabled: true
|
3762
|
+
AutoCorrect: contextual
|
3737
3763
|
VersionAdded: '0.46'
|
3764
|
+
VersionChanged: '1.61'
|
3738
3765
|
EnforcedStyle: compact
|
3739
3766
|
SupportedStyles:
|
3740
3767
|
- compact
|
@@ -4835,8 +4862,9 @@ Style/RaiseArgs:
|
|
4835
4862
|
Description: 'Checks the arguments passed to raise/fail.'
|
4836
4863
|
StyleGuide: '#exception-class-messages'
|
4837
4864
|
Enabled: true
|
4865
|
+
Safe: false
|
4838
4866
|
VersionAdded: '0.14'
|
4839
|
-
VersionChanged: '1.
|
4867
|
+
VersionChanged: '1.61'
|
4840
4868
|
EnforcedStyle: exploded
|
4841
4869
|
SupportedStyles:
|
4842
4870
|
- compact # raise Exception.new(msg)
|
@@ -4977,10 +5005,11 @@ Style/RedundantHeredocDelimiterQuotes:
|
|
4977
5005
|
Style/RedundantInitialize:
|
4978
5006
|
Description: 'Checks for redundant `initialize` methods.'
|
4979
5007
|
Enabled: pending
|
5008
|
+
AutoCorrect: contextual
|
4980
5009
|
Safe: false
|
4981
5010
|
AllowComments: true
|
4982
5011
|
VersionAdded: '1.27'
|
4983
|
-
VersionChanged: '1.
|
5012
|
+
VersionChanged: '1.61'
|
4984
5013
|
|
4985
5014
|
Style/RedundantInterpolation:
|
4986
5015
|
Description: 'Checks for strings that are just an interpolated expression.'
|
@@ -17,7 +17,10 @@ module RuboCop
|
|
17
17
|
|
18
18
|
PHASE_1_OVERRIDDEN = '(skipped because the default Layout/LineLength:Max is overridden)'
|
19
19
|
PHASE_1_DISABLED = '(skipped because Layout/LineLength is disabled)'
|
20
|
-
|
20
|
+
PHASE_1_SKIPPED_ONLY_COPS =
|
21
|
+
'(skipped because a list of cops is passed to the `--only` flag)'
|
22
|
+
PHASE_1_SKIPPED_ONLY_EXCLUDE =
|
23
|
+
'(skipped because only excludes will be generated due to `--auto-gen-only-exclude` flag)'
|
21
24
|
|
22
25
|
def run
|
23
26
|
add_formatter
|
@@ -29,12 +32,14 @@ module RuboCop
|
|
29
32
|
private
|
30
33
|
|
31
34
|
def maybe_run_line_length_cop
|
32
|
-
if
|
35
|
+
if only_exclude?
|
36
|
+
skip_line_length_cop(PHASE_1_SKIPPED_ONLY_EXCLUDE)
|
37
|
+
elsif !line_length_enabled?(@config_store.for_pwd)
|
33
38
|
skip_line_length_cop(PHASE_1_DISABLED)
|
34
39
|
elsif !same_max_line_length?(@config_store.for_pwd, ConfigLoader.default_configuration)
|
35
40
|
skip_line_length_cop(PHASE_1_OVERRIDDEN)
|
36
41
|
elsif options_has_only_flag?
|
37
|
-
skip_line_length_cop(
|
42
|
+
skip_line_length_cop(PHASE_1_SKIPPED_ONLY_COPS)
|
38
43
|
else
|
39
44
|
run_line_length_cop
|
40
45
|
end
|
@@ -65,6 +70,10 @@ module RuboCop
|
|
65
70
|
@options[:only]
|
66
71
|
end
|
67
72
|
|
73
|
+
def only_exclude?
|
74
|
+
@options[:auto_gen_only_exclude]
|
75
|
+
end
|
76
|
+
|
68
77
|
# Do an initial run with only Layout/LineLength so that cops that
|
69
78
|
# depend on Layout/LineLength:Max get the correct value for that
|
70
79
|
# parameter.
|
@@ -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 }
|
data/lib/rubocop/config.rb
CHANGED
@@ -244,6 +244,10 @@ module RuboCop
|
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
247
|
+
def parser_engine
|
248
|
+
@parser_engine ||= for_all_cops.fetch('ParserEngine', :parser_whitequark).to_sym
|
249
|
+
end
|
250
|
+
|
247
251
|
def target_rails_version
|
248
252
|
@target_rails_version ||=
|
249
253
|
if for_all_cops['TargetRailsVersion']
|
@@ -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
|
|