Sha256: b6fc8db0293352f97f345fb525844b52cc7919aedb4c653126b515be565306d2

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

# encoding: utf-8
require 'rails_best_practices/reviews/review'

module RailsBestPractices
  module Reviews
    # Find out unused methods in helpers.
    #
    # Implementation:
    #
    # Review process:
    #   remember all method calls in helpers.
    #   if they are not called in views or helpers,
    #   then they are unused methods in helpers.
    class RemoveUnusedMethodsInHelpersReview < Review
      include Moduleable
      include Callable
      include Exceptable

      interesting_files HELPER_FILES, VIEW_FILES

      def initialize(options={})
        super
        @helper_methods = Prepares.helper_methods
        self.class.interesting_files Prepares.helpers.map(&:decendants)
      end

      # get all unused methods at the end of review process
      add_callback :after_check do
        @helper_methods.get_all_unused_methods.each do |method|
          if !excepted?(method)
            add_error "remove unused methods (#{method.class_name}##{method.method_name})", method.file, method.line
          end
        end
      end

      protected
        def methods
          @helper_methods
        end

        def internal_except_methods
          ["*#url_for"]
        end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_best_practices-1.13.8 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.13.5 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.13.4 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.13.3 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.13.2 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.13.1 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.13.0 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.12.0 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.11.1 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
rails_best_practices-1.11.0 lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb