rubocop-rails 2.8.0 → 2.8.1

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: 6e89f00783e4dce6642e43ba4a4bf8ee29d078131f71404230db8fd2a1f87248
4
- data.tar.gz: bfbca38eb400e89e260b572babc327afec01b25bad89178179e8276ef7ce651c
3
+ metadata.gz: 49338e1944d78e63ec06fc37e16cbe3010f68f94d99ad24d5353be0c156bf8cb
4
+ data.tar.gz: 90823cd3bac084df9ac449fb6b0cb07a570721d2449c755432f022fb7c558e54
5
5
  SHA512:
6
- metadata.gz: 241d43809d5cbfa4684fa83c1b92c9069447bae05ca0235d137e6934a2a9ad35ff3e00fba46928e793045ee1cf35dc3a520cca9f177e8c3280530282eb52ac06
7
- data.tar.gz: 7019b400331651ad86a94e9562f93e31c32025ae5ed9c8c5da0f62c65974b21052438908a535da9314a6b903ea3ff6815dc7a0a6350ce3db9d6ab1d0ac18d015
6
+ metadata.gz: c242d3a6cdea9df1e4e7d9000e55db30d68dfd21317a286ad097c34a52e6cbd53a8fc6442a3333a312373adf8d7bfd05b562cf9a7391a752a7dccdc357a1b87e
7
+ data.tar.gz: fafe45955b9f0b50e403f37bdb499cdb78c6883f9472faba784e4e6e64a0fa661902d1700d38bd3a1d8c8a1c1cfc7ff2751e01cd37174cdda9025e9ef4195c43
@@ -52,6 +52,7 @@ module RuboCop
52
52
  # @param table [RuboCop::Rails::SchemaLoader::Table]
53
53
  # @return [String, nil]
54
54
  def resolve_relation_into_column(name:, class_node:, table:)
55
+ return unless table
55
56
  return name if table.with_column?(name: name)
56
57
 
57
58
  find_belongs_to(class_node) do |belongs_to|
@@ -59,7 +59,7 @@ module RuboCop
59
59
 
60
60
  def each_after_commit_callback(class_node)
61
61
  class_send_nodes(class_node).each do |node|
62
- yield node if after_commit_callback?(node)
62
+ yield node if after_commit_callback?(node) && named_callback?(node)
63
63
  end
64
64
  end
65
65
 
@@ -78,6 +78,13 @@ module RuboCop
78
78
  def after_commit_callback?(node)
79
79
  AFTER_COMMIT_CALLBACKS.include?(node.method_name)
80
80
  end
81
+
82
+ def named_callback?(node)
83
+ name = node.first_argument
84
+ return false unless name
85
+
86
+ name.sym_type?
87
+ end
81
88
  end
82
89
  end
83
90
  end
@@ -41,6 +41,7 @@ module RuboCop
41
41
  method_name = node.method_name
42
42
  static_name = static_method_name(method_name)
43
43
  return unless static_name
44
+ return if node.arguments.any?(&:splat_type?)
44
45
 
45
46
  add_offense(node,
46
47
  message: format(MSG, static_name: static_name,
@@ -16,6 +16,7 @@ module RuboCop
16
16
  #
17
17
  # # good
18
18
  # get :new, params: { user_id: 1 }
19
+ # get :new, **options
19
20
  class HttpPositionalArguments < Cop
20
21
  extend TargetRailsVersion
21
22
 
@@ -32,6 +33,10 @@ module RuboCop
32
33
  (send nil? {#{HTTP_METHODS.map(&:inspect).join(' ')}} !nil? $_ ...)
33
34
  PATTERN
34
35
 
36
+ def_node_matcher :kwsplat_hash?, <<~PATTERN
37
+ (hash (kwsplat _))
38
+ PATTERN
39
+
35
40
  def on_send(node)
36
41
  http_request?(node) do |data|
37
42
  return unless needs_conversion?(data)
@@ -61,6 +66,7 @@ module RuboCop
61
66
 
62
67
  def needs_conversion?(data)
63
68
  return true unless data.hash_type?
69
+ return false if kwsplat_hash?(data)
64
70
 
65
71
  data.each_pair.none? do |pair|
66
72
  special_keyword_arg?(pair.key) ||
@@ -24,7 +24,7 @@ module RuboCop
24
24
  (block
25
25
  ({send csend} _ :each_with_object (hash))
26
26
  (args (arg $_el) (arg _memo))
27
- ({send csend} (lvar _memo) :[]= $_ (lvar _el)))
27
+ ({send csend} (lvar _memo) :[]= $!`_memo (lvar _el)))
28
28
  PATTERN
29
29
 
30
30
  def_node_matcher :on_bad_to_h, <<~PATTERN
@@ -27,7 +27,7 @@ module RuboCop
27
27
  (block
28
28
  ({send csend} _ :each_with_object (hash))
29
29
  (args (arg $_el) (arg _memo))
30
- ({send csend} (lvar _memo) :[]= (lvar _el) $_))
30
+ ({send csend} (lvar _memo) :[]= (lvar _el) $!`_memo))
31
31
  PATTERN
32
32
 
33
33
  def_node_matcher :on_bad_to_h, <<~PATTERN
@@ -360,7 +360,7 @@ module RuboCop
360
360
  key.children.first.to_sym
361
361
  end
362
362
 
363
- hash_keys & keys == keys
363
+ (hash_keys & keys).sort == keys
364
364
  end
365
365
  end
366
366
  end
@@ -46,6 +46,8 @@ module RuboCop
46
46
 
47
47
  def find_schema_information(node)
48
48
  klass = class_node(node)
49
+ return unless klass
50
+
49
51
  table = schema.table_by(name: table_name(klass))
50
52
  names = column_names(node)
51
53
 
@@ -10,6 +10,8 @@ module RuboCop
10
10
  # # bad
11
11
  # User.where('name != ?', 'Gabe')
12
12
  # User.where('name != :name', name: 'Gabe')
13
+ # User.where('name <> ?', 'Gabe')
14
+ # User.where('name <> :name', name: 'Gabe')
13
15
  # User.where('name IS NOT NULL')
14
16
  # User.where('name NOT IN (?)', ['john', 'jane'])
15
17
  # User.where('name NOT IN (:names)', names: ['john', 'jane'])
@@ -62,9 +64,9 @@ module RuboCop
62
64
  end
63
65
  end
64
66
 
65
- NOT_EQ_ANONYMOUS_RE = /\A([\w.]+)\s+!=\s+\?\z/.freeze # column != ?
67
+ NOT_EQ_ANONYMOUS_RE = /\A([\w.]+)\s+(?:!=|<>)\s+\?\z/.freeze # column != ?, column <> ?
66
68
  NOT_IN_ANONYMOUS_RE = /\A([\w.]+)\s+NOT\s+IN\s+\(\?\)\z/i.freeze # column NOT IN (?)
67
- NOT_EQ_NAMED_RE = /\A([\w.]+)\s+!=\s+:(\w+)\z/.freeze # column != :column
69
+ NOT_EQ_NAMED_RE = /\A([\w.]+)\s+(?:!=|<>)\s+:(\w+)\z/.freeze # column != :column, column <> :column
68
70
  NOT_IN_NAMED_RE = /\A([\w.]+)\s+NOT\s+IN\s+\(:(\w+)\)\z/i.freeze # column NOT IN (:column)
69
71
  IS_NOT_NULL_RE = /\A([\w.]+)\s+IS\s+NOT\s+NULL\z/i.freeze # column IS NOT NULL
70
72
 
@@ -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.8.0'
7
+ STRING = '2.8.1'
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.8.0
4
+ version: 2.8.1
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: 2020-09-04 00:00:00.000000000 Z
13
+ date: 2020-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport