Sha256: 377e178bb5e6981be6bb69a6e32d523a0ac50bc3dc4248113e97d88a55bf1483

Contents?: true

Size: 785 Bytes

Versions: 6

Compression:

Stored size: 785 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>]
      #
      # :reek:FeatureEnvy
      def sniff(ctx)
        return [] if ctx.uses_super_with_implicit_arguments?
        ctx.unused_params.map do |param|
          name = param.name.to_s
          smell_warning(
            context: ctx,
            lines: [ctx.exp.line],
            message: "has unused parameter '#{name}'",
            parameters: { name: name })
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reek-4.6.1 lib/reek/smell_detectors/unused_parameters.rb
reek-4.6.0 lib/reek/smell_detectors/unused_parameters.rb
reek-4.5.6 lib/reek/smell_detectors/unused_parameters.rb
reek-4.5.5 lib/reek/smell_detectors/unused_parameters.rb
reek-4.5.4 lib/reek/smell_detectors/unused_parameters.rb
reek-4.5.3 lib/reek/smell_detectors/unused_parameters.rb