YAML Reports

September 12, 2016 ยท View on GitHub

Introduction

Reek's --yaml option writes on $stdout a YAML dump of the smells found. Each reported smell has a number of standard fields and a number of fields that are specific to the smell's type. The common fields are as follows:

FieldTypeValue
sourcestringThe name of the source file containing the smell, or $stdin
linesarrayThe source file line number(s) that contribute to this smell
contextstringThe name of the class, module or method containing the smell
classstringThe class to which this smell belongs
subclassstringThis smell's subclass within the above class
messagestringThe message that would have been printed in a standard Reek report
is_activebooleanfalse if the smell is masked by a config file; true otherwise

All of these fields are grouped into hashes location, smell and status (see the examples below).

Examples

Duplication:

- !ruby/object:Reek::SmellWarning 
  location: 
    source: spec/samples/masked/dirty.rb
    lines: 
    - 5
    - 7
    context: Dirty#a
  smell: 
    class: Duplication
    subclass: DuplicateMethodCall
    occurrences: 2
    call: puts(@s.title)
    message: calls puts(@s.title) twice
  status:
    is_active: true

Nested Iterators:

- !ruby/object:Reek::SmellWarning 
  location: 
    source: spec/samples/masked/dirty.rb
    lines: 
    - 5
    context: Dirty#a
  smell: 
    class: NestedIterators
    subclass: ""
    depth: 2
    message: contains iterators nested 2 deep
  status:
    is_active: true

Uncommunicative Method Name:

- !ruby/object:Reek::SmellWarning 
  location: 
    source: spec/samples/masked/dirty.rb
    lines: 
    - 3
    context: Dirty#a
  smell: 
    class: UncommunicativeName
    subclass: UncommunicativeMethodName
    method_name: a
    message: has the name 'a'
  status:
    is_active: false

Uncommunicative Variable Name:

- !ruby/object:Reek::SmellWarning 
  location: 
    source: spec/samples/masked/dirty.rb
    lines: 
    - 5
    context: Dirty#a
  smell: 
    class: UncommunicativeName
    subclass: UncommunicativeVariableName
    variable_name: x
    message: has the variable name 'x'
  status:
    is_active: true