rubocop 0.33.0 → 0.34.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/CHANGELOG.md +62 -1
- data/README.md +65 -6
- data/config/default.yml +30 -0
- data/config/disabled.yml +5 -0
- data/config/enabled.yml +19 -3
- data/lib/rubocop.rb +7 -2
- data/lib/rubocop/cli.rb +1 -1
- data/lib/rubocop/config.rb +11 -6
- data/lib/rubocop/config_loader.rb +7 -3
- data/lib/rubocop/cop/commissioner.rb +6 -11
- data/lib/rubocop/cop/cop.rb +7 -3
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +10 -8
- data/lib/rubocop/cop/lint/duplicated_key.rb +37 -0
- data/lib/rubocop/cop/lint/end_alignment.rb +6 -6
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +57 -14
- data/lib/rubocop/cop/metrics/method_length.rb +1 -3
- data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -2
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +11 -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 +9 -0
- data/lib/rubocop/cop/mixin/method_preference.rb +28 -0
- data/lib/rubocop/cop/mixin/safe_assignment.rb +2 -2
- data/lib/rubocop/cop/performance/case_when_splat.rb +132 -0
- data/lib/rubocop/cop/performance/string_replacement.rb +45 -28
- data/lib/rubocop/cop/rails/action_filter.rb +31 -5
- data/lib/rubocop/cop/rails/date.rb +6 -5
- data/lib/rubocop/cop/rails/read_write_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/time_zone.rb +12 -1
- data/lib/rubocop/cop/style/alias.rb +1 -0
- data/lib/rubocop/cop/style/block_delimiters.rb +6 -5
- data/lib/rubocop/cop/style/collection_methods.rb +2 -20
- data/lib/rubocop/cop/style/else_alignment.rb +2 -1
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +42 -13
- data/lib/rubocop/cop/style/extra_spacing.rb +17 -3
- data/lib/rubocop/cop/style/first_parameter_indentation.rb +1 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +5 -0
- data/lib/rubocop/cop/style/indentation_width.rb +7 -1
- data/lib/rubocop/cop/style/initial_indentation.rb +5 -0
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +35 -0
- data/lib/rubocop/cop/style/next.rb +31 -14
- data/lib/rubocop/cop/style/option_hash.rb +9 -1
- data/lib/rubocop/cop/style/parallel_assignment.rb +21 -44
- data/lib/rubocop/cop/style/redundant_freeze.rb +37 -0
- data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +2 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +35 -3
- data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +1 -0
- data/lib/rubocop/cop/style/string_methods.rb +32 -0
- data/lib/rubocop/cop/style/symbol_proc.rb +54 -12
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +1 -1
- data/lib/rubocop/cop/team.rb +2 -2
- data/lib/rubocop/cop/util.rb +2 -2
- data/lib/rubocop/cop/variable_force.rb +10 -10
- data/lib/rubocop/cop/variable_force/locatable.rb +5 -5
- data/lib/rubocop/formatter/formatter_set.rb +1 -0
- data/lib/rubocop/options.rb +24 -1
- data/lib/rubocop/result_cache.rb +121 -0
- data/lib/rubocop/runner.rb +55 -15
- data/lib/rubocop/target_finder.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.34.0.md +182 -0
- data/rubocop.gemspec +1 -1
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28abcf0a852c586dd74f51a997523666f7a139b0
|
4
|
+
data.tar.gz: 352ca8a89138692d8a06341e0fe0bec72de5d55e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d78c51015cbf72261a8493037c1cdf9ec868d00c965f3b816e48ffa4ecd080ac3e616e1b4d518cd6e22d3b27c80565a05ab73835d4e874575aa3f88fe1efbf99
|
7
|
+
data.tar.gz: cbf3a9a14028fa911fef98766067c201f9acd7e1205770f5b75379c55467769760f5af76265237bc98f3964cd4c1febbed6a77143deea5c0e23ee770d63dadd8
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,63 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.34.0 (05/09/2015)
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
* [#2143](https://github.com/bbatsov/rubocop/pull/2143): New cop `Performance/CaseWhenSplat` will identify and rearange `case` `when` statements that contain a `when` condition with a splat. ([@rrosenblum][])
|
10
|
+
* New cop `Lint/DuplicatedKey` checks for duplicated keys in hashes, which Ruby 2.2 warns against. ([@sliuu][])
|
11
|
+
* [#2106](https://github.com/bbatsov/rubocop/issues/2106): Add `SuspiciousParamNames` option to `Style/OptionHash`. ([@wli][])
|
12
|
+
* [#2193](https://github.com/bbatsov/rubocop/pull/2193): `Style/Next` supports more `Enumerable` methods. ([@rrosenblum][])
|
13
|
+
* [#2179](https://github.com/bbatsov/rubocop/issues/2179): Add `--list-target-files` option to CLI, which prints the files which will be inspected. ([@maxjacobson][])
|
14
|
+
* New cop `Style/MutableConstant` checks for assignment of mutable objects to constants. ([@bbatsov][])
|
15
|
+
* New cop `Style/RedudantFreeze` checks for usages of `Object#freeze` on immutable objects. ([@bbatsov][])
|
16
|
+
* [#1924](https://github.com/bbatsov/rubocop/issues/1924): New option `--cache` and configuration parameter `AllCops: UseCache` turn result caching on (default) or off. ([@jonas054][])
|
17
|
+
* [#2204](https://github.com/bbatsov/rubocop/pull/2204): New cop `Style/StringMethods` will check for preferred method `to_sym` over `intern`. ([@imtayadeway][])
|
18
|
+
|
19
|
+
### Changes
|
20
|
+
|
21
|
+
* [#1351](https://github.com/bbatsov/rubocop/issues/1351): Allow class emitter methods in `Style/MethodName`. ([@jonas054][])
|
22
|
+
* [#2126](https://github.com/bbatsov/rubocop/pull/2126): `Style/RescueModifier` can now auto-correct. ([@rrosenblum][])
|
23
|
+
* [#2109](https://github.com/bbatsov/rubocop/issues/2109): Allow alignment with a token on the nearest line with same indentation in `Style/ExtraSpacing`. ([@jonas054][])
|
24
|
+
* `Lint/EndAlignment` handles the `case` keyword. ([@lumeet][])
|
25
|
+
* [#2146](https://github.com/bbatsov/rubocop/pull/2146): Add STDIN support. ([@caseywebdev][])
|
26
|
+
* [#2175](https://github.com/bbatsov/rubocop/pull/2175): Files that are excluded from a cop (e.g. using the `Exclude:` config option) are no longer being processed by that cop. ([@bquorning][])
|
27
|
+
* `Rails/ActionFilter` now handles complete list of methods found in the Rails 4.2 [release notes](https://github.com/rails/rails/blob/4115a12da1409c753c747fd4bab6e612c0c6e51a/guides/source/4_2_release_notes.md#notable-changes-1). ([@MGerrior][])
|
28
|
+
* [*2138](https://github.com/bbatsov/rubocop/issues/2138): Change the offense in `Style/Next` to highlight the condition instead of the iteration. ([@rrosenblum][])
|
29
|
+
* `Style/EmptyLineBetweenDefs` now handles class methods as well. ([@unmanbearpig][])
|
30
|
+
* Improve handling of `super` in `Style/SymbolProc`. ([@lumeet][])
|
31
|
+
* `Style/SymbolProc` is applied to methods receiving arguments. ([@lumeet][])
|
32
|
+
* [#1839](https://github.com/bbatsov/rubocop/issues/1839): Remove Rainbow monkey patching of String which conflicts with other gems like colorize. ([@daviddavis][])
|
33
|
+
* `Style/HashSyntax` is now a bit faster when checking Ruby 1.9 syntax hash keys. ([@bquorning][])
|
34
|
+
* `Lint/DeprecatedClassMethods` is now a whole lot faster. ([@bquorning][])
|
35
|
+
* `Lint/BlockAlignment`, `Style/IndentationWidth`, and `Style/MultilineOperationIndentation` are now quite a bit faster. ([@bquorning][])
|
36
|
+
|
37
|
+
### Bug Fixes
|
38
|
+
|
39
|
+
* [#2123](https://github.com/bbatsov/rubocop/pull/2123): Fix handing of dynamic widths `Lint/FormatParameterMismatch`. ([@edmz][])
|
40
|
+
* [#2116](https://github.com/bbatsov/rubocop/pull/2116): Fix named params (using hash) `Lint/FormatParameterMismatch`. ([@edmz][])
|
41
|
+
* [#2135](https://github.com/bbatsov/rubocop/issues/2135): Ignore `super` and `zsuper` nodes in `Style/SymbolProc`. ([@bbatsov][])
|
42
|
+
* [#2165](https://github.com/bbatsov/rubocop/issues/2165): Fix a NPE in `Style/Alias`. ([@bbatsov][])
|
43
|
+
* [#2168](https://github.com/bbatsov/rubocop/issues/2168): Fix a NPE in `Rails/TimeZone`. ([@bbatsov][])
|
44
|
+
* [#2169](https://github.com/bbatsov/rubocop/issues/2169): Fix a NPE in `Rails/Date`. ([@bbatsov][])
|
45
|
+
* [#2105](https://github.com/bbatsov/rubocop/pull/2105): Fix a warning that was thrown when enabling `Style/OptionHash`. ([@wli][])
|
46
|
+
* [#2107](https://github.com/bbatsov/rubocop/pull/2107): Fix auto-correct of `Style/ParallelAssignment` for nested expressions. ([@rrosenblum][])
|
47
|
+
* [#2111](https://github.com/bbatsov/rubocop/issues/2111): Deal with byte order mark in `Style/InitialIndentation`. ([@jonas054][])
|
48
|
+
* [#2113](https://github.com/bbatsov/rubocop/issues/2113): Handle non-string tokens in `Style/ExtraSpacing`. ([@jonas054][])
|
49
|
+
* [#2129](https://github.com/bbatsov/rubocop/issues/2129): Handle empty interpolations in `Style/SpaceInsideStringInterpolation`. ([@lumeet][])
|
50
|
+
* [#2119](https://github.com/bbatsov/rubocop/issues/2119): Do not raise an error in `Style/RescueEnsureAlignment` and `Style/RescueModifier` when processing an excluded file. ([@rrosenblum][])
|
51
|
+
* [#2149](https://github.com/bbatsov/rubocop/issues/2149): Do not register an offense in `Rails/Date` when `Date#to_time` is called with a time zone argument. ([@maxjacobson][])
|
52
|
+
* Do not register a `Rails/TimeZone` offense when using Time.new safely. ([@maxjacobson][])
|
53
|
+
* [#2124](https://github.com/bbatsov/rubocop/issues/2124): Fix bug in `Style/EmptyLineBetweenDefs` when there are only comments between method definitions. ([@lumeet][])
|
54
|
+
* [#2154](https://github.com/bbatsov/rubocop/issues/2154): `Performance/StringReplacement` can auto-correct replacements with backslash in them. ([@rrosenblum][])
|
55
|
+
* [#2009](https://github.com/bbatsov/rubocop/issues/2009): Fix bug in `RuboCop::ConfigLoader.load_file` when `safe_yaml` is required. ([@eitoball][])
|
56
|
+
* [#2155](https://github.com/bbatsov/rubocop/issues/2155): Configuration `EndAlignment: AlignWith: variable` only applies when the operands of `=` are on the same line. ([@jonas054][])
|
57
|
+
* Fix bug in `Style/IndentationWidth` when `rescue` or `ensure` is preceded by an empty body. ([@lumeet][])
|
58
|
+
* [#2183](https://github.com/bbatsov/rubocop/issues/2183): Fix bug in `Style/BlockDelimiters` when auto-correcting adjacent braces. ([@lumeet][])
|
59
|
+
* [#2199](https://github.com/bbatsov/rubocop/issues/2199): Make `rubocop` exit with error when there are only `Lint/UnneededDisable` offenses. ([@jonas054][])
|
60
|
+
* Fix handling of empty parentheses when auto-correcting in `Style/SymbolProc`. ([@lumeet][])
|
61
|
+
|
5
62
|
## 0.33.0 (05/08/2015)
|
6
63
|
|
7
64
|
### New features
|
@@ -18,7 +75,7 @@
|
|
18
75
|
* [#2060](https://github.com/bbatsov/rubocop/issues/2060): New cop `Style/RescueEnsureAlignment` checks for bad alignment of `rescue` and `ensure` keywords. ([@lumeet][])
|
19
76
|
* New cop `Style/OptionalArguments` checks for optional arguments that do not appear at the end of an argument list. ([@rrosenblum][])
|
20
77
|
* New cop `Lint/CircularArgumentReference` checks for "circular argument references" in keyword arguments, which Ruby 2.2 warns against. ([@maxjacobson][], [@sliuu][])
|
21
|
-
* [#2030](https://github.com/bbatsov/rubocop/issues/2030): New cop `
|
78
|
+
* [#2030](https://github.com/bbatsov/rubocop/issues/2030): New cop `Style/OptionHash` checks for option hashes and encourages changing them to keyword arguments (disabled by default). ([@maxjacobson][])
|
22
79
|
|
23
80
|
### Changes
|
24
81
|
|
@@ -1525,3 +1582,7 @@
|
|
1525
1582
|
[@sliuu]: https://github.com/sliuu
|
1526
1583
|
[@edmz]: https://github.com/edmz
|
1527
1584
|
[@syndbg]: https://github.com/syndbg
|
1585
|
+
[@wli]: https://github.com/wli
|
1586
|
+
[@caseywebdev]: https://github.com/caseywebdev
|
1587
|
+
[@MGerrior]: https://github.com/MGerrior
|
1588
|
+
[@imtayadeway]: https://github.com/imtayadeway
|
data/README.md
CHANGED
@@ -25,9 +25,11 @@ automatically fix some of the problems for you.
|
|
25
25
|
|
26
26
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bbatsov/rubocop?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
27
27
|
|
28
|
-
You can support my work on RuboCop
|
28
|
+
You can support my work on RuboCop via
|
29
|
+
[Salt](https://salt.bountysource.com/teams/rubocop) and
|
30
|
+
[Gratipay](https://www.gratipay.com/rubocop).
|
29
31
|
|
30
|
-
[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/
|
32
|
+
[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop)
|
31
33
|
|
32
34
|
**This documentation tracks the `master` branch of RuboCop. Some of
|
33
35
|
the features and settings discussed here might not be available in
|
@@ -73,6 +75,11 @@ specific RuboCop release.**
|
|
73
75
|
- [Git pre-commit hook integration](#git-pre-commit-hook-integration)
|
74
76
|
- [Guard integration](#guard-integration)
|
75
77
|
- [Rake integration](#rake-integration)
|
78
|
+
- [Caching](#caching)
|
79
|
+
- [Cache Validity](#cache-validity)
|
80
|
+
- [Enabling and Disabling the Cache](#enabling-and-disabling-the-cache)
|
81
|
+
- [Cache Path](#cache-path)
|
82
|
+
- [Cache Pruning](#cache-pruning)
|
76
83
|
- [Extensions](#extensions)
|
77
84
|
- [Loading Extensions](#loading-extensions)
|
78
85
|
- [Custom Cops](#custom-cops)
|
@@ -160,7 +167,9 @@ Command flag | Description
|
|
160
167
|
--------------------------|------------------------------------------------------------
|
161
168
|
`-v/--version` | Displays the current version and exits.
|
162
169
|
`-V/--verbose-version` | Displays the current version plus the version of Parser and Ruby.
|
170
|
+
`-L/--list-target-files` | List all files RuboCop will inspect.
|
163
171
|
`-F/--fail-fast` | Inspects in modification time order and stops after first file with offenses.
|
172
|
+
`-C/--cache` | Store and reuse results for faster operation.
|
164
173
|
`-d/--debug` | Displays some extra debug output.
|
165
174
|
`-D/--display-cop-names` | Displays cop names in offense messages.
|
166
175
|
`-c/--config` | Run with specified config file.
|
@@ -176,6 +185,7 @@ Command flag | Description
|
|
176
185
|
`--exclude-limit` | Limit how many individual files `--auto-gen-config` can list in `Exclude` parameters, default is 15.
|
177
186
|
`--show-cops` | Shows available cops and their configuration.
|
178
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.
|
179
189
|
|
180
190
|
### Cops
|
181
191
|
|
@@ -810,6 +820,55 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
810
820
|
end
|
811
821
|
```
|
812
822
|
|
823
|
+
## Caching
|
824
|
+
|
825
|
+
Large projects containing hundreds or even thousands of files can take
|
826
|
+
a really long time to inspect, but RuboCop has functionality to
|
827
|
+
mitigate this problem. There's a caching mechanism that stores
|
828
|
+
information about offenses found in inspected files.
|
829
|
+
|
830
|
+
### Cache Validity
|
831
|
+
|
832
|
+
Later runs will be able to retrieve this information and present the
|
833
|
+
stored information instead of inspecting the file again. This will be
|
834
|
+
done if the cache for the file is still valid, which it is if there
|
835
|
+
are no changes in:
|
836
|
+
* the contents of the inspected file
|
837
|
+
* RuboCop configuration for the file
|
838
|
+
* the options given to `rubocop`, with some exceptions that have no
|
839
|
+
bearing on which offenses are reported
|
840
|
+
* version of the `rubocop` program (or to be precise, anything in the
|
841
|
+
source code of the invoked `rubocop` program)
|
842
|
+
|
843
|
+
### Enabling and Disabling the Cache
|
844
|
+
|
845
|
+
The caching functionality is enabled if the configuration parameter
|
846
|
+
`AllCops: UseCache` is `true`, which it is by default. The command
|
847
|
+
line option `--cache false` can be used to turn off caching, thus
|
848
|
+
overriding the configuration parameter. If `AllCops: UseCache` is set
|
849
|
+
to `false` in the local `.rubocop.yml`, then it's `--cache true` that
|
850
|
+
overrides the setting.
|
851
|
+
|
852
|
+
### Cache Path
|
853
|
+
|
854
|
+
By default, the cache is stored in in a subdirectory of the temporary
|
855
|
+
directory, `/tmp/rubocop_cache/` on Unix-like systems. The
|
856
|
+
configuration parameter `AllCops: CacheRootDirectory` can be used to
|
857
|
+
set it to a different path. One reason to use this option could be
|
858
|
+
that there's a network disk where users on different machines want to
|
859
|
+
have a common RuboCop cache. Another could be that a Continuous
|
860
|
+
Integration system allows directories, but not a temporary directory,
|
861
|
+
to be saved between runs.
|
862
|
+
|
863
|
+
### Cache Pruning
|
864
|
+
|
865
|
+
Each time a file has changed, its offenses will be stored under a new
|
866
|
+
key in the cache. This means that the cache will continue to grow
|
867
|
+
until we do something to stop it. The configuration parameter
|
868
|
+
`AllCops: MaxFilesInCache` sets a limit, and when the number of files
|
869
|
+
in the cache exceeds that limit, the oldest files will be automatially
|
870
|
+
removed from the cache.
|
871
|
+
|
813
872
|
## Extensions
|
814
873
|
|
815
874
|
It's possible to extend RuboCop with custom cops and formatters.
|
@@ -901,11 +960,11 @@ priority right now. Writing a new cop is a great way to dive into RuboCop!
|
|
901
960
|
Of course, bug reports and suggestions for improvements are always
|
902
961
|
welcome. GitHub pull requests are even better! :-)
|
903
962
|
|
904
|
-
You can also support my work on RuboCop
|
905
|
-
[
|
906
|
-
[
|
963
|
+
You can also support my work on RuboCop via
|
964
|
+
[Salt](https://salt.bountysource.com/teams/rubocop) and
|
965
|
+
[Gratipay](https://www.gratipay.com/rubocop).
|
907
966
|
|
908
|
-
[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/
|
967
|
+
[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop)
|
909
968
|
|
910
969
|
## Mailing List
|
911
970
|
|
data/config/default.yml
CHANGED
@@ -49,6 +49,17 @@ AllCops:
|
|
49
49
|
# opt-out. Note that when DisabledByDefault is true, cops in user
|
50
50
|
# configuration will be enabled even if they don't set the Enabled parameter.
|
51
51
|
DisabledByDefault: false
|
52
|
+
# Enables the result cache if true. Can be overridden by the --cache command
|
53
|
+
# line option.
|
54
|
+
UseCache: true
|
55
|
+
# Threshold for how many files can be stored in the result cache before some
|
56
|
+
# of the files are automatically removed.
|
57
|
+
MaxFilesInCache: 20000
|
58
|
+
# The cache will be stored in "rubocop_cache" under this directory. The name
|
59
|
+
# "/tmp" is special and will be converted to the system temporary directory,
|
60
|
+
# which is "/tmp" on Unix-like systems, but could be something else on other
|
61
|
+
# systems.
|
62
|
+
CacheRootDirectory: /tmp
|
52
63
|
|
53
64
|
# Indent private/protected/public as deep as method definitions
|
54
65
|
Style/AccessModifierIndentation:
|
@@ -523,6 +534,15 @@ Style/MultilineOperationIndentation:
|
|
523
534
|
Style/NumericLiterals:
|
524
535
|
MinDigits: 5
|
525
536
|
|
537
|
+
Style/OptionHash:
|
538
|
+
# A list of parameter names that will be flagged by this cop.
|
539
|
+
SuspiciousParamNames:
|
540
|
+
- options
|
541
|
+
- opts
|
542
|
+
- args
|
543
|
+
- params
|
544
|
+
- parameters
|
545
|
+
|
526
546
|
# Allow safe assignment in conditions.
|
527
547
|
Style/ParenthesesAroundCondition:
|
528
548
|
AllowSafeAssignment: true
|
@@ -616,6 +636,16 @@ Style/StringLiteralsInInterpolation:
|
|
616
636
|
- single_quotes
|
617
637
|
- double_quotes
|
618
638
|
|
639
|
+
Style/StringMethods:
|
640
|
+
# Mapping from undesired method to desired_method
|
641
|
+
# e.g. to use `to_sym` over `intern`:
|
642
|
+
#
|
643
|
+
# StringMethods:
|
644
|
+
# PreferredMethods:
|
645
|
+
# intern: to_sym
|
646
|
+
PreferredMethods:
|
647
|
+
intern: to_sym
|
648
|
+
|
619
649
|
Style/SpaceAroundBlockParameters:
|
620
650
|
EnforcedStyleInsidePipes: no_space
|
621
651
|
SupportedStyles:
|
data/config/disabled.yml
CHANGED
@@ -44,8 +44,13 @@ Style/MissingElse:
|
|
44
44
|
- case
|
45
45
|
- both
|
46
46
|
|
47
|
+
Style/MutableConstant:
|
48
|
+
Description: 'Do not assign mutable objects to constants.'
|
49
|
+
Enabled: false
|
50
|
+
|
47
51
|
Style/OptionHash:
|
48
52
|
Description: "Don't use option hashes when you can use keyword arguments."
|
53
|
+
Enabled: false
|
49
54
|
|
50
55
|
Style/Send:
|
51
56
|
Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
|
data/config/enabled.yml
CHANGED
@@ -468,9 +468,7 @@ Style/ParallelAssignment:
|
|
468
468
|
Check for simple usages of parallel assignment.
|
469
469
|
It will only warn when the number of variables
|
470
470
|
matches on both sides of the assignment.
|
471
|
-
This also provides performance benefits
|
472
471
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parallel-assignment'
|
473
|
-
Reference: 'https://github.com/JuanitoFatas/fast-ruby#parallel-assignment-vs-sequential-assignment-code'
|
474
472
|
Enabled: true
|
475
473
|
|
476
474
|
Style/ParenthesesAroundCondition:
|
@@ -519,6 +517,10 @@ Style/RedundantException:
|
|
519
517
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-runtimeerror'
|
520
518
|
Enabled: true
|
521
519
|
|
520
|
+
Style/RedundantFreeze:
|
521
|
+
Description: "Checks usages of Object#freeze on immutable objects."
|
522
|
+
Enabled: true
|
523
|
+
|
522
524
|
Style/RedundantReturn:
|
523
525
|
Description: "Don't use return where it's not required."
|
524
526
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-return'
|
@@ -696,6 +698,10 @@ Style/StringLiteralsInInterpolation:
|
|
696
698
|
strings match the configured preference.
|
697
699
|
Enabled: true
|
698
700
|
|
701
|
+
Style/StringMethods:
|
702
|
+
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
703
|
+
Enabled: true
|
704
|
+
|
699
705
|
Style/StructInheritance:
|
700
706
|
Description: 'Checks for inheritance from Struct.new.'
|
701
707
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new'
|
@@ -891,6 +897,10 @@ Lint/DuplicateMethods:
|
|
891
897
|
Description: 'Check for duplicate methods calls.'
|
892
898
|
Enabled: true
|
893
899
|
|
900
|
+
Lint/DuplicatedKey:
|
901
|
+
Description: 'Check for duplicate keys in hash literals.'
|
902
|
+
Enabled: true
|
903
|
+
|
894
904
|
Lint/EachWithObjectArgument:
|
895
905
|
Description: 'Check for immutable argument given to each_with_object.'
|
896
906
|
Enabled: true
|
@@ -926,7 +936,7 @@ Lint/Eval:
|
|
926
936
|
|
927
937
|
Lint/FormatParameterMismatch:
|
928
938
|
Description: 'The number of parameters to format/sprint must match the fields.'
|
929
|
-
Enabled: true
|
939
|
+
Enabled: true
|
930
940
|
|
931
941
|
Lint/HandleExceptions:
|
932
942
|
Description: "Don't suppress exception."
|
@@ -1050,6 +1060,12 @@ Lint/Void:
|
|
1050
1060
|
|
1051
1061
|
##################### Performance #############################
|
1052
1062
|
|
1063
|
+
Performance/CaseWhenSplat:
|
1064
|
+
Description: >-
|
1065
|
+
Place `when` conditions that use splat at the end
|
1066
|
+
of the list of `when` branches.
|
1067
|
+
Enabled: true
|
1068
|
+
|
1053
1069
|
Performance/Count:
|
1054
1070
|
Description: >-
|
1055
1071
|
Use `count` instead of `select...size`, `reject...size`,
|
data/lib/rubocop.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'parser/current'
|
4
4
|
require 'rainbow'
|
5
|
-
# Rainbow 2.0 does not load the monkey-patch for String by default.
|
6
|
-
require 'rainbow/ext/string' unless String.method_defined?(:color)
|
7
5
|
|
8
6
|
require 'English'
|
9
7
|
require 'set'
|
@@ -54,6 +52,7 @@ require 'rubocop/cop/mixin/if_node'
|
|
54
52
|
require 'rubocop/cop/mixin/negative_conditional'
|
55
53
|
require 'rubocop/cop/mixin/on_method_def'
|
56
54
|
require 'rubocop/cop/mixin/method_complexity'
|
55
|
+
require 'rubocop/cop/mixin/method_preference'
|
57
56
|
require 'rubocop/cop/mixin/min_body_length'
|
58
57
|
require 'rubocop/cop/mixin/on_normal_if_unless'
|
59
58
|
require 'rubocop/cop/mixin/parser_diagnostic'
|
@@ -78,6 +77,7 @@ require 'rubocop/cop/lint/debugger'
|
|
78
77
|
require 'rubocop/cop/lint/def_end_alignment'
|
79
78
|
require 'rubocop/cop/lint/deprecated_class_methods'
|
80
79
|
require 'rubocop/cop/lint/duplicate_methods'
|
80
|
+
require 'rubocop/cop/lint/duplicated_key'
|
81
81
|
require 'rubocop/cop/lint/each_with_object_argument'
|
82
82
|
require 'rubocop/cop/lint/else_layout'
|
83
83
|
require 'rubocop/cop/lint/empty_ensure'
|
@@ -123,6 +123,7 @@ require 'rubocop/cop/metrics/method_length'
|
|
123
123
|
require 'rubocop/cop/metrics/parameter_lists'
|
124
124
|
require 'rubocop/cop/metrics/perceived_complexity'
|
125
125
|
|
126
|
+
require 'rubocop/cop/performance/case_when_splat'
|
126
127
|
require 'rubocop/cop/performance/count'
|
127
128
|
require 'rubocop/cop/performance/detect'
|
128
129
|
require 'rubocop/cop/performance/flat_map'
|
@@ -218,6 +219,7 @@ require 'rubocop/cop/style/multiline_block_layout'
|
|
218
219
|
require 'rubocop/cop/style/multiline_if_then'
|
219
220
|
require 'rubocop/cop/style/multiline_operation_indentation'
|
220
221
|
require 'rubocop/cop/style/multiline_ternary_operator'
|
222
|
+
require 'rubocop/cop/style/mutable_constant'
|
221
223
|
require 'rubocop/cop/style/negated_if'
|
222
224
|
require 'rubocop/cop/style/negated_while'
|
223
225
|
require 'rubocop/cop/style/nested_ternary_operator'
|
@@ -240,6 +242,7 @@ require 'rubocop/cop/style/proc'
|
|
240
242
|
require 'rubocop/cop/style/raise_args'
|
241
243
|
require 'rubocop/cop/style/redundant_begin'
|
242
244
|
require 'rubocop/cop/style/redundant_exception'
|
245
|
+
require 'rubocop/cop/style/redundant_freeze'
|
243
246
|
require 'rubocop/cop/style/redundant_return'
|
244
247
|
require 'rubocop/cop/style/redundant_self'
|
245
248
|
require 'rubocop/cop/style/regexp_literal'
|
@@ -275,6 +278,7 @@ require 'rubocop/cop/style/space_inside_string_interpolation'
|
|
275
278
|
require 'rubocop/cop/style/special_global_vars'
|
276
279
|
require 'rubocop/cop/style/string_literals'
|
277
280
|
require 'rubocop/cop/style/string_literals_in_interpolation'
|
281
|
+
require 'rubocop/cop/style/string_methods'
|
278
282
|
require 'rubocop/cop/style/struct_inheritance'
|
279
283
|
require 'rubocop/cop/style/symbol_array'
|
280
284
|
require 'rubocop/cop/style/symbol_literal'
|
@@ -329,6 +333,7 @@ require 'rubocop/target_finder'
|
|
329
333
|
require 'rubocop/token'
|
330
334
|
require 'rubocop/comment_config'
|
331
335
|
require 'rubocop/processed_source'
|
336
|
+
require 'rubocop/result_cache'
|
332
337
|
require 'rubocop/runner'
|
333
338
|
require 'rubocop/cli'
|
334
339
|
require 'rubocop/options'
|
data/lib/rubocop/cli.rb
CHANGED
@@ -103,7 +103,7 @@ module RuboCop
|
|
103
103
|
def display_error_summary(errors)
|
104
104
|
return if errors.empty?
|
105
105
|
|
106
|
-
warn "\n#{pluralize(errors.size, 'error')} occurred:".
|
106
|
+
warn Rainbow("\n#{pluralize(errors.size, 'error')} occurred:").red
|
107
107
|
|
108
108
|
errors.each { |error| warn error }
|
109
109
|
|
data/lib/rubocop/config.rb
CHANGED
@@ -23,6 +23,10 @@ module RuboCop
|
|
23
23
|
super(hash)
|
24
24
|
end
|
25
25
|
|
26
|
+
def to_s
|
27
|
+
@to_s ||= __getobj__.to_s
|
28
|
+
end
|
29
|
+
|
26
30
|
def make_excludes_absolute
|
27
31
|
keys.each do |key|
|
28
32
|
validate_section_presence(key)
|
@@ -80,7 +84,7 @@ module RuboCop
|
|
80
84
|
def warn_unless_valid
|
81
85
|
validate
|
82
86
|
rescue Config::ValidationError => e
|
83
|
-
warn "Warning: #{e.message}".
|
87
|
+
warn Rainbow.new.wrap("Warning: #{e.message}").red
|
84
88
|
end
|
85
89
|
|
86
90
|
def add_missing_namespaces
|
@@ -163,11 +167,12 @@ module RuboCop
|
|
163
167
|
# directory. This is so that paths in config/default.yml, for example, are
|
164
168
|
# not relative to RuboCop's config directory since that wouldn't work.
|
165
169
|
def base_dir_for_path_parameters
|
166
|
-
|
167
|
-
File.
|
168
|
-
|
169
|
-
|
170
|
-
|
170
|
+
@base_dir_for_path_parameters ||=
|
171
|
+
if File.basename(loaded_path) == ConfigLoader::DOTFILE
|
172
|
+
File.expand_path(File.dirname(loaded_path))
|
173
|
+
else
|
174
|
+
Dir.pwd
|
175
|
+
end
|
171
176
|
end
|
172
177
|
|
173
178
|
private
|
@@ -147,7 +147,11 @@ module RuboCop
|
|
147
147
|
|
148
148
|
def yaml_safe_load(yaml_code)
|
149
149
|
if YAML.respond_to?(:safe_load) # Ruby 2.1+
|
150
|
-
|
150
|
+
if defined?(SafeYAML)
|
151
|
+
YAML.safe_load(yaml_code, nil, whitelisted_tags: %w(!ruby/regexp))
|
152
|
+
else
|
153
|
+
YAML.safe_load(yaml_code, [Regexp])
|
154
|
+
end
|
151
155
|
else
|
152
156
|
YAML.load(yaml_code)
|
153
157
|
end
|
@@ -178,8 +182,8 @@ module RuboCop
|
|
178
182
|
end
|
179
183
|
|
180
184
|
def old_auto_config_file_warning
|
181
|
-
warn 'Attention: rubocop-todo.yml has been renamed to ' \
|
182
|
-
|
185
|
+
warn Rainbow('Attention: rubocop-todo.yml has been renamed to ' \
|
186
|
+
"#{AUTO_GENERATED_FILE}").red
|
183
187
|
exit(1)
|
184
188
|
end
|
185
189
|
end
|