rails_best_practices 1.23.4 → 1.23.5
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 +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb +1 -1
- data/lib/rails_best_practices/version.rb +1 -1
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +32 -0
- 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: 1b79a2271c8b3c7bb805e9dc8f77c9398c7ca059857fe1880a0afea162f1e316
|
|
4
|
+
data.tar.gz: 3c88065ef997537a0ebcca377e09b2cacebc547f93269ab2a68480aeeb639d0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad8bec7c01a84e0fd0d1b21d9e68a12c1621867d589eb9ad6d900d76683565499a4d6ef0ecf496cd36d54dda589c614db8c09b6b4842b0954372a49ba43ebccc
|
|
7
|
+
data.tar.gz: 688007d0ff2d631c945bc8fd40632a80d700091e7281487d872d0a88d1abbc6ab9ae740d441bb4de8046c71d001ad6aefb34e466ba2883b5ae5888dfa96485f9
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.0.
|
|
1
|
+
4.0.10
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -61,7 +61,7 @@ module RailsBestPractices
|
|
|
61
61
|
action_name = first_argument.hash_value('state').to_s
|
|
62
62
|
call_method(action_name, current_class_name)
|
|
63
63
|
end
|
|
64
|
-
when 'around_filter',
|
|
64
|
+
when 'around_filter', /\A(?:append_|prepend_)?(?:before|after|around)_action\z/
|
|
65
65
|
node.arguments.all.each { |argument| mark_used(argument) }
|
|
66
66
|
when 'layout'
|
|
67
67
|
first_argument = node.arguments.all.first
|
|
@@ -13,6 +13,38 @@ module RailsBestPractices
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
context 'private/protected' do
|
|
16
|
+
[
|
|
17
|
+
'before_action :load_post, prepend: true',
|
|
18
|
+
'before_action(:load_post)',
|
|
19
|
+
'after_action(:load_post)',
|
|
20
|
+
'prepend_before_action :load_post',
|
|
21
|
+
'prepend_after_action(:load_post)',
|
|
22
|
+
'prepend_around_action :load_post',
|
|
23
|
+
'append_before_action(:load_post)',
|
|
24
|
+
'append_after_action :load_post',
|
|
25
|
+
'append_around_action(:load_post)'
|
|
26
|
+
].each do |declaration|
|
|
27
|
+
it "recognizes the callback in #{declaration}" do
|
|
28
|
+
content = <<-EOF
|
|
29
|
+
class PostsController < ApplicationController
|
|
30
|
+
#{declaration}
|
|
31
|
+
skip_before_action :unused, raise: false
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def load_post; end
|
|
36
|
+
def unused; end
|
|
37
|
+
end
|
|
38
|
+
EOF
|
|
39
|
+
runner.prepare('app/controllers/posts_controller.rb', content)
|
|
40
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
|
41
|
+
runner.after_review
|
|
42
|
+
expect(runner.errors.map(&:to_s)).to eq([
|
|
43
|
+
'app/controllers/posts_controller.rb:8 - remove unused methods (PostsController#unused)'
|
|
44
|
+
])
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
16
48
|
it 'removes unused methods' do
|
|
17
49
|
content = <<-EOF
|
|
18
50
|
RailsBestPracticesCom::Application.routes.draw do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_best_practices
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.23.
|
|
4
|
+
version: 1.23.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Huang
|
|
@@ -419,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
419
419
|
- !ruby/object:Gem::Version
|
|
420
420
|
version: 1.3.6
|
|
421
421
|
requirements: []
|
|
422
|
-
rubygems_version: 4.0.
|
|
422
|
+
rubygems_version: 4.0.20
|
|
423
423
|
specification_version: 4
|
|
424
424
|
summary: a code metric tool for rails codes.
|
|
425
425
|
test_files:
|