Sha256: 5c4a47e5386e530ffdd39eb143ff4b812694d8e836282044084c80febc92ac9a

Contents?: true

Size: 944 Bytes

Versions: 10

Compression:

Stored size: 944 Bytes

Contents

require_relative 'smell_detector'
require_relative 'smell_warning'

module Reek
  module Smells
    #
    # Methods should use their parameters.
    #
    # See {file:docs/Unused-Parameters.md} for details.
    # @api private
    class UnusedParameters < SmellDetector
      def self.smell_category
        'UnusedCode'
      end

      #
      # Checks whether the given method has any unused parameters.
      #
      # @return [Array<SmellWarning>]
      #
      def examine_context(method_ctx)
        return [] if method_ctx.uses_super_with_implicit_arguments?
        method_ctx.unused_params.map do |param|
          SmellWarning.new(self,
                           context: method_ctx.full_name,
                           lines: [method_ctx.exp.line],
                           message: "has unused parameter '#{param.name}'",
                           parameters: { name: param.name.to_s })
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
reek-3.3.1 lib/reek/smells/unused_parameters.rb
reek-3.3.0 lib/reek/smells/unused_parameters.rb
reek-3.2.1 lib/reek/smells/unused_parameters.rb
reek-3.2 lib/reek/smells/unused_parameters.rb
reek-3.1 lib/reek/smells/unused_parameters.rb
reek-3.0.4 lib/reek/smells/unused_parameters.rb
reek-3.0.3 lib/reek/smells/unused_parameters.rb
reek-3.0.2 lib/reek/smells/unused_parameters.rb
reek-3.0.1 lib/reek/smells/unused_parameters.rb
reek-3.0.0 lib/reek/smells/unused_parameters.rb