rails_best_practices 1.19.3 → 1.19.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +0 -4
  5. data/Gemfile.lock +120 -0
  6. data/README.md +4 -1
  7. data/lib/rails_best_practices.rb +2 -0
  8. data/lib/rails_best_practices/analyzer.rb +5 -4
  9. data/lib/rails_best_practices/cli.rb +22 -0
  10. data/lib/rails_best_practices/command.rb +1 -131
  11. data/lib/rails_best_practices/core/check.rb +24 -23
  12. data/lib/rails_best_practices/core/checks_loader.rb +17 -18
  13. data/lib/rails_best_practices/core/methods.rb +9 -8
  14. data/lib/rails_best_practices/core/model_associations.rb +1 -1
  15. data/lib/rails_best_practices/core/runner.rb +38 -38
  16. data/lib/rails_best_practices/option_parser.rb +140 -0
  17. data/lib/rails_best_practices/prepares/controller_prepare.rb +8 -14
  18. data/lib/rails_best_practices/prepares/gemfile_prepare.rb +1 -1
  19. data/lib/rails_best_practices/prepares/initializer_prepare.rb +3 -3
  20. data/lib/rails_best_practices/prepares/mailer_prepare.rb +1 -1
  21. data/lib/rails_best_practices/prepares/model_prepare.rb +13 -13
  22. data/lib/rails_best_practices/prepares/route_prepare.rb +16 -15
  23. data/lib/rails_best_practices/prepares/schema_prepare.rb +1 -1
  24. data/lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb +25 -23
  25. data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +73 -72
  26. data/lib/rails_best_practices/reviews/check_destroy_return_value_review.rb +2 -1
  27. data/lib/rails_best_practices/reviews/check_save_return_value_review.rb +4 -3
  28. data/lib/rails_best_practices/reviews/default_scope_is_evil_review.rb +1 -1
  29. data/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb +1 -1
  30. data/lib/rails_best_practices/reviews/hash_syntax_review.rb +11 -11
  31. data/lib/rails_best_practices/reviews/isolate_seed_data_review.rb +8 -8
  32. data/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb +5 -5
  33. data/lib/rails_best_practices/reviews/law_of_demeter_review.rb +20 -19
  34. data/lib/rails_best_practices/reviews/move_code_into_controller_review.rb +3 -3
  35. data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +5 -5
  36. data/lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb +5 -5
  37. data/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb +13 -13
  38. data/lib/rails_best_practices/reviews/not_rescue_exception_review.rb +1 -1
  39. data/lib/rails_best_practices/reviews/not_use_default_route_review.rb +2 -2
  40. data/lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb +1 -1
  41. data/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb +3 -3
  42. data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +32 -32
  43. data/lib/rails_best_practices/reviews/remove_empty_helpers_review.rb +4 -4
  44. data/lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb +14 -14
  45. data/lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb +6 -6
  46. data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +15 -15
  47. data/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb +8 -8
  48. data/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb +71 -70
  49. data/lib/rails_best_practices/reviews/review.rb +2 -1
  50. data/lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb +1 -1
  51. data/lib/rails_best_practices/reviews/simplify_render_in_views_review.rb +11 -11
  52. data/lib/rails_best_practices/reviews/use_before_filter_review.rb +12 -9
  53. data/lib/rails_best_practices/reviews/use_model_association_review.rb +10 -10
  54. data/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb +14 -13
  55. data/lib/rails_best_practices/reviews/use_observer_review.rb +20 -20
  56. data/lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb +6 -6
  57. data/lib/rails_best_practices/reviews/use_query_attribute_review.rb +44 -41
  58. data/lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb +7 -7
  59. data/lib/rails_best_practices/reviews/use_scope_access_review.rb +14 -14
  60. data/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb +1 -1
  61. data/lib/rails_best_practices/version.rb +1 -1
  62. data/rails_best_practices.gemspec +8 -8
  63. data/spec/rails_best_practices/analyzer_spec.rb +4 -4
  64. data/spec/rails_best_practices/core/error_spec.rb +6 -3
  65. data/spec/rails_best_practices/lexicals/long_line_check_spec.rb +21 -21
  66. data/spec/rails_best_practices/prepares/gemfile_prepare_spec.rb +15 -15
  67. data/spec/rails_best_practices/prepares/route_prepare_spec.rb +17 -15
  68. data/spec/rails_best_practices/reviews/hash_syntax_review_spec.rb +4 -4
  69. data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +8 -8
  70. data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +6 -6
  71. data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +4 -2
  72. data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +6 -4
  73. data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +8 -6
  74. data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +16 -14
  75. data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +4 -4
  76. data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +14 -14
  77. data/spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb +1 -1
  78. data/spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb +51 -51
  79. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a366fcb2bd3097eb1afcc7fa940b233a4177c6d
4
- data.tar.gz: 45c9b324f42e0974e7314c1db9e634c782665e93
3
+ metadata.gz: 5465e0c3226433bf68485822ab52b54993f334c4
4
+ data.tar.gz: 05650ce6bef4b2c0bd89ac24401d3119c708313f
5
5
  SHA512:
6
- metadata.gz: fa6aed2c8549d66e9650e456787a57cc32fb052011506e10cdc94ee43803d2016d644ec4e0aae1d9b08d583abb5d2eab7c4dd26eb8754e60bac46a02f8ad4459
7
- data.tar.gz: 5558cb09e7a4a4f38af75078762d3dba880bd29a97ea2ba743df3e20edf8ca51a0fd3f440808f29043b8d00d99503257de3e18849ea3d6d355930728dd9187f6
6
+ metadata.gz: 514d93fb5333c09d93b65838aeaa3942d693c1e8c1e7b7bf388d198c5b2aca36be0820a97abf29825ef4e127233d1af0d7b911f3968f54e388530cc3e19c08f7
7
+ data.tar.gz: f502d73f187def721cbcb7df9c09fc2652b23cdd80f082b96a6301d1a3733f0dceafe0dd1c8c87dd089fcf678761c36aa7f81431908c44f2b9eb2b14a7014858
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  .DS_STORE
2
2
  .*.swp
3
- Gemfile.lock
4
3
  pkg/**
5
4
  *.gem
6
5
  .bundle
@@ -1,5 +1,9 @@
1
1
  # Next Release
2
2
 
3
+ ## 1.19.4
4
+
5
+ * Add cli class
6
+
3
7
  ## 1.19.3
4
8
 
5
9
  * Fix false positive remove unused method for around_action in
data/Gemfile CHANGED
@@ -3,10 +3,6 @@ gemspec
3
3
 
4
4
  gem 'coveralls', require: false
5
5
 
6
- if RUBY_PLATFORM =~ /darwin/i
7
- gem 'growl'
8
- gem 'rb-fsevent'
9
- end
10
6
  gem 'guard'
11
7
  gem 'guard-rspec'
12
8
  gem 'pry'
@@ -0,0 +1,120 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_best_practices (1.19.4)
5
+ activesupport
6
+ code_analyzer (>= 0.4.8)
7
+ erubis
8
+ i18n
9
+ json
10
+ require_all (~> 2.0)
11
+ ruby-progressbar
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ activesupport (5.2.1)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ awesome_print (1.6.1)
22
+ code_analyzer (0.4.8)
23
+ sexp_processor
24
+ coderay (1.1.1)
25
+ concurrent-ruby (1.0.5)
26
+ coveralls (0.8.11)
27
+ json (~> 1.8)
28
+ simplecov (~> 0.11.0)
29
+ term-ansicolor (~> 1.3)
30
+ thor (~> 0.19.1)
31
+ tins (~> 1.6.0)
32
+ diff-lcs (1.2.5)
33
+ docile (1.1.5)
34
+ erubis (2.7.0)
35
+ ffi (1.9.10)
36
+ formatador (0.2.5)
37
+ guard (2.13.0)
38
+ formatador (>= 0.2.4)
39
+ listen (>= 2.7, <= 4.0)
40
+ lumberjack (~> 1.0)
41
+ nenv (~> 0.1)
42
+ notiffany (~> 0.0)
43
+ pry (>= 0.9.12)
44
+ shellany (~> 0.0)
45
+ thor (>= 0.18.1)
46
+ guard-rspec (4.3.1)
47
+ guard (~> 2.1)
48
+ rspec (>= 2.14, < 4.0)
49
+ haml (4.0.7)
50
+ tilt
51
+ i18n (1.1.1)
52
+ concurrent-ruby (~> 1.0)
53
+ json (1.8.6)
54
+ listen (3.0.6)
55
+ rb-fsevent (>= 0.9.3)
56
+ rb-inotify (>= 0.9.7)
57
+ lumberjack (1.0.10)
58
+ method_source (0.8.2)
59
+ minitest (5.11.3)
60
+ nenv (0.3.0)
61
+ notiffany (0.0.8)
62
+ nenv (~> 0.1)
63
+ shellany (~> 0.0)
64
+ pry (0.10.3)
65
+ coderay (~> 1.1.0)
66
+ method_source (~> 0.8.1)
67
+ slop (~> 3.4)
68
+ rake (10.5.0)
69
+ rb-fsevent (0.9.7)
70
+ rb-inotify (0.9.7)
71
+ ffi (>= 0.5.0)
72
+ require_all (2.0.0)
73
+ rspec (2.14.1)
74
+ rspec-core (~> 2.14.0)
75
+ rspec-expectations (~> 2.14.0)
76
+ rspec-mocks (~> 2.14.0)
77
+ rspec-core (2.14.8)
78
+ rspec-expectations (2.14.5)
79
+ diff-lcs (>= 1.1.3, < 2.0)
80
+ rspec-mocks (2.14.6)
81
+ ruby-progressbar (1.10.0)
82
+ sexp_processor (4.10.1)
83
+ shellany (0.0.1)
84
+ simplecov (0.11.2)
85
+ docile (~> 1.1.0)
86
+ json (~> 1.8)
87
+ simplecov-html (~> 0.10.0)
88
+ simplecov-html (0.10.0)
89
+ slim (3.0.6)
90
+ temple (~> 0.7.3)
91
+ tilt (>= 1.3.3, < 2.1)
92
+ slop (3.6.0)
93
+ temple (0.7.6)
94
+ term-ansicolor (1.3.2)
95
+ tins (~> 1.0)
96
+ thor (0.19.1)
97
+ thread_safe (0.3.6)
98
+ tilt (2.0.2)
99
+ tins (1.6.0)
100
+ tzinfo (1.2.5)
101
+ thread_safe (~> 0.1)
102
+
103
+ PLATFORMS
104
+ ruby
105
+
106
+ DEPENDENCIES
107
+ awesome_print
108
+ bundler
109
+ coveralls
110
+ guard
111
+ guard-rspec
112
+ haml
113
+ pry
114
+ rails_best_practices!
115
+ rake (< 11.0)
116
+ rspec (~> 2.14.0)
117
+ slim
118
+
119
+ BUNDLED WITH
120
+ 1.16.0
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/rails_best_practices.svg)](http://badge.fury.io/rb/rails_best_practices)
4
4
  [![Build Status](https://secure.travis-ci.org/flyerhzm/rails_best_practices.svg)](http://travis-ci.org/flyerhzm/rails_best_practices)
5
5
  [![Coverage Status](https://coveralls.io/repos/railsbp/rails_best_practices/badge.svg?branch=master)](https://coveralls.io/r/railsbp/rails_best_practices)
6
- [![AwesomeCode Status for flyerhzm/rails_best_practices](https://awesomecode.io/projects/d02ecd70-e068-4ad4-b61a-7003ac24b49a/status)](https://awesomecode.io/projects/8)
6
+ [![AwesomeCode Status for flyerhzm/rails_best_practices](https://awesomecode.io/projects/d02ecd70-e068-4ad4-b61a-7003ac24b49a/status)](https://awesomecode.io/repos/flyerhzm/rails_best_practices)
7
7
 
8
8
  [![Coderwall Endorse](http://api.coderwall.com/flyerhzm/endorsecount.png)](http://coderwall.com/flyerhzm)
9
9
  [![Click here to lend your support to: rails best practices and make a donation at www.pledgie.com !](https://pledgie.com/campaigns/12057.png?skin_name=chrome)](https://pledgie.com/campaigns/12057)
@@ -182,6 +182,9 @@ Now you can customize this configuration file. The default configuration is as f
182
182
  UseScopeAccessCheck: { }
183
183
  UseTurboSprocketsRails3Check: { }
184
184
 
185
+ Now, at the root directory of a Rails app, run:
186
+
187
+ rails_best_practices . -c config/rails_best_practices.yml
185
188
 
186
189
  You can remove or comment a review to disable it, and you can change the options.
187
190
 
@@ -8,6 +8,8 @@ require 'rails_best_practices/analyzer'
8
8
  require 'rails_best_practices/lexicals'
9
9
  require 'rails_best_practices/prepares'
10
10
  require 'rails_best_practices/reviews'
11
+ require 'rails_best_practices/option_parser'
12
+ require 'rails_best_practices/cli'
11
13
 
12
14
  module RailsBestPractices
13
15
  end
@@ -19,7 +19,7 @@ module RailsBestPractices
19
19
  attr_reader :path
20
20
 
21
21
  DEFAULT_CONFIG = File.join(File.dirname(__FILE__), '..', '..', 'rails_best_practices.yml')
22
- GITHUB_URL = 'https://github.com/'.freeze
22
+ GITHUB_URL = 'https://github.com/'
23
23
 
24
24
  # initialize
25
25
  #
@@ -137,14 +137,15 @@ module RailsBestPractices
137
137
  def expand_dirs_to_files(*dirs)
138
138
  extensions = %w[rb erb rake rhtml haml slim builder rxml rabl]
139
139
 
140
- dirs.flatten.map { |entry|
140
+ dirs.flatten.map do |entry|
141
141
  next unless File.exist? entry
142
+
142
143
  if File.directory? entry
143
144
  Dir[File.join(entry, '**', "*.{#{extensions.join(',')}}")]
144
145
  else
145
146
  entry
146
147
  end
147
- }.flatten
148
+ end.flatten
148
149
  end
149
150
 
150
151
  # sort files, models first, mailers, helpers, and then sort other files by characters.
@@ -226,7 +227,7 @@ module RailsBestPractices
226
227
  template = @options['template'] ? File.read(File.expand_path(@options['template'])) : File.read(File.join(File.dirname(__FILE__), '..', '..', 'assets', 'result.html.erb'))
227
228
 
228
229
  if @options['with-github']
229
- last_commit_id = @options['last-commit-id'] ? @options['last-commit-id'] : `cd #{@runner.class.base_path} && git rev-parse HEAD`.chomp
230
+ last_commit_id = @options['last-commit-id'] || `cd #{@runner.class.base_path} && git rev-parse HEAD`.chomp
230
231
  unless @options['github-name'].start_with?('https')
231
232
  @options['github-name'] = GITHUB_URL + @options['github-name']
232
233
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBestPractices
4
+ class CLI
5
+ # Run analyze with ruby code
6
+ # @param [Array] argv command argments
7
+ # @return [Boolean] return true, if there is no violation.
8
+ # @example
9
+ # RailsBestPractices::CLI.run(['-d', '-o', 'path/to/file'])
10
+ def self.run(argv)
11
+ options = OptionParser.parse!(argv)
12
+ if !argv.empty? && !File.exist?(argv.first)
13
+ raise Errno::ENOENT, "#{argv.first} doesn't exist"
14
+ end
15
+
16
+ analyzer = Analyzer.new(argv.first, options)
17
+ analyzer.analyze
18
+ analyzer.output
19
+ analyzer.runner.errors.empty?
20
+ end
21
+ end
22
+ end
@@ -1,137 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'optparse'
4
-
5
- # Usage: rails_best_practices [options] path
6
- # -d, --debug debug mode
7
- # --silent silent mode
8
- # -f, --format FORMAT output format (text, html, yml, json, xml)
9
- # --output-file FILE output html file for the analyzing result
10
- # --without-color only output plain text without color
11
- # --with-textmate open file by textmate in html format
12
- # --with-sublime open file by sublime in html format (requires subl-handler)
13
- # --with-mvim open file by mvim in html format
14
- # --with-github GITHUB_NAME open file on github in html format, GITHUB_NAME is like railsbp/rails-bestpractices.com
15
- # --with-git display git commit and username, only support html format
16
- # --with-hg display hg commit and username, only support html format
17
- # --template TEMPLATE customize erb template
18
- # --vendor include vendor files
19
- # --spec include spec files
20
- # --test include test files
21
- # --features include features files
22
- # -x, --exclude PATTERNS don't analyze files matching a pattern
23
- # (comma-separated regexp list)
24
- # -o, --only PATTERNS analyze files only matching a pattern
25
- # (comma-separated regexp list)
26
- # -g, --generate generate configuration yaml
27
- # -v, --version show this version
28
- # -h, --help show this message
29
-
30
- options = {}
31
-
32
- OptionParser.new do |opts|
33
- opts.banner = 'Usage: rails_best_practices [options] path'
34
-
35
- opts.on('-d', '--debug', 'Debug mode') do
36
- options['debug'] = true
37
- end
38
-
39
- opts.on('-f', '--format FORMAT', 'output format (text, html, yml, json, xml)') do |format|
40
- options['format'] = format
41
- end
42
-
43
- opts.on('--without-color', 'only output plain text without color') do
44
- options['without-color'] = true
45
- end
46
-
47
- opts.on('--with-textmate', 'open file by textmate in html format') do
48
- options['with-textmate'] = true
49
- end
50
-
51
- opts.on('--with-sublime', 'open file by sublime in html format') do
52
- options['with-sublime'] = true
53
- end
54
-
55
- opts.on('--with-mvim', 'open file by mvim in html format') do
56
- options['with-mvim'] = true
57
- end
58
-
59
- opts.on('--with-github GITHUB_NAME', 'open file on github in html format') do |github_name|
60
- options['with-github'] = true
61
- options['github-name'] = github_name
62
- end
63
-
64
- opts.on('--last-commit-id COMMIT_ID', 'last commit id') do |commit_id|
65
- options['last-commit-id'] = commit_id
66
- end
67
-
68
- opts.on('--with-hg', 'display hg commit and username, only support html format') do
69
- options['with-hg'] = true
70
- end
71
-
72
- opts.on('--with-git', 'display git commit and username, only support html format') do
73
- options['with-git'] = true
74
- end
75
-
76
- opts.on('--template TEMPLATE', 'customize erb template') do |template|
77
- options['template'] = template
78
- end
79
-
80
- opts.on('--output-file OUTPUT_FILE', 'output html file for the analyzing result') do |output_file|
81
- options['output-file'] = output_file
82
- end
83
-
84
- opts.on('--silent', 'silent mode') do
85
- options['silent'] = true
86
- end
87
-
88
- %w[vendor spec test features].each do |pattern|
89
- opts.on("--#{pattern}", "include #{pattern} files") do
90
- options[pattern] = true
91
- end
92
- end
93
-
94
- opts.on_tail('-v', '--version', 'Show this version') do
95
- require 'rails_best_practices/version'
96
- puts RailsBestPractices::VERSION
97
- exit
98
- end
99
-
100
- opts.on_tail('-h', '--help', 'Show this message') do
101
- puts opts
102
- exit
103
- end
104
-
105
- opts.on('-x', '--exclude PATTERNS', "Don't analyze files matching a pattern", '(comma-separated regexp list)') do |list|
106
- begin
107
- options['exclude'] = list.split(',').map { |x| Regexp.new x }
108
- rescue RegexpError => e
109
- raise OptionParser::InvalidArgument, e.message
110
- end
111
- end
112
-
113
- opts.on('-o', '--only PATTERNS', 'Analyze files only matching a pattern', '(comma-separated regexp list)') do |list|
114
- begin
115
- options['only'] = list.split(',').map { |x| Regexp.new x }
116
- rescue RegexpError => e
117
- raise OptionParser::InvalidArgument e.message
118
- end
119
- end
120
-
121
- opts.on('-g', '--generate', 'Generate configuration yaml') do
122
- options['generate'] = true
123
- end
124
-
125
- opts.on(
126
- '-c',
127
- '--config CONFIG_PATH', 'configuration file location (defaults to config/rails_best_practices.yml)'
128
- ) do |config_path|
129
- options['config'] = config_path
130
- end
131
-
132
- opts.parse!
133
- end
134
-
4
+ options = RailsBestPractices::OptionParser.parse!
135
5
  if !ARGV.empty? && !File.exist?(ARGV.first)
136
6
  puts "#{ARGV.first} doesn't exist"
137
7
  exit 1
@@ -240,7 +240,7 @@ module RailsBestPractices
240
240
  else
241
241
  mark_used(node.message)
242
242
  last_argument = node.arguments.all.last
243
- if last_argument.present? && :bare_assoc_hash == last_argument.sexp_type
243
+ if last_argument.present? && last_argument.sexp_type == :bare_assoc_hash
244
244
  last_argument.hash_values.each { |argument_value| mark_used(argument_value) }
245
245
  end
246
246
  end
@@ -283,27 +283,28 @@ module RailsBestPractices
283
283
 
284
284
  private
285
285
 
286
- def mark_used(method_node)
287
- return if method_node == :call
288
- if :bare_assoc_hash == method_node.sexp_type
289
- method_node.hash_values.each { |value_node| mark_used(value_node) }
290
- elsif :array == method_node.sexp_type
291
- method_node.array_values.each { |value_node| mark_used(value_node) }
292
- else
293
- method_name = method_node.to_s
294
- end
295
- call_method(method_name)
286
+ def mark_used(method_node)
287
+ return if method_node == :call
288
+
289
+ if method_node.sexp_type == :bare_assoc_hash
290
+ method_node.hash_values.each { |value_node| mark_used(value_node) }
291
+ elsif method_node.sexp_type == :array
292
+ method_node.array_values.each { |value_node| mark_used(value_node) }
293
+ else
294
+ method_name = method_node.to_s
296
295
  end
296
+ call_method(method_name)
297
+ end
297
298
 
298
- def call_method(method_name, class_name = nil)
299
- class_name ||= respond_to?(:current_class_name) ? current_class_name : current_module_name
300
- if methods.has_method?(class_name, method_name)
301
- methods.get_method(class_name, method_name).mark_used
302
- end
303
- methods.mark_parent_class_method_used(class_name, method_name)
304
- methods.mark_subclasses_method_used(class_name, method_name)
305
- methods.possible_public_used(method_name)
299
+ def call_method(method_name, class_name = nil)
300
+ class_name ||= respond_to?(:current_class_name) ? current_class_name : current_module_name
301
+ if methods.has_method?(class_name, method_name)
302
+ methods.get_method(class_name, method_name).mark_used
306
303
  end
304
+ methods.mark_parent_class_method_used(class_name, method_name)
305
+ methods.mark_subclasses_method_used(class_name, method_name)
306
+ methods.possible_public_used(method_name)
307
+ end
307
308
  end
308
309
  end
309
310
  end
@@ -317,21 +318,21 @@ module RailsBestPractices
317
318
 
318
319
  # check if the controller is inherit from InheritedResources::Base.
319
320
  add_callback :start_class do |_node|
320
- if 'InheritedResources::Base' == current_extend_class_name
321
+ if current_extend_class_name == 'InheritedResources::Base'
321
322
  @inherited_resources = true
322
323
  end
323
324
  end
324
325
 
325
326
  # check if there is a DSL call inherit_resources.
326
327
  add_callback :start_var_ref do |node|
327
- if 'inherit_resources' == node.to_s
328
+ if node.to_s == 'inherit_resources'
328
329
  @inherited_resources = true
329
330
  end
330
331
  end
331
332
 
332
333
  # check if there is a DSL call inherit_resources.
333
334
  add_callback :start_vcall do |node|
334
- if 'inherit_resources' == node.to_s
335
+ if node.to_s == 'inherit_resources'
335
336
  @inherited_resources = true
336
337
  end
337
338
  end
@@ -350,7 +351,7 @@ module RailsBestPractices
350
351
  # check if the method is in the except methods list.
351
352
  def excepted?(method)
352
353
  is_ignored?(method.file) ||
353
- except_methods.any? { |except_method| Exceptable.matches method, except_method }
354
+ except_methods.any? { |except_method| Exceptable.matches method, except_method }
354
355
  end
355
356
 
356
357
  def internal_except_methods