Sha256: 4004e269b53b30132d8cd30b1db0e5f655c0c75ac1ff653458a0d59a667599ad

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

require_relative 'base_detector'

module Reek
  module SmellDetectors
    #
    # Methods should use their parameters.
    #
    # See {file:docs/Unused-Parameters.md} for details.
    class UnusedParameters < BaseDetector
      #
      # Checks whether the given method has any unused parameters.
      #
      # @return [Array<SmellWarning>]
      #
      def sniff
        return [] if context.uses_super_with_implicit_arguments?
        context.unused_params.map do |param|
          name = param.name.to_s
          smell_warning(
            lines: [source_line],
            message: "has unused parameter '#{name}'",
            parameters: { name: name })
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reek-5.0.2 lib/reek/smell_detectors/unused_parameters.rb
reek-5.0.1 lib/reek/smell_detectors/unused_parameters.rb
reek-5.0.0 lib/reek/smell_detectors/unused_parameters.rb