Sha256: 948c96eca7baebeb3172d46cec45a0e135a227cd2f7534bf2b9a9c152eebf800
Contents?: true
Size: 1.19 KB
Versions: 30
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require_relative 'base_detector' module Reek module SmellDetectors # # A class that publishes a getter or setter for an instance variable # invites client classes to become too intimate with its inner workings, # and in particular with its representation of state. # # This detector raises a warning for every public +attr_writer+, # +attr_accessor+, and +attr+ with the writable flag set to +true+. # # See {file:docs/Attribute.md} for details. # # TODO: Catch attributes declared "by hand" class Attribute < BaseDetector def self.contexts # :nodoc: [:sym] end # # Checks whether the given class declares any attributes. # # @return [Array<SmellWarning>] # def sniff attributes_in_context.map do |_attribute, line| smell_warning( lines: [line], message: 'is a writable attribute') end end private def attributes_in_context if context.visibility == :public call_node = expression [[call_node.name, call_node.line]] else [] end end end end end
Version data entries
30 entries across 28 versions & 2 rubygems