ducalis 0.5.13 → 0.5.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75bd9a05b686683a5a460a113fc81089795ddc36
4
- data.tar.gz: 88fccc0c3fec65985a012b90c303ee6ae907b80e
3
+ metadata.gz: dee09942e0904fe18f8abf7a345305cbdfd8989c
4
+ data.tar.gz: f93046f6e097760d0a5768dc3f2212b9d2cfe834
5
5
  SHA512:
6
- metadata.gz: 8085d59b75d50d3db357845b7104e5cce09e3712b9fc76d0bbc1ceff63456335888d947395fda9089fc3421f87f243c537ac46fb617217775e5ed75dbc93fd9e
7
- data.tar.gz: 5925c8c9286eb4b6fc758e818782e8467a9390c51897a56eccd7b6dac53145b0a11494f6b7901b11bdc524461ae182bc6fc5b5393638ec03f3f267f0ad2fd954
6
+ metadata.gz: b039f3df86b92eb0ccda9d61c8eaa3ac32995d9de8cc60f9f372b5c6a50b524d7dfb37385de66d3d63dd4ae4a4d97f88950a26388a225057d533da62f98e5cf7
7
+ data.tar.gz: 1278017d4fafa60ff80a176e3c2d1a4fea13a76bf279c29a3879100c46a479b33a8691992e16ed96d520b4562d59d638120657a66ce540ce8498d4f3a2c137b5
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.8
4
- - 2.3.4
5
- - 2.4.2
3
+ - 2.2.9
4
+ - 2.3.6
5
+ - 2.4.3
6
6
  before_install:
7
7
  - gem update --system
8
8
  - gem --version
9
+ - gem install bundler
@@ -630,6 +630,11 @@ User.where(id: 7).delete
630
630
  User.where(id: 7).save(validate: false)
631
631
  ```
632
632
 
633
+ ![](https://placehold.it/10/f03c15/000000?text=+) raises `update_column` method calling
634
+ ```ruby
635
+ User.where(id: 7).update_column(admin: false)
636
+ ```
637
+
633
638
  ![](https://placehold.it/10/f03c15/000000?text=+) raises `toggle!` method calling
634
639
  ```ruby
635
640
  User.where(id: 7).toggle!
@@ -745,6 +750,16 @@ Group.find(8)
745
750
  Group.includes(:profiles).find(8)
746
751
  ```
747
752
 
753
+ ![](https://placehold.it/10/f03c15/000000?text=+) raises if AR search was called with find_by id
754
+ ```ruby
755
+ Group.includes(:profiles).find_by(id: 8)
756
+ ```
757
+
758
+ ![](https://placehold.it/10/f03c15/000000?text=+) raises if AR search was called on unnamespaced constant
759
+ ```ruby
760
+ ::Group.find(8)
761
+ ```
762
+
748
763
  ![](https://placehold.it/10/f03c15/000000?text=+) ignores where statements and still raises error
749
764
  ```ruby
750
765
  Group.includes(:profiles).where(name: "John").find(8)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ducalis (0.5.13)
4
+ ducalis (0.5.14)
5
5
  git (~> 1.3, >= 1.3.0)
6
6
  policial (= 0.0.4)
7
7
  regexp-examples (~> 1.3, >= 1.3.2)
@@ -36,7 +36,7 @@ GEM
36
36
  method_source (0.9.0)
37
37
  multi_json (1.12.2)
38
38
  multipart-post (2.0.0)
39
- octokit (4.7.0)
39
+ octokit (4.8.0)
40
40
  sawyer (~> 0.8.0, >= 0.5.3)
41
41
  parser (2.4.0.2)
42
42
  ast (~> 2.3)
@@ -19,15 +19,44 @@ module Ducalis
19
19
  end
20
20
 
21
21
  DESCRIPTION = {
22
- # Method => [Alternative, Reason, Callable condition]
23
- toggle!: ['toggle.save', 'it is not invoking validations', ALWAYS_TRUE],
24
- save: [:save, 'it is not invoking validations', VALIDATE_CHECK],
25
- delete: [:destroy, 'it is not invoking callbacks', DELETE_CHECK],
26
- delete_all: [:destroy_all, 'it is not invoking callbacks', ALWAYS_TRUE],
27
- update_attribute: [:update, 'it is not invoking validation', ALWAYS_TRUE],
28
- update_column: [:update, 'it is not invoking callbacks', ALWAYS_TRUE],
22
+ # Method => [
23
+ # Alternative,
24
+ # Reason,
25
+ # Callable condition
26
+ # ]
27
+ toggle!: [
28
+ '`toggle.save`',
29
+ 'it is not invoking validations',
30
+ ALWAYS_TRUE
31
+ ],
32
+ save: [
33
+ '`save`',
34
+ 'it is not invoking validations',
35
+ VALIDATE_CHECK
36
+ ],
37
+ delete: [
38
+ '`destroy`',
39
+ 'it is not invoking callbacks',
40
+ DELETE_CHECK
41
+ ],
42
+ delete_all: [
43
+ '`destroy_all`',
44
+ 'it is not invoking callbacks',
45
+ ALWAYS_TRUE
46
+ ],
47
+ update_attribute: [
48
+ '`update` (`update_attributes` for Rails versions < 4)',
49
+ 'it is not invoking validations',
50
+ ALWAYS_TRUE
51
+ ],
52
+ update_column: [
53
+ '`update` (`update_attributes` for Rails versions < 4)',
54
+ 'it is not invoking callbacks',
55
+ ALWAYS_TRUE
56
+ ],
29
57
  update_columns: [
30
- :update, 'it is not invoking validations, callbacks and updated_at',
58
+ '`update` (`update_attributes` for Rails versions < 4)',
59
+ 'it is not invoking validations, callbacks and updated_at',
31
60
  ALWAYS_TRUE
32
61
  ]
33
62
  }.freeze
@@ -16,23 +16,14 @@ module Ducalis
16
16
  MESSAGE
17
17
 
18
18
  def on_send(node)
19
- _, method_name, *args = *node
20
- return unless method_name == :find
21
- return if args.empty?
22
- return unless children(node).any? { |subnode| subnode.type == :const }
19
+ return unless [find_method?(node), find_by_id?(node)].any?
20
+ return unless const_like?(node)
23
21
  add_offense(node, :expression, OFFENSE)
24
22
  end
25
23
 
26
- private
27
-
28
- def children(node)
29
- current_nodes = [node]
30
- while current_nodes.any? { |subnode| subnode.child_nodes.count != 0 }
31
- current_nodes = current_nodes.flat_map do |subnode|
32
- subnode.child_nodes.count.zero? ? subnode : subnode.child_nodes
33
- end
34
- end
35
- current_nodes
36
- end
24
+ def_node_search :const_like?, '(const ...)'
25
+ def_node_search :find_method?, '(send (...) :find (...))'
26
+ def_node_search :find_by_id?,
27
+ '(send (...) :find_by (:hash (:pair (:sym :id) (...))))'
37
28
  end
38
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ducalis
4
- VERSION = '0.5.13'
4
+ VERSION = '0.5.14'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ducalis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.13
4
+ version: 0.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignat Zakrevsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-19 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git