Class: RuboCop::Cop::Style::NoHelpers

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/style/no_helpers.rb

Overview

This cop does not allow helpers to be placed in an application. View objects, specifically ViewComponent, create better Object Oriented design. Global helper methods tightly couple templates.

Constant Summary collapse

MSG =
"Helpers create global view methods. Instead, use view objects to " \
"encapsulate your display logic."

Instance Method Summary collapse

Instance Method Details

#investigate(processed_source) ⇒ Object



14
15
16
17
18
19
# File 'lib/rubocop/cop/style/no_helpers.rb', line 14

def investigate(processed_source)
  return if processed_source.blank?
  return unless helper_path?

  add_offense(processed_source.ast, message: format(MSG))
end