Sha256: 2ce88d21f7e93c3fe21950ecf1067affddf9ac8f11a149daba0a461fbfc40d94

Contents?: true

Size: 846 Bytes

Versions: 13

Compression:

Stored size: 846 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.
    class UnusedParameters < SmellDetector
      def self.smell_category
        'UnusedCode'
      end

      #
      # Checks whether the given method has any unused parameters.
      #
      # @return [Array<SmellWarning>]
      #
      # :reek:FeatureEnvy
      def inspect(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

13 entries across 13 versions & 1 rubygems

Version Path
reek-3.11 lib/reek/smells/unused_parameters.rb
reek-3.10.2 lib/reek/smells/unused_parameters.rb
reek-3.10.1 lib/reek/smells/unused_parameters.rb
reek-3.10.0 lib/reek/smells/unused_parameters.rb
reek-3.9.1 lib/reek/smells/unused_parameters.rb
reek-3.9.0 lib/reek/smells/unused_parameters.rb
reek-3.8.3 lib/reek/smells/unused_parameters.rb
reek-3.8.2 lib/reek/smells/unused_parameters.rb
reek-3.8.1 lib/reek/smells/unused_parameters.rb
reek-3.8.0 lib/reek/smells/unused_parameters.rb
reek-3.7.1 lib/reek/smells/unused_parameters.rb
reek-3.7.0 lib/reek/smells/unused_parameters.rb
reek-3.6.1 lib/reek/smells/unused_parameters.rb