# frozen_string_literal: true require_relative 'base_detector' module Reek module SmellDetectors # # Classes should use their private methods. Otherwise this is dead # code which is confusing and bad for maintenance. # # See {file:docs/Unused-Private-Method.md} for details. # class UnusedPrivateMethod < BaseDetector def self.default_config super.merge(SmellConfiguration::ENABLED_KEY => false) end # Class for storing `hits` which are unused private methods # we found in the given context. `name` and `line` are then used to # construct SmellWarnings. class Hit attr_reader :name, :line def initialize(context) @name = context.name @line = context.exp.line end end def self.contexts [:class] end # # @return [Array] # def sniff hits.map do |hit| name = hit.name smell_warning( context: context, lines: [hit.line], message: "has the unused private instance method '#{name}'", parameters: { name: name.to_s }) end end private # # @return [Array] # def hits unused_private_methods.map do |defined_method| Hit.new(defined_method) unless ignore_method?(defined_method) end.compact end # # @return [Array