Class: SpecGuard::RSpec::Linter::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/specguard/rspec/linter.rb

Overview

One annotation's verdict. problem is set when discovery could not produce an intent at all; reasons when the schema rejected one. They are mutually exclusive by construction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:, line:, kind: nil, problem: nil, reasons: []) ⇒ Result

Returns a new instance of Result.



78
79
80
# File 'lib/specguard/rspec/linter.rb', line 78

def initialize(file:, line:, kind: nil, problem: nil, reasons: [])
  super
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



77
78
79
# File 'lib/specguard/rspec/linter.rb', line 77

def file
  @file
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



77
78
79
# File 'lib/specguard/rspec/linter.rb', line 77

def kind
  @kind
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



77
78
79
# File 'lib/specguard/rspec/linter.rb', line 77

def line
  @line
end

#problemObject (readonly)

Returns the value of attribute problem

Returns:

  • (Object)

    the current value of problem



77
78
79
# File 'lib/specguard/rspec/linter.rb', line 77

def problem
  @problem
end

#reasonsObject (readonly)

Returns the value of attribute reasons

Returns:

  • (Object)

    the current value of reasons



77
78
79
# File 'lib/specguard/rspec/linter.rb', line 77

def reasons
  @reasons
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/specguard/rspec/linter.rb', line 86

def failed?
  !ok?
end

#line_scoped?Boolean

A read failure is not line-scoped: nothing in the file was ever seen, and slice 1's line is a 0 sentinel rather than a location. The binary drops the line for exactly these findings (JSONFinding in open-test-intent's cmd/validate-intent/report.go — "line is null where a finding is not line-scoped, kind is null on a passing finding"), and :0 is not somewhere a reader can go: anything parsing file:line — CI annotations, editor quickfix, review comments — would point at a line that does not exist.

This is what makes kind load-bearing rather than decorative.

The rule is a predicate rather than an inline comparison because it now has two renderers: CLI#report_failure prints file instead of file:0, and JSONReporter emits "line": null for the same findings. Spelling kind == Finding::KIND_READ in both would let one of them keep emitting the sentinel after the rule changed here.

Returns:

  • (Boolean)


106
107
108
# File 'lib/specguard/rspec/linter.rb', line 106

def line_scoped?
  kind != Finding::KIND_READ
end

#locationObject



110
111
112
# File 'lib/specguard/rspec/linter.rb', line 110

def location
  line_scoped? ? "#{file}:#{line}" : file
end

#ok?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/specguard/rspec/linter.rb', line 82

def ok?
  problem.nil? && reasons.empty?
end