Sha256: 4171f5f9f021ee49dee5c01a0ecb0182b0c06e9aeac90e88e20fdec0c3a1b4aa
Contents?: true
Size: 1.08 KB
Versions: 8
Compression:
Stored size: 1.08 KB
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 |module_node| if "ApplicationHelper" != module_node.module_name.to_s && empty_body?(module_node) add_error "remove empty helpers" end end protected def empty_body?(module_node) s(:bodystmt, s(:stmts_add, s(:stmts_new), s(:void_stmt)), nil, nil, nil) == module_node.body end end end end
Version data entries
8 entries across 8 versions & 1 rubygems