Class: RuboCop::Cop::RSpecParity::SufficientContexts::Branch

Inherits:
Struct
  • Object
show all
Defined in:
lib/rubocop/cop/rspec_parity/sufficient_contexts.rb

Overview

A single counted branch. ‘kind` is :guard or :regular (preserving the guard fall-through accounting in #branches_from). `label` is the normalized condition/operator source used both for display and for matching `# rspec_parity:covers` annotations. `origin` is nil for the method’s own branches, or the helper method name when inlined from a single-use private method. ‘detail` is an optional semantic qualifier (e.g. “b decides”, “assigns”) applied only when the plain label collides with another branch — see #disambiguate.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#detailObject

Returns the value of attribute detail

Returns:

  • (Object)

    the current value of detail



217
218
219
# File 'lib/rubocop/cop/rspec_parity/sufficient_contexts.rb', line 217

def detail
  @detail
end

#kindObject

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



217
218
219
# File 'lib/rubocop/cop/rspec_parity/sufficient_contexts.rb', line 217

def kind
  @kind
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



217
218
219
# File 'lib/rubocop/cop/rspec_parity/sufficient_contexts.rb', line 217

def label
  @label
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



217
218
219
# File 'lib/rubocop/cop/rspec_parity/sufficient_contexts.rb', line 217

def line
  @line
end

#originObject

Returns the value of attribute origin

Returns:

  • (Object)

    the current value of origin



217
218
219
# File 'lib/rubocop/cop/rspec_parity/sufficient_contexts.rb', line 217

def origin
  @origin
end

Instance Method Details

#annotation_tokenObject

The string an author types after ‘# rspec_parity:covers` to claim this branch. The origin prefix disambiguates identical conditions in different helpers; it is optional when the condition is unique.



221
222
223
# File 'lib/rubocop/cop/rspec_parity/sufficient_contexts.rb', line 221

def annotation_token
  origin ? "#{origin}: #{label}" : label
end