Class: RuboCop::Cop::Itamae::NeedlessDefaultAction
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Itamae::NeedlessDefaultAction
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/itamae/needless_default_action.rb
Overview
Checks whether default action is written for resource.
Constant Summary collapse
- MSG =
'Prefer to omit the default action.'
- RESOURCE_DEFAULT_ACTIONS =
{ directory: :create, execute: :run, file: :create, gem_package: :install, git: :sync, group: :create, http_request: :create, link: :create, local_ruby_block: :run, package: :install, remote_directory: :create, remote_file: :create, service: :nothing, template: :create, user: :create }.freeze
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rubocop/cop/itamae/needless_default_action.rb', line 60 def on_block(node) find_resource(node) do |resource, param_nodes| param_nodes.compact.each do |param_node| find_action(param_node) do |action| next unless action == RESOURCE_DEFAULT_ACTIONS[resource] add_offense(param_node.loc.expression) do |corrector| remove_action_param(corrector, param_node.parent, param_node) if param_node.send_type? end end end end end |