rubocop 0.31.0 → 0.35.0
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/CHANGELOG.md +315 -0
- data/README.md +199 -38
- data/config/default.yml +91 -12
- data/config/disabled.yml +45 -4
- data/config/enabled.yml +107 -9
- data/lib/rubocop/ast_node.rb +48 -0
- data/lib/rubocop/cli.rb +11 -1
- data/lib/rubocop/comment_config.rb +4 -1
- data/lib/rubocop/config.rb +26 -17
- data/lib/rubocop/config_loader.rb +61 -14
- data/lib/rubocop/cop/commissioner.rb +7 -12
- data/lib/rubocop/cop/cop.rb +43 -20
- data/lib/rubocop/cop/lint/block_alignment.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +69 -0
- data/lib/rubocop/cop/lint/debugger.rb +9 -48
- data/lib/rubocop/cop/lint/def_end_alignment.rb +8 -4
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +42 -23
- data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -2
- data/lib/rubocop/cop/lint/duplicated_key.rb +37 -0
- data/lib/rubocop/cop/lint/end_alignment.rb +33 -13
- data/lib/rubocop/cop/lint/eval.rb +6 -2
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +175 -0
- data/lib/rubocop/cop/lint/literal_in_condition.rb +0 -5
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +10 -0
- data/lib/rubocop/cop/lint/nested_method_definition.rb +31 -0
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +19 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_disable.rb +72 -0
- data/lib/rubocop/cop/lint/unused_block_argument.rb +6 -0
- data/lib/rubocop/cop/lint/unused_method_argument.rb +8 -0
- data/lib/rubocop/cop/metrics/abc_size.rb +17 -6
- data/lib/rubocop/cop/metrics/class_length.rb +1 -1
- data/lib/rubocop/cop/metrics/method_length.rb +1 -3
- data/lib/rubocop/cop/metrics/module_length.rb +1 -1
- data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +1 -1
- data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -2
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +28 -4
- data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +26 -3
- data/lib/rubocop/cop/mixin/check_assignment.rb +2 -3
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +59 -12
- data/lib/rubocop/cop/mixin/configurable_max.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_naming.rb +14 -3
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -3
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +10 -1
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +41 -0
- data/lib/rubocop/cop/mixin/if_node.rb +10 -0
- data/lib/rubocop/cop/mixin/method_preference.rb +28 -0
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
- data/lib/rubocop/cop/mixin/on_method_def.rb +4 -5
- data/lib/rubocop/cop/mixin/safe_assignment.rb +3 -14
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +8 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +8 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -7
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
- data/lib/rubocop/cop/mixin/surrounding_space.rb +5 -4
- data/lib/rubocop/cop/offense.rb +16 -3
- data/lib/rubocop/cop/performance/case_when_splat.rb +160 -0
- data/lib/rubocop/cop/performance/count.rb +35 -30
- data/lib/rubocop/cop/performance/detect.rb +16 -3
- data/lib/rubocop/cop/performance/fixed_size.rb +50 -0
- data/lib/rubocop/cop/performance/flat_map.rb +3 -3
- data/lib/rubocop/cop/performance/sample.rb +103 -59
- data/lib/rubocop/cop/performance/size.rb +2 -1
- data/lib/rubocop/cop/performance/string_replacement.rb +187 -0
- data/lib/rubocop/cop/rails/action_filter.rb +31 -5
- data/lib/rubocop/cop/rails/date.rb +15 -14
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +97 -0
- data/lib/rubocop/cop/rails/read_write_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/time_zone.rb +46 -18
- data/lib/rubocop/cop/style/alias.rb +1 -0
- data/lib/rubocop/cop/style/align_hash.rb +8 -15
- data/lib/rubocop/cop/style/align_parameters.rb +19 -7
- data/lib/rubocop/cop/style/and_or.rb +42 -13
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +2 -1
- data/lib/rubocop/cop/style/block_comments.rb +4 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +69 -24
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +40 -12
- data/lib/rubocop/cop/style/case_indentation.rb +18 -4
- data/lib/rubocop/cop/style/collection_methods.rb +2 -20
- data/lib/rubocop/cop/style/command_literal.rb +2 -10
- data/lib/rubocop/cop/style/comment_annotation.rb +29 -8
- data/lib/rubocop/cop/style/copyright.rb +5 -3
- data/lib/rubocop/cop/style/documentation.rb +21 -12
- data/lib/rubocop/cop/style/dot_position.rb +6 -0
- data/lib/rubocop/cop/style/double_negation.rb +4 -15
- data/lib/rubocop/cop/style/each_with_object.rb +17 -4
- data/lib/rubocop/cop/style/else_alignment.rb +2 -1
- data/lib/rubocop/cop/style/empty_else.rb +25 -0
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +39 -14
- data/lib/rubocop/cop/style/encoding.rb +10 -4
- data/lib/rubocop/cop/style/extra_spacing.rb +126 -5
- data/lib/rubocop/cop/style/first_array_element_line_break.rb +41 -0
- data/lib/rubocop/cop/style/first_hash_element_line_break.rb +35 -0
- data/lib/rubocop/cop/style/first_method_argument_line_break.rb +37 -0
- data/lib/rubocop/cop/style/first_method_parameter_line_break.rb +42 -0
- data/lib/rubocop/cop/style/first_parameter_indentation.rb +5 -3
- data/lib/rubocop/cop/style/for.rb +2 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +5 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +32 -5
- data/lib/rubocop/cop/style/indent_hash.rb +67 -37
- data/lib/rubocop/cop/style/indentation_width.rb +36 -10
- data/lib/rubocop/cop/style/initial_indentation.rb +37 -0
- data/lib/rubocop/cop/style/leading_comment_space.rb +3 -2
- data/lib/rubocop/cop/style/method_call_parentheses.rb +28 -1
- data/lib/rubocop/cop/style/method_def_parentheses.rb +10 -7
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +21 -24
- data/lib/rubocop/cop/style/mutable_constant.rb +35 -0
- data/lib/rubocop/cop/style/nested_modifier.rb +97 -0
- data/lib/rubocop/cop/style/next.rb +50 -15
- data/lib/rubocop/cop/style/non_nil_check.rb +12 -8
- data/lib/rubocop/cop/style/one_line_conditional.rb +8 -4
- data/lib/rubocop/cop/style/option_hash.rb +64 -0
- data/lib/rubocop/cop/style/optional_arguments.rb +49 -0
- data/lib/rubocop/cop/style/parallel_assignment.rb +218 -0
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +3 -66
- data/lib/rubocop/cop/style/predicate_name.rb +7 -2
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -13
- data/lib/rubocop/cop/style/redundant_freeze.rb +37 -0
- data/lib/rubocop/cop/style/redundant_return.rb +32 -3
- data/lib/rubocop/cop/style/regexp_literal.rb +2 -10
- data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +81 -0
- data/lib/rubocop/cop/style/rescue_modifier.rb +30 -22
- data/lib/rubocop/cop/style/send.rb +18 -0
- data/lib/rubocop/cop/style/signal_exception.rb +24 -11
- data/lib/rubocop/cop/style/single_line_methods.rb +8 -9
- data/lib/rubocop/cop/style/single_space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/style/space_around_operators.rb +2 -0
- data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +61 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +4 -2
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +108 -0
- data/lib/rubocop/cop/style/string_methods.rb +32 -0
- data/lib/rubocop/cop/style/struct_inheritance.rb +11 -10
- data/lib/rubocop/cop/style/symbol_literal.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +62 -13
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +9 -1
- data/lib/rubocop/cop/style/trailing_comma.rb +17 -7
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +23 -2
- data/lib/rubocop/cop/style/trivial_accessors.rb +10 -1
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +31 -20
- data/lib/rubocop/cop/style/variable_name.rb +5 -0
- data/lib/rubocop/cop/style/while_until_do.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +15 -2
- data/lib/rubocop/cop/team.rb +25 -5
- data/lib/rubocop/cop/util.rb +7 -2
- data/lib/rubocop/cop/variable_force/locatable.rb +6 -6
- data/lib/rubocop/cop/variable_force.rb +10 -10
- data/lib/rubocop/formatter/base_formatter.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +70 -8
- data/lib/rubocop/formatter/formatter_set.rb +27 -1
- data/lib/rubocop/formatter/progress_formatter.rb +10 -2
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/node_pattern.rb +390 -0
- data/lib/rubocop/options.rb +148 -81
- data/lib/rubocop/processed_source.rb +7 -2
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/remote_config.rb +60 -0
- data/lib/rubocop/result_cache.rb +123 -0
- data/lib/rubocop/runner.rb +85 -22
- data/lib/rubocop/target_finder.rb +4 -4
- data/lib/rubocop/token.rb +2 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop/warning.rb +11 -0
- data/lib/rubocop.rb +32 -3
- data/relnotes/v0.32.0.md +139 -0
- data/relnotes/v0.32.1.md +122 -0
- data/relnotes/v0.33.0.md +157 -0
- data/relnotes/v0.34.0.md +182 -0
- data/relnotes/v0.34.1.md +129 -0
- data/relnotes/v0.34.2.md +139 -0
- data/relnotes/v0.35.0.md +210 -0
- data/rubocop.gemspec +4 -4
- metadata +50 -12
- data/lib/rubocop/cop/performance/parallel_assignment.rb +0 -79
data/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
[](http://badge.fury.io/rb/rubocop)
|
|
2
2
|
[](https://gemnasium.com/bbatsov/rubocop)
|
|
3
3
|
[](https://travis-ci.org/bbatsov/rubocop)
|
|
4
|
-
[](https://coveralls.io/r/bbatsov/rubocop)
|
|
5
5
|
[](https://codeclimate.com/github/bbatsov/rubocop)
|
|
6
6
|
[](http://inch-ci.org/github/bbatsov/rubocop)
|
|
7
|
-
[](https://www.gratipay.com/bbatsov/)
|
|
8
7
|
|
|
9
8
|
<p align="center">
|
|
10
|
-
<img src="https://raw.
|
|
9
|
+
<img src="https://raw.githubusercontent.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
|
|
11
10
|
</p>
|
|
12
11
|
|
|
13
12
|
> Role models are important. <br/>
|
|
@@ -25,9 +24,11 @@ automatically fix some of the problems for you.
|
|
|
25
24
|
|
|
26
25
|
[](https://gitter.im/bbatsov/rubocop?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
27
26
|
|
|
28
|
-
You can support my work on RuboCop
|
|
27
|
+
You can support my work on RuboCop via
|
|
28
|
+
[Salt](https://salt.bountysource.com/teams/rubocop) and
|
|
29
|
+
[Gratipay](https://gratipay.com/rubocop/).
|
|
29
30
|
|
|
30
|
-
[](https://gratipay.com/
|
|
31
|
+
[](https://gratipay.com/rubocop/)
|
|
31
32
|
|
|
32
33
|
**This documentation tracks the `master` branch of RuboCop. Some of
|
|
33
34
|
the features and settings discussed here might not be available in
|
|
@@ -70,8 +71,14 @@ specific RuboCop release.**
|
|
|
70
71
|
- [LightTable](#lighttable)
|
|
71
72
|
- [RubyMine](#rubymine)
|
|
72
73
|
- [Other Editors](#other-editors)
|
|
74
|
+
- [Git pre-commit hook integration](#git-pre-commit-hook-integration)
|
|
73
75
|
- [Guard integration](#guard-integration)
|
|
74
76
|
- [Rake integration](#rake-integration)
|
|
77
|
+
- [Caching](#caching)
|
|
78
|
+
- [Cache Validity](#cache-validity)
|
|
79
|
+
- [Enabling and Disabling the Cache](#enabling-and-disabling-the-cache)
|
|
80
|
+
- [Cache Path](#cache-path)
|
|
81
|
+
- [Cache Pruning](#cache-pruning)
|
|
75
82
|
- [Extensions](#extensions)
|
|
76
83
|
- [Loading Extensions](#loading-extensions)
|
|
77
84
|
- [Custom Cops](#custom-cops)
|
|
@@ -90,13 +97,13 @@ specific RuboCop release.**
|
|
|
90
97
|
|
|
91
98
|
**RuboCop**'s installation is pretty standard:
|
|
92
99
|
|
|
93
|
-
```
|
|
100
|
+
```sh
|
|
94
101
|
$ gem install rubocop
|
|
95
102
|
```
|
|
96
103
|
|
|
97
104
|
If you'd rather install RuboCop using `bundler`, don't require it in your `Gemfile`:
|
|
98
105
|
|
|
99
|
-
```
|
|
106
|
+
```rb
|
|
100
107
|
gem 'rubocop', require: false
|
|
101
108
|
```
|
|
102
109
|
|
|
@@ -105,13 +112,13 @@ gem 'rubocop', require: false
|
|
|
105
112
|
Running `rubocop` with no arguments will check all Ruby source files
|
|
106
113
|
in the current directory:
|
|
107
114
|
|
|
108
|
-
```
|
|
115
|
+
```sh
|
|
109
116
|
$ rubocop
|
|
110
117
|
```
|
|
111
118
|
|
|
112
119
|
Alternatively you can pass `rubocop` a list of files and directories to check:
|
|
113
120
|
|
|
114
|
-
```
|
|
121
|
+
```sh
|
|
115
122
|
$ rubocop app spec lib/something.rb
|
|
116
123
|
```
|
|
117
124
|
|
|
@@ -151,7 +158,7 @@ test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
|
|
|
151
158
|
|
|
152
159
|
For more details check the available command-line options:
|
|
153
160
|
|
|
154
|
-
```
|
|
161
|
+
```sh
|
|
155
162
|
$ rubocop -h
|
|
156
163
|
```
|
|
157
164
|
|
|
@@ -159,9 +166,12 @@ Command flag | Description
|
|
|
159
166
|
--------------------------|------------------------------------------------------------
|
|
160
167
|
`-v/--version` | Displays the current version and exits.
|
|
161
168
|
`-V/--verbose-version` | Displays the current version plus the version of Parser and Ruby.
|
|
169
|
+
`-L/--list-target-files` | List all files RuboCop will inspect.
|
|
162
170
|
`-F/--fail-fast` | Inspects in modification time order and stops after first file with offenses.
|
|
171
|
+
`-C/--cache` | Store and reuse results for faster operation.
|
|
163
172
|
`-d/--debug` | Displays some extra debug output.
|
|
164
173
|
`-D/--display-cop-names` | Displays cop names in offense messages.
|
|
174
|
+
`-E/--extra-details` | Displays extra details in offense messages.
|
|
165
175
|
`-c/--config` | Run with specified config file.
|
|
166
176
|
`-f/--format` | Choose a formatter.
|
|
167
177
|
`-o/--out` | Write output to a file instead of STDOUT.
|
|
@@ -172,8 +182,10 @@ Command flag | Description
|
|
|
172
182
|
`--only` | Run only the specified cop(s) and/or cops in the specified departments.
|
|
173
183
|
`--except` | Run all cops enabled by configuration except the specified cop(s) and/or departments.
|
|
174
184
|
`--auto-gen-config` | Generate a configuration file acting as a TODO list.
|
|
185
|
+
`--exclude-limit` | Limit how many individual files `--auto-gen-config` can list in `Exclude` parameters, default is 15.
|
|
175
186
|
`--show-cops` | Shows available cops and their configuration.
|
|
176
187
|
`--fail-level` | Minimum [severity](#severity) for exit with error code. Full severity name or upper case initial can be given. Normally, auto-corrected offenses are ignored. Use `A` or `autocorrect` if you'd like them to trigger failure.
|
|
188
|
+
`-s/--stdin` | Pipe source from STDIN. This is useful for editor integration.
|
|
177
189
|
|
|
178
190
|
### Cops
|
|
179
191
|
|
|
@@ -196,7 +208,7 @@ code. RuboCop implements in a portable way all built-in MRI lint
|
|
|
196
208
|
checks (`ruby -wc`) and adds a lot of extra lint checks of its
|
|
197
209
|
own. You can run only the lint cops like this:
|
|
198
210
|
|
|
199
|
-
```
|
|
211
|
+
```sh
|
|
200
212
|
$ rubocop -l
|
|
201
213
|
```
|
|
202
214
|
|
|
@@ -219,7 +231,7 @@ Rails cops are specific to the Ruby on Rails framework. Unlike style
|
|
|
219
231
|
and lint cops they are not used by default and you have to request them
|
|
220
232
|
specifically:
|
|
221
233
|
|
|
222
|
-
```
|
|
234
|
+
```sh
|
|
223
235
|
$ rubocop -R
|
|
224
236
|
```
|
|
225
237
|
|
|
@@ -258,6 +270,11 @@ Metrics/LineLength:
|
|
|
258
270
|
|
|
259
271
|
### Inheritance
|
|
260
272
|
|
|
273
|
+
RuboCop supports inheriting configuration from one or more supplemental
|
|
274
|
+
configuration files at runtime.
|
|
275
|
+
|
|
276
|
+
#### Inheriting from another configuration file in the project
|
|
277
|
+
|
|
261
278
|
The optional `inherit_from` directive is used to include configuration
|
|
262
279
|
from one or more files. This makes it possible to have the common
|
|
263
280
|
project settings in the `.rubocop.yml` file at the project root, and
|
|
@@ -275,6 +292,57 @@ inherit_from:
|
|
|
275
292
|
- ../conf/.rubocop.yml
|
|
276
293
|
```
|
|
277
294
|
|
|
295
|
+
### Inheriting configuration from a remote URL
|
|
296
|
+
|
|
297
|
+
The optional `inherit_from` directive can contain a full url to a remote
|
|
298
|
+
file. This makes it possible to have common project settings stored on a http
|
|
299
|
+
server and shared between many projects. You can inherit from both remote and
|
|
300
|
+
local files in the same config.
|
|
301
|
+
|
|
302
|
+
The same inheritance rules apply to remote URLs and inheriting from local
|
|
303
|
+
files where the first file in the list has the lowest precedence and the
|
|
304
|
+
last one has the highest. The format for multiple inheritance using URLs is:
|
|
305
|
+
|
|
306
|
+
```yaml
|
|
307
|
+
inherit_from:
|
|
308
|
+
- http://www.example.com/rubocop.yml
|
|
309
|
+
- ../.rubocop.yml
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
#### Inheriting configuration from a dependency gem
|
|
313
|
+
|
|
314
|
+
The optional `inherit_gem` directive is used to include configuration from
|
|
315
|
+
one or more gems external to the current project. This makes it possible to
|
|
316
|
+
inherit a shared dependency's RuboCop configuration that can be used from
|
|
317
|
+
multiple disparate projects.
|
|
318
|
+
|
|
319
|
+
Configurations inherited in this way will be essentially *prepended* to the
|
|
320
|
+
`inherit_from` directive, such that the `inherit_gem` configurations will be
|
|
321
|
+
loaded first, then the `inherit_from` relative file paths will be loaded
|
|
322
|
+
(overriding the configurations from the gems), and finally the remaining
|
|
323
|
+
directives in the configuration file will supersede any of the inherited
|
|
324
|
+
configurations. This means the configurations inherited from one or more gems
|
|
325
|
+
have the lowest precedence of inheritance.
|
|
326
|
+
|
|
327
|
+
The directive should be formatted as a YAML Hash using the gem name as the
|
|
328
|
+
key and the relative path within the gem as the value:
|
|
329
|
+
|
|
330
|
+
```yaml
|
|
331
|
+
inherit_gem:
|
|
332
|
+
rubocop: config/default.yml
|
|
333
|
+
my-shared-gem: .rubocop.yml
|
|
334
|
+
cucumber: conf/rubocop.yml
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Note**: If the shared dependency is declared using a [Bundler](http://bundler.io/)
|
|
338
|
+
Gemfile and the gem was installed using `bundle install`, it would be
|
|
339
|
+
necessary to also invoke RuboCop using Bundler in order to find the
|
|
340
|
+
dependency's installation path at runtime:
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
$ bundle exec rubocop <options...>
|
|
344
|
+
```
|
|
345
|
+
|
|
278
346
|
### Defaults
|
|
279
347
|
|
|
280
348
|
The file
|
|
@@ -367,6 +435,15 @@ Metrics/LineLength:
|
|
|
367
435
|
Enabled: false
|
|
368
436
|
```
|
|
369
437
|
|
|
438
|
+
Most cops are enabled by default. Some cops, configured in [config/disabled.yml](https://github.com/bbatsov/rubocop/blob/master/config/disabled.yml), are disabled by default. The cop enabling process can be altered by setting `DisabledByDefault` to `true`.
|
|
439
|
+
|
|
440
|
+
```yaml
|
|
441
|
+
AllCops:
|
|
442
|
+
DisabledByDefault: true
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
All cops are then disabled by default, and only cops appearing in user configuration files are enabled. `Enabled: true` does not have to be set for cops in user configuration. They will be enabled anyway.
|
|
446
|
+
|
|
370
447
|
#### Severity
|
|
371
448
|
|
|
372
449
|
Each cop has a default severity level based on which department it belongs
|
|
@@ -384,6 +461,20 @@ Metrics/CyclomaticComplexity:
|
|
|
384
461
|
Severity: warning
|
|
385
462
|
```
|
|
386
463
|
|
|
464
|
+
## Details
|
|
465
|
+
|
|
466
|
+
Individual cops can be embellished with extra details in offense messages:
|
|
467
|
+
|
|
468
|
+
```yaml
|
|
469
|
+
Metrics/LineLength:
|
|
470
|
+
Details: >-
|
|
471
|
+
If lines are too short, text becomes hard to read because you must
|
|
472
|
+
constantly jump from one line to the next while reading. If lines are too
|
|
473
|
+
long, the line jumping becomes too hard because you "lose the line" while
|
|
474
|
+
going back to the start of the next line. 80 characters is a good
|
|
475
|
+
compromise.
|
|
476
|
+
```
|
|
477
|
+
|
|
387
478
|
#### AutoCorrect
|
|
388
479
|
|
|
389
480
|
Cops that support the `--auto-correct` option can have that support
|
|
@@ -399,10 +490,18 @@ Style/PerlBackrefs:
|
|
|
399
490
|
If you have a code base with an overwhelming amount of offenses, it can
|
|
400
491
|
be a good idea to use `rubocop --auto-gen-config` and add an
|
|
401
492
|
`inherit_from: .rubocop_todo.yml` in your `.rubocop.yml`. The generated
|
|
402
|
-
file `.rubocop_todo.yml` contains configuration to disable
|
|
403
|
-
currently detect an offense in the code
|
|
404
|
-
|
|
405
|
-
|
|
493
|
+
file `.rubocop_todo.yml` contains configuration to disable cops that
|
|
494
|
+
currently detect an offense in the code by excluding the offending
|
|
495
|
+
files, or disabling the cop altogether once a file count limit has been
|
|
496
|
+
reached.
|
|
497
|
+
|
|
498
|
+
By adding the option `--exclude-limit COUNT`, e.g., `rubocop
|
|
499
|
+
--auto-gen-config --exclude-limit 5`, you can change how many files are
|
|
500
|
+
excluded before the cop is entirely disabled. The default COUNT is 15.
|
|
501
|
+
|
|
502
|
+
Then you can start removing the entries in the generated
|
|
503
|
+
`.rubocop_todo.yml` file one by one as you work through all the offenses
|
|
504
|
+
in the code.
|
|
406
505
|
|
|
407
506
|
## Disabling Cops within Source Code
|
|
408
507
|
|
|
@@ -445,7 +544,7 @@ You can enable multiple formatters at the same time by specifying `-f/--format`
|
|
|
445
544
|
The `-o/--out` option applies to the previously specified `-f/--format`,
|
|
446
545
|
or the default `progress` format if no `-f/--format` is specified before the `-o/--out` option.
|
|
447
546
|
|
|
448
|
-
```
|
|
547
|
+
```sh
|
|
449
548
|
# Simple format to $stdout.
|
|
450
549
|
$ rubocop --format simple
|
|
451
550
|
|
|
@@ -480,7 +579,7 @@ and at the end it displays all detected offenses in the `clang` format.
|
|
|
480
579
|
A `.` represents a clean file, and each of the capital letters means
|
|
481
580
|
the severest offense (convention, warning, error or fatal) found in a file.
|
|
482
581
|
|
|
483
|
-
```
|
|
582
|
+
```sh
|
|
484
583
|
$ rubocop
|
|
485
584
|
Inspecting 26 files
|
|
486
585
|
..W.C....C..CWCW.C...WC.CC
|
|
@@ -500,7 +599,7 @@ lib/foo.rb:6:5: C: Missing top-level class documentation comment.
|
|
|
500
599
|
|
|
501
600
|
The `clang` formatter displays the offenses in a manner similar to `clang`:
|
|
502
601
|
|
|
503
|
-
```
|
|
602
|
+
```sh
|
|
504
603
|
$ rubocop test.rb
|
|
505
604
|
Inspecting 1 file
|
|
506
605
|
W
|
|
@@ -527,9 +626,9 @@ test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
|
|
|
527
626
|
|
|
528
627
|
The `fuubar` style formatter displays a progress bar
|
|
529
628
|
and shows details of offenses in the `clang` format as soon as they are detected.
|
|
530
|
-
This is inspired by the [Fuubar](https://github.com/
|
|
629
|
+
This is inspired by the [Fuubar](https://github.com/thekompanee/fuubar) formatter for RSpec.
|
|
531
630
|
|
|
532
|
-
```
|
|
631
|
+
```sh
|
|
533
632
|
$ rubocop --format fuubar
|
|
534
633
|
lib/foo.rb.rb:1:1: C: Use snake_case for methods and variables.
|
|
535
634
|
def badName
|
|
@@ -546,7 +645,7 @@ lib/bar.rb:13:14: W: File.exists? is deprecated in favor of File.exist?.
|
|
|
546
645
|
|
|
547
646
|
The `emacs` formatter displays the offenses in a format suitable for consumption by `Emacs` (and possibly other tools).
|
|
548
647
|
|
|
549
|
-
```
|
|
648
|
+
```sh
|
|
550
649
|
$ rubocop --format emacs test.rb
|
|
551
650
|
/Users/bozhidar/projects/test.rb:1:1: C: Use snake_case for methods and variables.
|
|
552
651
|
/Users/bozhidar/projects/test.rb:2:3: C: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||.
|
|
@@ -557,7 +656,7 @@ $ rubocop --format emacs test.rb
|
|
|
557
656
|
|
|
558
657
|
The name of the formatter says it all :-)
|
|
559
658
|
|
|
560
|
-
```
|
|
659
|
+
```sh
|
|
561
660
|
$ rubocop --format simple test.rb
|
|
562
661
|
== test.rb ==
|
|
563
662
|
C: 1: 5: Use snake_case for method names.
|
|
@@ -576,7 +675,7 @@ Sometimes you might want to just open all files with offenses in your
|
|
|
576
675
|
favorite editor. This formatter outputs just the names of the files
|
|
577
676
|
with offenses in them and makes it possible to do something like:
|
|
578
677
|
|
|
579
|
-
```
|
|
678
|
+
```sh
|
|
580
679
|
$ rubocop --format files | xargs vim
|
|
581
680
|
```
|
|
582
681
|
|
|
@@ -641,7 +740,7 @@ see where most of your style cleanup is going to be spent.
|
|
|
641
740
|
With this in mind, you can use the offense count formatter to outline the offended
|
|
642
741
|
cops and the number of offenses found for each by running:
|
|
643
742
|
|
|
644
|
-
```
|
|
743
|
+
```sh
|
|
645
744
|
$ rubocop --format offenses
|
|
646
745
|
|
|
647
746
|
87 Documentation
|
|
@@ -663,7 +762,7 @@ $ rubocop --format offenses
|
|
|
663
762
|
|
|
664
763
|
Useful for CI environments. It will create an HTML report like [this](http://f.cl.ly/items/0M3029412x3O091a1X1R/expected.html).
|
|
665
764
|
|
|
666
|
-
```
|
|
765
|
+
```sh
|
|
667
766
|
$ rubocop --format html -o rubocop.html
|
|
668
767
|
```
|
|
669
768
|
|
|
@@ -686,7 +785,7 @@ RuboCop supports the following Ruby implementations:
|
|
|
686
785
|
Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs
|
|
687
786
|
and quickly jump between problems in your code.
|
|
688
787
|
|
|
689
|
-
[flycheck](https://github.com/
|
|
788
|
+
[flycheck](https://github.com/flycheck/flycheck) > 0.9 also supports
|
|
690
789
|
RuboCop and uses it by default when available.
|
|
691
790
|
|
|
692
791
|
### Vim
|
|
@@ -705,7 +804,7 @@ useful.
|
|
|
705
804
|
|
|
706
805
|
### Brackets
|
|
707
806
|
|
|
708
|
-
The [brackets-rubocop](https://github.com/smockle/brackets-rubocop)
|
|
807
|
+
The [brackets-rubocop](https://github.com/smockle-archive/brackets-rubocop)
|
|
709
808
|
extension displays RuboCop results in Brackets.
|
|
710
809
|
It can be installed via the extension manager in Brackets.
|
|
711
810
|
|
|
@@ -721,7 +820,7 @@ The [atom-lint](https://github.com/yujinakayama/atom-lint) package
|
|
|
721
820
|
runs RuboCop and highlights the offenses in Atom.
|
|
722
821
|
|
|
723
822
|
You can also use the [linter-rubocop](https://github.com/AtomLinter/linter-rubocop)
|
|
724
|
-
plugin for Atom's [linter](https://github.com/
|
|
823
|
+
plugin for Atom's [linter](https://github.com/atom-community/linter).
|
|
725
824
|
|
|
726
825
|
### LightTable
|
|
727
826
|
|
|
@@ -738,6 +837,18 @@ provides basic RuboCop integration for RubyMine/IntelliJ IDEA.
|
|
|
738
837
|
Here's one great opportunity to contribute to RuboCop - implement
|
|
739
838
|
RuboCop integration for your favorite editor.
|
|
740
839
|
|
|
840
|
+
## Git pre-commit hook integration
|
|
841
|
+
|
|
842
|
+
[overcommit](https://github.com/brigade/overcommit) is a fully configurable and
|
|
843
|
+
extendable Git commit hook manager. To use RuboCop with overcommit, add the
|
|
844
|
+
following to your `.overcommit.yml` file:
|
|
845
|
+
|
|
846
|
+
```yaml
|
|
847
|
+
PreCommit:
|
|
848
|
+
RuboCop:
|
|
849
|
+
enabled: true
|
|
850
|
+
```
|
|
851
|
+
|
|
741
852
|
## Guard integration
|
|
742
853
|
|
|
743
854
|
If you're fond of [Guard](https://github.com/guard/guard) you might
|
|
@@ -779,6 +890,56 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
|
779
890
|
end
|
|
780
891
|
```
|
|
781
892
|
|
|
893
|
+
## Caching
|
|
894
|
+
|
|
895
|
+
Large projects containing hundreds or even thousands of files can take
|
|
896
|
+
a really long time to inspect, but RuboCop has functionality to
|
|
897
|
+
mitigate this problem. There's a caching mechanism that stores
|
|
898
|
+
information about offenses found in inspected files.
|
|
899
|
+
|
|
900
|
+
### Cache Validity
|
|
901
|
+
|
|
902
|
+
Later runs will be able to retrieve this information and present the
|
|
903
|
+
stored information instead of inspecting the file again. This will be
|
|
904
|
+
done if the cache for the file is still valid, which it is if there
|
|
905
|
+
are no changes in:
|
|
906
|
+
* the contents of the inspected file
|
|
907
|
+
* RuboCop configuration for the file
|
|
908
|
+
* the options given to `rubocop`, with some exceptions that have no
|
|
909
|
+
bearing on which offenses are reported
|
|
910
|
+
* the Ruby version used to invoke `rubocop`
|
|
911
|
+
* version of the `rubocop` program (or to be precise, anything in the
|
|
912
|
+
source code of the invoked `rubocop` program)
|
|
913
|
+
|
|
914
|
+
### Enabling and Disabling the Cache
|
|
915
|
+
|
|
916
|
+
The caching functionality is enabled if the configuration parameter
|
|
917
|
+
`AllCops: UseCache` is `true`, which it is by default. The command
|
|
918
|
+
line option `--cache false` can be used to turn off caching, thus
|
|
919
|
+
overriding the configuration parameter. If `AllCops: UseCache` is set
|
|
920
|
+
to `false` in the local `.rubocop.yml`, then it's `--cache true` that
|
|
921
|
+
overrides the setting.
|
|
922
|
+
|
|
923
|
+
### Cache Path
|
|
924
|
+
|
|
925
|
+
By default, the cache is stored in in a subdirectory of the temporary
|
|
926
|
+
directory, `/tmp/rubocop_cache/` on Unix-like systems. The
|
|
927
|
+
configuration parameter `AllCops: CacheRootDirectory` can be used to
|
|
928
|
+
set it to a different path. One reason to use this option could be
|
|
929
|
+
that there's a network disk where users on different machines want to
|
|
930
|
+
have a common RuboCop cache. Another could be that a Continuous
|
|
931
|
+
Integration system allows directories, but not a temporary directory,
|
|
932
|
+
to be saved between runs.
|
|
933
|
+
|
|
934
|
+
### Cache Pruning
|
|
935
|
+
|
|
936
|
+
Each time a file has changed, its offenses will be stored under a new
|
|
937
|
+
key in the cache. This means that the cache will continue to grow
|
|
938
|
+
until we do something to stop it. The configuration parameter
|
|
939
|
+
`AllCops: MaxFilesInCache` sets a limit, and when the number of files
|
|
940
|
+
in the cache exceeds that limit, the oldest files will be automatially
|
|
941
|
+
removed from the cache.
|
|
942
|
+
|
|
782
943
|
## Extensions
|
|
783
944
|
|
|
784
945
|
It's possible to extend RuboCop with custom cops and formatters.
|
|
@@ -821,9 +982,9 @@ or implement all formatter API methods by duck typing.
|
|
|
821
982
|
|
|
822
983
|
Please see the documents below for more formatter API details.
|
|
823
984
|
|
|
824
|
-
* [RuboCop::Formatter::BaseFormatter](http://rubydoc.info/gems/rubocop/RuboCop/Formatter/BaseFormatter)
|
|
825
|
-
* [RuboCop::Cop::Offense](http://rubydoc.info/gems/rubocop/RuboCop/Cop/Offense)
|
|
826
|
-
* [Parser::Source::Range](http://rubydoc.info/github/whitequark/parser/Parser/Source/Range)
|
|
985
|
+
* [RuboCop::Formatter::BaseFormatter](http://www.rubydoc.info/gems/rubocop/RuboCop/Formatter/BaseFormatter)
|
|
986
|
+
* [RuboCop::Cop::Offense](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Offense)
|
|
987
|
+
* [Parser::Source::Range](http://www.rubydoc.info/github/whitequark/parser/Parser/Source/Range)
|
|
827
988
|
|
|
828
989
|
#### Using Custom Formatter in Command Line
|
|
829
990
|
|
|
@@ -832,7 +993,7 @@ You can tell RuboCop to use your custom formatter with a combination of
|
|
|
832
993
|
For example, when you have defined `MyCustomFormatter` in
|
|
833
994
|
`./path/to/my_custom_formatter.rb`, you would type this command:
|
|
834
995
|
|
|
835
|
-
```
|
|
996
|
+
```sh
|
|
836
997
|
$ rubocop --require ./path/to/my_custom_formatter --format MyCustomFormatter
|
|
837
998
|
```
|
|
838
999
|
|
|
@@ -855,7 +1016,7 @@ The logo is licensed under a
|
|
|
855
1016
|
|
|
856
1017
|
## Contributors
|
|
857
1018
|
|
|
858
|
-
Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
|
|
1019
|
+
Here's a [list](https://github.com/bbatsov/rubocop/graphs/contributors) of
|
|
859
1020
|
all the people who have contributed to the development of RuboCop.
|
|
860
1021
|
|
|
861
1022
|
I'm extremely grateful to each and every one of them!
|
|
@@ -870,11 +1031,11 @@ priority right now. Writing a new cop is a great way to dive into RuboCop!
|
|
|
870
1031
|
Of course, bug reports and suggestions for improvements are always
|
|
871
1032
|
welcome. GitHub pull requests are even better! :-)
|
|
872
1033
|
|
|
873
|
-
You can also support my work on RuboCop
|
|
874
|
-
[
|
|
875
|
-
[
|
|
1034
|
+
You can also support my work on RuboCop via
|
|
1035
|
+
[Salt](https://salt.bountysource.com/teams/rubocop) and
|
|
1036
|
+
[Gratipay](https://gratipay.com/rubocop/).
|
|
876
1037
|
|
|
877
|
-
[](https://gratipay.com/
|
|
1038
|
+
[](https://gratipay.com/rubocop/)
|
|
878
1039
|
|
|
879
1040
|
## Mailing List
|
|
880
1041
|
|
data/config/default.yml
CHANGED
|
@@ -38,10 +38,32 @@ AllCops:
|
|
|
38
38
|
# behavior by overriding DisplayStyleGuide, or by giving the
|
|
39
39
|
# -S/--display-style-guide option.
|
|
40
40
|
DisplayStyleGuide: false
|
|
41
|
+
# Extra details are not displayed in offense messages by default. Change
|
|
42
|
+
# behaviour by overriding ExtraDetails, or by giving the
|
|
43
|
+
# -E/--extra-details option.
|
|
44
|
+
ExtraDetails: false
|
|
41
45
|
# Additional cops that do not reference a style guide rule may be enabled by
|
|
42
46
|
# default. Change behavior by overriding StyleGuideCopsOnly, or by giving
|
|
43
47
|
# the --only-guide-cops option.
|
|
44
48
|
StyleGuideCopsOnly: false
|
|
49
|
+
# All cops except the ones in disabled.yml are enabled by default. Change
|
|
50
|
+
# this behavior by overriding DisabledByDefault. When DisabledByDefault is
|
|
51
|
+
# true, all cops in the default configuration are disabled, and and only cops
|
|
52
|
+
# in user configuration are enabled. This makes cops opt-in instead of
|
|
53
|
+
# opt-out. Note that when DisabledByDefault is true, cops in user
|
|
54
|
+
# configuration will be enabled even if they don't set the Enabled parameter.
|
|
55
|
+
DisabledByDefault: false
|
|
56
|
+
# Enables the result cache if true. Can be overridden by the --cache command
|
|
57
|
+
# line option.
|
|
58
|
+
UseCache: true
|
|
59
|
+
# Threshold for how many files can be stored in the result cache before some
|
|
60
|
+
# of the files are automatically removed.
|
|
61
|
+
MaxFilesInCache: 20000
|
|
62
|
+
# The cache will be stored in "rubocop_cache" under this directory. The name
|
|
63
|
+
# "/tmp" is special and will be converted to the system temporary directory,
|
|
64
|
+
# which is "/tmp" on Unix-like systems, but could be something else on other
|
|
65
|
+
# systems.
|
|
66
|
+
CacheRootDirectory: /tmp
|
|
45
67
|
|
|
46
68
|
# Indent private/protected/public as deep as method definitions
|
|
47
69
|
Style/AccessModifierIndentation:
|
|
@@ -165,6 +187,11 @@ Style/BlockDelimiters:
|
|
|
165
187
|
# method) but exceptions are permitted in the `ProceduralMethods`,
|
|
166
188
|
# `FunctionalMethods` and `IgnoredMethods` sections below.
|
|
167
189
|
- semantic
|
|
190
|
+
# The `braces_for_chaining` style enforces braces around single line blocks
|
|
191
|
+
# and do..end around multi-line blocks, except for multi-line blocks whose
|
|
192
|
+
# return value is being chained with another method (in which case braces
|
|
193
|
+
# are enforced).
|
|
194
|
+
- braces_for_chaining
|
|
168
195
|
ProceduralMethods:
|
|
169
196
|
# Methods that are known to be procedural in nature but look functional from
|
|
170
197
|
# their usage, e.g.
|
|
@@ -376,6 +403,12 @@ Style/Encoding:
|
|
|
376
403
|
- always
|
|
377
404
|
AutoCorrectEncodingComment: '# encoding: utf-8'
|
|
378
405
|
|
|
406
|
+
Style/ExtraSpacing:
|
|
407
|
+
# When true, allows most uses of extra spacing if the intent is to align
|
|
408
|
+
# things with the previous or next line, not counting empty lines or comment
|
|
409
|
+
# lines.
|
|
410
|
+
AllowForAlignment: true
|
|
411
|
+
|
|
379
412
|
Style/FileName:
|
|
380
413
|
# File names listed in AllCops:Include are excluded by default. Add extra
|
|
381
414
|
# excludes here.
|
|
@@ -461,6 +494,7 @@ Style/IndentHash:
|
|
|
461
494
|
SupportedStyles:
|
|
462
495
|
- special_inside_parentheses
|
|
463
496
|
- consistent
|
|
497
|
+
- align_braces
|
|
464
498
|
|
|
465
499
|
Style/LambdaCall:
|
|
466
500
|
EnforcedStyle: call
|
|
@@ -494,6 +528,7 @@ Style/MethodDefParentheses:
|
|
|
494
528
|
SupportedStyles:
|
|
495
529
|
- require_parentheses
|
|
496
530
|
- require_no_parentheses
|
|
531
|
+
- require_no_parentheses_except_multiline
|
|
497
532
|
|
|
498
533
|
Style/MethodName:
|
|
499
534
|
EnforcedStyle: snake_case
|
|
@@ -510,6 +545,15 @@ Style/MultilineOperationIndentation:
|
|
|
510
545
|
Style/NumericLiterals:
|
|
511
546
|
MinDigits: 5
|
|
512
547
|
|
|
548
|
+
Style/OptionHash:
|
|
549
|
+
# A list of parameter names that will be flagged by this cop.
|
|
550
|
+
SuspiciousParamNames:
|
|
551
|
+
- options
|
|
552
|
+
- opts
|
|
553
|
+
- args
|
|
554
|
+
- params
|
|
555
|
+
- parameters
|
|
556
|
+
|
|
513
557
|
# Allow safe assignment in conditions.
|
|
514
558
|
Style/ParenthesesAroundCondition:
|
|
515
559
|
AllowSafeAssignment: true
|
|
@@ -533,16 +577,20 @@ Style/PercentQLiterals:
|
|
|
533
577
|
- upper_case_q # Always use %Q
|
|
534
578
|
|
|
535
579
|
Style/PredicateName:
|
|
536
|
-
# Predicate name
|
|
580
|
+
# Predicate name prefixes.
|
|
537
581
|
NamePrefix:
|
|
538
582
|
- is_
|
|
539
583
|
- has_
|
|
540
584
|
- have_
|
|
541
|
-
# Predicate name
|
|
585
|
+
# Predicate name prefixes that should be removed.
|
|
542
586
|
NamePrefixBlacklist:
|
|
543
587
|
- is_
|
|
544
588
|
- has_
|
|
545
589
|
- have_
|
|
590
|
+
# Predicate names which, despite having a blacklisted prefix, or no ?,
|
|
591
|
+
# should still be accepted
|
|
592
|
+
NameWhitelist:
|
|
593
|
+
- is_a?
|
|
546
594
|
|
|
547
595
|
Style/RaiseArgs:
|
|
548
596
|
EnforcedStyle: exploded
|
|
@@ -591,6 +639,12 @@ Style/SingleLineBlockParams:
|
|
|
591
639
|
Style/SingleLineMethods:
|
|
592
640
|
AllowIfMethodIsEmpty: true
|
|
593
641
|
|
|
642
|
+
Style/StabbyLambdaParentheses:
|
|
643
|
+
EnforcedStyle: require_parentheses
|
|
644
|
+
SupportedStyles:
|
|
645
|
+
- require_parentheses
|
|
646
|
+
- require_no_parentheses
|
|
647
|
+
|
|
594
648
|
Style/StringLiterals:
|
|
595
649
|
EnforcedStyle: single_quotes
|
|
596
650
|
SupportedStyles:
|
|
@@ -603,6 +657,16 @@ Style/StringLiteralsInInterpolation:
|
|
|
603
657
|
- single_quotes
|
|
604
658
|
- double_quotes
|
|
605
659
|
|
|
660
|
+
Style/StringMethods:
|
|
661
|
+
# Mapping from undesired method to desired_method
|
|
662
|
+
# e.g. to use `to_sym` over `intern`:
|
|
663
|
+
#
|
|
664
|
+
# StringMethods:
|
|
665
|
+
# PreferredMethods:
|
|
666
|
+
# intern: to_sym
|
|
667
|
+
PreferredMethods:
|
|
668
|
+
intern: to_sym
|
|
669
|
+
|
|
606
670
|
Style/SpaceAroundBlockParameters:
|
|
607
671
|
EnforcedStyleInsidePipes: no_space
|
|
608
672
|
SupportedStyles:
|
|
@@ -643,6 +707,12 @@ Style/SpaceInsideHashLiteralBraces:
|
|
|
643
707
|
- space
|
|
644
708
|
- no_space
|
|
645
709
|
|
|
710
|
+
Style/SpaceInsideStringInterpolation:
|
|
711
|
+
EnforcedStyle: no_space
|
|
712
|
+
SupportedStyles:
|
|
713
|
+
- space
|
|
714
|
+
- no_space
|
|
715
|
+
|
|
646
716
|
Style/SymbolProc:
|
|
647
717
|
# A list of method names to be ignored by the check.
|
|
648
718
|
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
|
|
@@ -794,6 +864,15 @@ Lint/DefEndAlignment:
|
|
|
794
864
|
- def
|
|
795
865
|
AutoCorrect: false
|
|
796
866
|
|
|
867
|
+
# Checks for unused block arguments
|
|
868
|
+
Lint/UnusedBlockArgument:
|
|
869
|
+
IgnoreEmptyBlocks: true
|
|
870
|
+
|
|
871
|
+
# Checks for unused method arguments.
|
|
872
|
+
Lint/UnusedMethodArgument:
|
|
873
|
+
AllowUnusedKeywordArguments: false
|
|
874
|
+
IgnoreEmptyMethods: true
|
|
875
|
+
|
|
797
876
|
##################### Rails ##################################
|
|
798
877
|
|
|
799
878
|
Rails/ActionFilter:
|
|
@@ -805,15 +884,15 @@ Rails/ActionFilter:
|
|
|
805
884
|
- app/controllers/**/*.rb
|
|
806
885
|
|
|
807
886
|
Rails/Date:
|
|
808
|
-
# The value `
|
|
887
|
+
# The value `strict` disallows usage of `Date.today`, `Date.current`,
|
|
809
888
|
# `Date#to_time` etc.
|
|
810
|
-
# The value `
|
|
889
|
+
# The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
|
|
811
890
|
# (but not `Date.today`) which are overriden by ActiveSupport to handle current
|
|
812
891
|
# time zone.
|
|
813
|
-
EnforcedStyle:
|
|
892
|
+
EnforcedStyle: flexible
|
|
814
893
|
SupportedStyles:
|
|
815
|
-
-
|
|
816
|
-
-
|
|
894
|
+
- strict
|
|
895
|
+
- flexible
|
|
817
896
|
|
|
818
897
|
Rails/DefaultScope:
|
|
819
898
|
Include:
|
|
@@ -847,12 +926,12 @@ Rails/ScopeArgs:
|
|
|
847
926
|
- app/models/**/*.rb
|
|
848
927
|
|
|
849
928
|
Rails/TimeZone:
|
|
850
|
-
# The value `
|
|
851
|
-
# The value `
|
|
852
|
-
EnforcedStyle:
|
|
929
|
+
# The value `strict` means that `Time` should be used with `zone`.
|
|
930
|
+
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
|
|
931
|
+
EnforcedStyle: flexible
|
|
853
932
|
SupportedStyles:
|
|
854
|
-
-
|
|
855
|
-
-
|
|
933
|
+
- strict
|
|
934
|
+
- flexible
|
|
856
935
|
|
|
857
936
|
Rails/Validation:
|
|
858
937
|
Include:
|