Skip to content

alphasights/demeter_cop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DemeterCop CircleCI

DemeterCop is a simple tool that let you watch a Ruby object and record which methods and method chains are being called on it.

Usage

class Suspicious
  def action
    ['first', 'second']
  end
end

suspect = Suspicious.new
watched = DemeterCop.watch(suspect) # No need to assign really, as the same object will be returned
suspect == watched # => true

suspect.action.last.length
DemeterCop.report

Will return (pretty formatted):

{
    Suspicious < Object => {
               [ :action ] => {
            :location => "(irb):21:in `irb_binding'"
        },
        [ :action, :last ] => {
            :location => "(irb):21:in `irb_binding'"
        }
    }
}

Where keys (like [:action, :last]) are method chains called on the watched object and values are extra information, for example :location for source file call location.

About

Discover Law of Demeter violations on Ruby objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published