rubocop 0.58.1 → 0.58.2
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 +6 -5
- data/config/default.yml +1 -1
- data/lib/rubocop/cop/layout/class_structure.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +3 -1
- data/lib/rubocop/cop/lint/shadowed_argument.rb +31 -4
- data/lib/rubocop/cop/lint/unneeded_require_statement.rb +0 -3
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +7 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +17 -2
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +6 -6
- data/lib/rubocop/magic_comment.rb +2 -2
- data/lib/rubocop/path_util.rb +1 -1
- data/lib/rubocop/result_cache.rb +1 -2
- data/lib/rubocop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3195801b4e3ffa9ab52997ec2600cdc62b5c4e23
|
4
|
+
data.tar.gz: 8b1276d6c0101f1556d374e67d1749010b53542a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5dff57a5eeecb51495820462954f998817b9ad3b9018e603ee0f2f79ea8445e9e4bbe49578f3bdb091fbe47a8f53d179c3713c449fbc6510a7f068f96e7c015
|
7
|
+
data.tar.gz: 0a4d5da0871e328ca5bd9de6b048d3eac8e74a6b95f6682f0ddfbd220a6e4b13a4925e4d31473184fc0bfe818245a93d40225b2353011f88cf12da55e026dd32
|
data/README.md
CHANGED
@@ -19,11 +19,12 @@
|
|
19
19
|
> Role models are important. <br/>
|
20
20
|
> -- Officer Alex J. Murphy / RoboCop
|
21
21
|
|
22
|
-
**RuboCop** is a Ruby static code analyzer. Out of
|
23
|
-
enforce many of the guidelines outlined in the
|
24
|
-
[Ruby Style
|
22
|
+
**RuboCop** is a Ruby static code analyzer and code formatter. Out of
|
23
|
+
the box it will enforce many of the guidelines outlined in the
|
24
|
+
community [Ruby Style
|
25
|
+
Guide](https://github.com/rubocop-hq/ruby-style-guide).
|
25
26
|
|
26
|
-
|
27
|
+
RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
|
27
28
|
[configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
|
28
29
|
|
29
30
|
Apart from reporting problems in your code, RuboCop can also
|
@@ -53,7 +54,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
53
54
|
might want to use a conservative version locking in your `Gemfile`:
|
54
55
|
|
55
56
|
```rb
|
56
|
-
gem 'rubocop', '~> 0.58.
|
57
|
+
gem 'rubocop', '~> 0.58.2', require: false
|
57
58
|
```
|
58
59
|
|
59
60
|
## Quickstart
|
data/config/default.yml
CHANGED
@@ -42,7 +42,6 @@ AllCops:
|
|
42
42
|
- '**/.irbrc'
|
43
43
|
- '**/.pryrc'
|
44
44
|
- '**/buildfile'
|
45
|
-
- '**/config.ru'
|
46
45
|
- '**/Appraisals'
|
47
46
|
- '**/Berksfile'
|
48
47
|
- '**/Brewfile'
|
@@ -798,6 +797,7 @@ Naming/UncommunicativeMethodParamName:
|
|
798
797
|
- 'on'
|
799
798
|
- in
|
800
799
|
- at
|
800
|
+
- ip
|
801
801
|
# Blacklisted names that will register an offense
|
802
802
|
ForbiddenNames: []
|
803
803
|
|
@@ -5,10 +5,13 @@ module RuboCop
|
|
5
5
|
module Lint
|
6
6
|
# This cop checks for shadowed arguments.
|
7
7
|
#
|
8
|
+
# This cop has `IgnoreImplicitReferences` configuration option.
|
9
|
+
# It means argument shadowing is used in order to pass parameters
|
10
|
+
# to zero arity `super` when `IgnoreImplicitReferences` is `true`.
|
11
|
+
#
|
8
12
|
# @example
|
9
13
|
#
|
10
14
|
# # bad
|
11
|
-
#
|
12
15
|
# do_something do |foo|
|
13
16
|
# foo = 42
|
14
17
|
# puts foo
|
@@ -19,10 +22,7 @@ module RuboCop
|
|
19
22
|
# puts foo
|
20
23
|
# end
|
21
24
|
#
|
22
|
-
# @example
|
23
|
-
#
|
24
25
|
# # good
|
25
|
-
#
|
26
26
|
# do_something do |foo|
|
27
27
|
# foo = foo + 42
|
28
28
|
# puts foo
|
@@ -36,6 +36,33 @@ module RuboCop
|
|
36
36
|
# def do_something(foo)
|
37
37
|
# puts foo
|
38
38
|
# end
|
39
|
+
#
|
40
|
+
# @example IgnoreImplicitReferences: false (default)
|
41
|
+
#
|
42
|
+
# # bad
|
43
|
+
# def do_something(foo)
|
44
|
+
# foo = 42
|
45
|
+
# super
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# def do_something(foo)
|
49
|
+
# foo = super
|
50
|
+
# bar
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @example IgnoreImplicitReferences: true
|
54
|
+
#
|
55
|
+
# # good
|
56
|
+
# def do_something(foo)
|
57
|
+
# foo = 42
|
58
|
+
# super
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# def do_something(foo)
|
62
|
+
# foo = super
|
63
|
+
# bar
|
64
|
+
# end
|
65
|
+
#
|
39
66
|
class ShadowedArgument < Cop
|
40
67
|
MSG = 'Argument `%<argument>s` was shadowed by a local variable ' \
|
41
68
|
'before it was used.'.freeze
|
@@ -22,11 +22,8 @@ module RuboCop
|
|
22
22
|
# # good
|
23
23
|
# require 'unloaded_feature'
|
24
24
|
class UnneededRequireStatement < Cop
|
25
|
-
extend TargetRubyVersion
|
26
25
|
include RangeHelp
|
27
26
|
|
28
|
-
minimum_target_ruby_version 2.2
|
29
|
-
|
30
27
|
MSG = 'Remove unnecessary `require` statement.'.freeze
|
31
28
|
|
32
29
|
def_node_matcher :unnecessary_require_statement?, <<-PATTERN
|
@@ -34,7 +34,13 @@ module RuboCop
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def leading_comment_lines
|
37
|
-
processed_source
|
37
|
+
comments = processed_source.comments
|
38
|
+
|
39
|
+
comments.each_with_object([]) do |comment, leading_comments|
|
40
|
+
next if comment.loc.line > 3
|
41
|
+
|
42
|
+
leading_comments << comment.text
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
@@ -8,7 +8,7 @@ module RuboCop
|
|
8
8
|
#
|
9
9
|
# This cop can be configured with the EnforcedStyleForLeadingUnderscores
|
10
10
|
# directive. It can be configured to allow for memoized instance variables
|
11
|
-
# prefixed with an underscore. Prefixing ivars with an
|
11
|
+
# prefixed with an underscore. Prefixing ivars with an underscore is a
|
12
12
|
# convention that is used to implicitly indicate that an ivar should not
|
13
13
|
# be set or referencd outside of the memoization method.
|
14
14
|
#
|
@@ -21,6 +21,11 @@ module RuboCop
|
|
21
21
|
# end
|
22
22
|
#
|
23
23
|
# # good
|
24
|
+
# def _foo
|
25
|
+
# @foo ||= calculate_expensive_thing
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# # good
|
24
29
|
# def foo
|
25
30
|
# @foo ||= calculate_expensive_thing
|
26
31
|
# end
|
@@ -54,6 +59,11 @@ module RuboCop
|
|
54
59
|
# @_foo ||= calculate_expensive_thing
|
55
60
|
# end
|
56
61
|
#
|
62
|
+
# # good
|
63
|
+
# def _foo
|
64
|
+
# @_foo ||= calculate_expensive_thing
|
65
|
+
# end
|
66
|
+
#
|
57
67
|
# @example EnforcedStyleForLeadingUnderscores :optional
|
58
68
|
# # bad
|
59
69
|
# def foo
|
@@ -69,6 +79,11 @@ module RuboCop
|
|
69
79
|
# def foo
|
70
80
|
# @_foo ||= calculate_expensive_thing
|
71
81
|
# end
|
82
|
+
#
|
83
|
+
# # good
|
84
|
+
# def _foo
|
85
|
+
# @_foo ||= calculate_expensive_thing
|
86
|
+
# end
|
72
87
|
class MemoizedInstanceVariableName < Cop
|
73
88
|
include ConfigurableEnforcedStyle
|
74
89
|
|
@@ -118,7 +133,7 @@ module RuboCop
|
|
118
133
|
|
119
134
|
return false unless valid_leading_underscore?(variable_name)
|
120
135
|
|
121
|
-
variable_name.sub(/\A_/, '') == method_name
|
136
|
+
variable_name.sub(/\A_/, '') == method_name.sub(/\A_/, '')
|
122
137
|
end
|
123
138
|
|
124
139
|
def message(variable)
|
@@ -3,13 +3,13 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Rails
|
6
|
-
# This cop checks that methods specified in the filter's `only`
|
7
|
-
#
|
6
|
+
# This cop checks that methods specified in the filter's `only` or
|
7
|
+
# `except` options are defined within the same class or module.
|
8
8
|
#
|
9
|
-
# You can specify methods of superclass or methods added
|
10
|
-
# on the filter, but these confuse developers. If you
|
11
|
-
#
|
12
|
-
# the filter in that class or module.
|
9
|
+
# You can technically specify methods of superclass or methods added
|
10
|
+
# by mixins on the filter, but these confuse developers. If you
|
11
|
+
# specify methods that are defined in other classes or modules, you
|
12
|
+
# should define the filter in that class or module.
|
13
13
|
#
|
14
14
|
# @example
|
15
15
|
# # bad
|
@@ -190,7 +190,7 @@ module RuboCop
|
|
190
190
|
class SimpleComment < MagicComment
|
191
191
|
# Match `encoding` or `coding`
|
192
192
|
def encoding
|
193
|
-
extract(
|
193
|
+
extract(/\A\s*\#.*\b(?:en)?coding: (#{TOKEN})/i)
|
194
194
|
end
|
195
195
|
|
196
196
|
private
|
@@ -203,7 +203,7 @@ module RuboCop
|
|
203
203
|
# Case-insensitive and dashes/underscores are acceptable.
|
204
204
|
# @see https://git.io/vM7Mg
|
205
205
|
def extract_frozen_string_literal
|
206
|
-
extract(/\A
|
206
|
+
extract(/\A\s*#\s*frozen[_-]string[_-]literal:\s*(#{TOKEN})\s*\z/i)
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
data/lib/rubocop/path_util.rb
CHANGED
data/lib/rubocop/result_cache.rb
CHANGED
@@ -84,7 +84,6 @@ module RuboCop
|
|
84
84
|
relevant_options_digest(options),
|
85
85
|
file_checksum(file, config_store))
|
86
86
|
@cached_data = CachedData.new(file)
|
87
|
-
@pwd = Dir.pwd
|
88
87
|
end
|
89
88
|
|
90
89
|
def valid?
|
@@ -136,7 +135,7 @@ module RuboCop
|
|
136
135
|
digester = Digest::MD5.new
|
137
136
|
mode = File.stat(file).mode
|
138
137
|
digester.update(
|
139
|
-
"#{
|
138
|
+
"#{file}#{mode}#{config_store.for(file).signature}"
|
140
139
|
)
|
141
140
|
digester.file(file)
|
142
141
|
digester.hexdigest
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '0.58.
|
6
|
+
STRING = '0.58.2'.freeze
|
7
7
|
|
8
8
|
MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
|
9
9
|
'%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'.freeze
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.58.
|
4
|
+
version: 0.58.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-07-
|
13
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jaro_winkler
|