Class: Spoom::Sorbet::Errors::Error
- Inherits:
-
Object
- Object
- Spoom::Sorbet::Errors::Error
- Includes:
- Comparable
- Defined in:
- lib/spoom/sorbet/errors.rb
Instance Attribute Summary collapse
- #code ⇒ Object readonly
- #file ⇒ Object readonly
-
#files_from_error_sections ⇒ Object
readonly
Other files associated with the error.
- #line ⇒ Object readonly
- #message ⇒ Object readonly
- #more ⇒ Object readonly
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
By default errors are sorted by location.
-
#initialize(file, line, message, code, more = []) ⇒ Error
constructor
A new instance of Error.
- #to_junit_xml_element ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file, line, message, code, more = []) ⇒ Error
Returns a new instance of Error.
188 189 190 191 192 193 194 195 |
# File 'lib/spoom/sorbet/errors.rb', line 188 def initialize(file, line, , code, more = []) @file = file @line = line @message = @code = code @more = more @files_from_error_sections = Set.new #: Set[String] end |
Instance Attribute Details
#code ⇒ Object (readonly)
178 179 180 |
# File 'lib/spoom/sorbet/errors.rb', line 178 def code @code end |
#file ⇒ Object (readonly)
175 176 177 |
# File 'lib/spoom/sorbet/errors.rb', line 175 def file @file end |
#files_from_error_sections ⇒ Object (readonly)
Other files associated with the error
185 186 187 |
# File 'lib/spoom/sorbet/errors.rb', line 185 def files_from_error_sections @files_from_error_sections end |
#line ⇒ Object (readonly)
178 179 180 |
# File 'lib/spoom/sorbet/errors.rb', line 178 def line @line end |
#message ⇒ Object (readonly)
175 176 177 |
# File 'lib/spoom/sorbet/errors.rb', line 175 def @message end |
#more ⇒ Object (readonly)
181 182 183 |
# File 'lib/spoom/sorbet/errors.rb', line 181 def more @more end |
Instance Method Details
#<=>(other) ⇒ Object
By default errors are sorted by location
199 200 201 202 203 |
# File 'lib/spoom/sorbet/errors.rb', line 199 def <=>(other) return 0 unless other.is_a?(Error) [file, line, code, ] <=> [other.file, other.line, other.code, other.] end |
#to_junit_xml_element ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/spoom/sorbet/errors.rb', line 211 def to_junit_xml_element testcase_element = REXML::Element.new("testcase") # Unlike traditional test suites, we can't report all tests # regardless of outcome; we only have errors to report. As a # result we reinterpret the definitions of the test properties # bit: the error message becomes the test name and the full error # info gets plugged into the failure body along with file/line # information (displayed in Jenkins as the "Stacktrace" for the # error). testcase_element.add_attributes( "name" => , "file" => file, "line" => line, ) failure_element = testcase_element.add_element("failure") failure_element.add_attributes( "type" => code, ) explanation_text = [ "In file #{file}:\n", *more, ].join.chomp # Use CDATA so that parsers know the whitespace is significant. failure_element.add(REXML::CData.new(explanation_text)) testcase_element end |
#to_s ⇒ Object
206 207 208 |
# File 'lib/spoom/sorbet/errors.rb', line 206 def to_s "#{file}:#{line}: #{} (#{code})" end |