Sha256: 2dc79e2814a875af249d024992933f8c239b14bd5d7eda310ead3ee0550f40a9

Contents?: true

Size: 854 Bytes

Versions: 5

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Workit
      # Check for controller action must be using `action_args`.
      #
      # @example
      #   # bad
      #   class FooController
      #     def index
      #       # ...
      #     end
      #   end
      #
      #   # good
      #   class FooController
      #     def index(foo:)
      #       # ...
      #     end
      #
      #     def not_action
      #       # ...
      #     end
      #   end
      #
      class ActionArgs < Base
        MSG = "Consider using `action_args`."

        def on_def(node)
          add_offense(node) if !node.arguments? && controller_methods.include?(node.method_name.to_s)
        end

        private

        def controller_methods
          cop_config.fetch("ControllerMethods", [])
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workitcop-0.5.0 lib/rubocop/cop/workit/action_args.rb
workitcop-0.4.2 lib/rubocop/cop/workit/action_args.rb
workitcop-0.4.0 lib/rubocop/cop/workit/action_args.rb
workitcop-0.3.0 lib/rubocop/cop/workit/action_args.rb
workitcop-0.2.0 lib/rubocop/cop/workit/action_args.rb