1 # frozen_string_literal: true
6 # Use only specific action names.
8 # It is good practice to separate controller classes rather than adding more actions as needed.
9 # By default, the 7 CRUD action names are specified that are generated by the Rails scaffold.
13 # class UsersController < ApplicationController
19 # class UserArticlesController < ApplicationController
23 class SpecificActionNames < Base
24 include VisibilityHelp
26 MSG = "Use only specific action names."
28 # @param node [RuboCop::AST::DefNode]
31 return unless bad?(node)
36 "Use only specific action names (%<action_names>s).",
37 :action_names => configured_action_names.join(", ")
44 # @param node [RuboCop::AST::DefNode]
47 node_visibility(node) == :public
50 # @param node [RuboCop::AST::DefNode]
53 action?(node) && !configured_action_name?(node)
56 # @param node [RuboCop::AST::DefNode]
58 def configured_action_name?(node)
59 configured_action_names.include?(node.method_name.to_s)
62 # @return [Array<String>]
63 def configured_action_names
64 cop_config["ActionNames"]