Sha256: 45bf9d3d28edf2084d659703c187ef81509c20e20dbe9b0900abd81eb9a1257a

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 Bytes

Contents

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

module RailsBestPractices
  module Reviews
    # Review a helper file to make sure it is not an empty moduel.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/72-remove-empty-helpers.
    #
    # Implementation:
    #
    # Review process:
    #   check all helper files, if the body of module is nil, then the helper file should be removed.
    class RemoveEmptyHelpersReview < Review
      interesting_nodes :module
      interesting_files HELPER_FILES
      url "http://rails-bestpractices.com/posts/72-remove-empty-helpers"

      # check the body of module node, if it is nil, then it should be removed.
      add_callback :start_module do |node|
        if s(:bodystmt, s(:stmts_add, s(:stmts_new), s(:void_stmt)), nil, nil, nil) == node.body
          add_error "remove empty helpers", node.file, node.line
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-1.11.1 lib/rails_best_practices/reviews/remove_empty_helpers_review.rb
rails_best_practices-1.11.0 lib/rails_best_practices/reviews/remove_empty_helpers_review.rb