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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9d8cbc9fa9fc0752a334a92dd7af50f2a33331ac1b9604dc7c1f27efbc141e6
4
- data.tar.gz: 81833c9b0dbc71254f75f18eb59a13147025efdff95342c3ba1855e773301fc2
3
+ metadata.gz: 0cf251ed7e29a11391396009eb82eed3fa4684e100b26b9041d469da2db04133
4
+ data.tar.gz: 440778968fbafa4dd3415741d8ef3c49e6025bee7ec85454a5b7012859e657c4
5
5
  SHA512:
6
- metadata.gz: a5ffc7a5e763076a13e5addebf2b4321ebfddbbb19e752bfe9697003eb4451e5d5eebc4ced8c2f3f55e1e10f24a81670e14b7ec48ee748d1c15996085618b5c8
7
- data.tar.gz: 0e8b3557bfa819b2fb1304f992a48845afbb52db0c8c7beb970bbcc09c4345c5f9d2f9f273efb2692374f3a03c28c6d615824af20ca669c40359299dca53f41a
6
+ metadata.gz: fe54c2657de98b317f8df85618a4a00708be71dc8c7c924a43734773a1f3d31da6d85e44cbb983f5c10ecb235bf420ac86a4e67ac86a45b70e7c9b8403f4623e
7
+ data.tar.gz: 4c9111285fe0211b5b1da14f8b31d2023a20e3b223dee3a1a3fcec0c66e622a0116ec783059a5161042640f92799b4df2b7585a4dd0ac96f12b06fa776886960
data/README.md CHANGED
@@ -18,7 +18,7 @@ gem install rubocop-rails
18
18
  or if you use bundler put this in your `Gemfile`
19
19
 
20
20
  ```ruby
21
- gem 'rubocop-rails'
21
+ gem 'rubocop-rails', require: false
22
22
  ```
23
23
 
24
24
  ## Usage
@@ -1,5 +1,9 @@
1
1
  # Common configuration.
2
2
 
3
+ inherit_mode:
4
+ merge:
5
+ - Exclude
6
+
3
7
  AllCops:
4
8
  Exclude:
5
9
  - bin/*
@@ -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 on_send(node)
36
- return unless task_definition?(node)
37
- return if task_name(node) == :default
38
- return if with_dependencies?(node)
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
- add_offense(node)
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
- def on_send(node) # rubocop:disable Metrics/CyclomaticComplexity
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']
@@ -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)
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Rails
5
5
  # This module holds the RuboCop Rails version information.
6
6
  module Version
7
- STRING = '2.4.1'
7
+ STRING = '2.4.2'
8
8
  end
9
9
  end
10
10
  end
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.1
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: 2019-12-25 00:00:00.000000000 Z
13
+ date: 2020-01-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack