rubocop-rails 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +4 -0
- data/lib/rubocop/cop/rails/rake_environment.rb +7 -6
- data/lib/rubocop/cop/rails/save_bang.rb +10 -2
- data/lib/rubocop/rails/inject.rb +1 -1
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cf251ed7e29a11391396009eb82eed3fa4684e100b26b9041d469da2db04133
|
4
|
+
data.tar.gz: 440778968fbafa4dd3415741d8ef3c49e6025bee7ec85454a5b7012859e657c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe54c2657de98b317f8df85618a4a00708be71dc8c7c924a43734773a1f3d31da6d85e44cbb983f5c10ecb235bf420ac86a4e67ac86a45b70e7c9b8403f4623e
|
7
|
+
data.tar.gz: 4c9111285fe0211b5b1da14f8b31d2023a20e3b223dee3a1a3fcec0c66e622a0116ec783059a5161042640f92799b4df2b7585a4dd0ac96f12b06fa776886960
|
data/README.md
CHANGED
data/config/default.yml
CHANGED
@@ -29,15 +29,16 @@ module RuboCop
|
|
29
29
|
MSG = 'Include `:environment` task as a dependency for all Rake tasks.'
|
30
30
|
|
31
31
|
def_node_matcher :task_definition?, <<~PATTERN
|
32
|
-
(send nil? :task ...)
|
32
|
+
(block $(send nil? :task ...) ...)
|
33
33
|
PATTERN
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def on_block(node)
|
36
|
+
task_definition?(node) do |task_method|
|
37
|
+
return if task_name(task_method) == :default
|
38
|
+
return if with_dependencies?(task_method)
|
39
39
|
|
40
|
-
|
40
|
+
add_offense(task_method)
|
41
|
+
end
|
41
42
|
end
|
42
43
|
|
43
44
|
private
|
@@ -12,7 +12,8 @@ module RuboCop
|
|
12
12
|
# - update or save calls, assigned to a variable,
|
13
13
|
# or used as a condition in an if/unless/case statement.
|
14
14
|
# - create calls, assigned to a variable that then has a
|
15
|
-
# call to `persisted
|
15
|
+
# call to `persisted?`, or whose return value is checked by
|
16
|
+
# `persisted?` immediately
|
16
17
|
# - calls if the result is explicitly returned from methods and blocks,
|
17
18
|
# or provided as arguments.
|
18
19
|
# - calls whose signature doesn't look like an ActiveRecord
|
@@ -137,16 +138,19 @@ module RuboCop
|
|
137
138
|
add_offense_for_node(node, CREATE_MSG)
|
138
139
|
end
|
139
140
|
|
140
|
-
|
141
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
142
|
+
def on_send(node)
|
141
143
|
return unless persist_method?(node)
|
142
144
|
return if return_value_assigned?(node)
|
143
145
|
return if implicit_return?(node)
|
144
146
|
return if check_used_in_condition_or_compound_boolean(node)
|
145
147
|
return if argument?(node)
|
146
148
|
return if explicit_return?(node)
|
149
|
+
return if checked_immediately?(node)
|
147
150
|
|
148
151
|
add_offense_for_node(node)
|
149
152
|
end
|
153
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
150
154
|
alias on_csend on_send
|
151
155
|
|
152
156
|
def autocorrect(node)
|
@@ -238,6 +242,10 @@ module RuboCop
|
|
238
242
|
parent.if_type? || parent.case_type?
|
239
243
|
end
|
240
244
|
|
245
|
+
def checked_immediately?(node)
|
246
|
+
node.parent && call_to_persisted?(node.parent)
|
247
|
+
end
|
248
|
+
|
241
249
|
def allowed_receiver?(node)
|
242
250
|
return false unless node.receiver
|
243
251
|
return false unless cop_config['AllowedReceivers']
|
data/lib/rubocop/rails/inject.rb
CHANGED
@@ -8,7 +8,7 @@ module RuboCop
|
|
8
8
|
def self.defaults!
|
9
9
|
path = CONFIG_DEFAULT.to_s
|
10
10
|
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
11
|
-
config = Config.new(hash, path)
|
11
|
+
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
12
12
|
puts "configuration from #{path}" if ConfigLoader.debug?
|
13
13
|
config = ConfigLoader.merge_with_default(config, path, unset_nil: false)
|
14
14
|
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-01-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|