Class: Pelusa::Lint::DemeterLaw
- Inherits:
-
Object
- Object
- Pelusa::Lint::DemeterLaw
- Defined in:
- lib/pelusa/lint/demeter_law.rb
Instance Method Summary collapse
- #check(klass) ⇒ Object
-
#initialize ⇒ DemeterLaw
constructor
A new instance of DemeterLaw.
Constructor Details
#initialize ⇒ DemeterLaw
4 5 6 |
# File 'lib/pelusa/lint/demeter_law.rb', line 4 def initialize @violations = Set.new end |
Instance Method Details
#check(klass) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pelusa/lint/demeter_law.rb', line 8 def check(klass) initialize iterate_lines!(klass) return SuccessfulAnalysis.new(name) if @violations.empty? FailedAnalysis.new(name, @violations) do |violations| "There are #{violations.length} Demeter law violations in lines #{violations.to_a.join(', ')}." end end |