Class: RuboCop::Cop::Cuseum::SinglePublicMethodService
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Cuseum::SinglePublicMethodService
- Defined in:
- lib/rubocop/cop/cuseum/single_public_method_service.rb
Overview
Ensures that service classes in app/services have at most one public method.
Constant Summary collapse
- MSG =
"Service classes should have at most one public method."
Instance Method Summary collapse
Instance Method Details
#on_class(node) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubocop/cop/cuseum/single_public_method_service.rb', line 46 def on_class(node) public_methods = extract_public_methods(node) # Allow 0 or 1 public methods, flag 2 or more return if public_methods.size <= 1 public_methods.each_with_index do |method_node, index| next if index.zero? # Allow the first public method add_offense(method_node, message: MSG) end end |