ducalis 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/DOCUMENTATION.md +15 -0
- data/Gemfile.lock +2 -2
- data/lib/ducalis/cops/preferable_methods.rb +37 -8
- data/lib/ducalis/cops/protected_scope_cop.rb +6 -15
- data/lib/ducalis/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: dee09942e0904fe18f8abf7a345305cbdfd8989c
|
4
|
+
data.tar.gz: f93046f6e097760d0a5768dc3f2212b9d2cfe834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b039f3df86b92eb0ccda9d61c8eaa3ac32995d9de8cc60f9f372b5c6a50b524d7dfb37385de66d3d63dd4ae4a4d97f88950a26388a225057d533da62f98e5cf7
|
7
|
+
data.tar.gz: 1278017d4fafa60ff80a176e3c2d1a4fea13a76bf279c29a3879100c46a479b33a8691992e16ed96d520b4562d59d638120657a66ce540ce8498d4f3a2c137b5
|
data/.travis.yml
CHANGED
data/DOCUMENTATION.md
CHANGED
@@ -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)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ducalis (0.5.
|
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.
|
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 => [
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
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
|
-
|
20
|
-
return unless
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
data/lib/ducalis/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|