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
: Integer?.
-
#file ⇒ Object
readonly
: String?.
-
#files_from_error_sections ⇒ Object
readonly
Other files associated with the error : Set.
-
#line ⇒ Object
readonly
: Integer?.
-
#message ⇒ Object
readonly
: String?.
-
#more ⇒ Object
readonly
: Array.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
By default errors are sorted by location : (untyped other) -> Integer.
-
#initialize(file, line, message, code, more = []) ⇒ Error
constructor
: (String? file, Integer? line, String? message, Integer? code, ?Array more) -> void.
-
#to_junit_xml_element ⇒ Object
: -> REXML::Element.
-
#to_s ⇒ Object
: -> String.
Constructor Details
#initialize(file, line, message, code, more = []) ⇒ Error
: (String? file, Integer? line, String? message, Integer? code, ?Array more) -> void
166 167 168 169 170 171 172 173 |
# File 'lib/spoom/sorbet/errors.rb', line 166 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)
: Integer?
156 157 158 |
# File 'lib/spoom/sorbet/errors.rb', line 156 def code @code end |
#file ⇒ Object (readonly)
: String?
153 154 155 |
# File 'lib/spoom/sorbet/errors.rb', line 153 def file @file end |
#files_from_error_sections ⇒ Object (readonly)
Other files associated with the error : Set
163 164 165 |
# File 'lib/spoom/sorbet/errors.rb', line 163 def files_from_error_sections @files_from_error_sections end |
#line ⇒ Object (readonly)
: Integer?
156 157 158 |
# File 'lib/spoom/sorbet/errors.rb', line 156 def line @line end |
#message ⇒ Object (readonly)
: String?
153 154 155 |
# File 'lib/spoom/sorbet/errors.rb', line 153 def @message end |
#more ⇒ Object (readonly)
: Array
159 160 161 |
# File 'lib/spoom/sorbet/errors.rb', line 159 def more @more end |
Instance Method Details
#<=>(other) ⇒ Object
By default errors are sorted by location : (untyped other) -> Integer
177 178 179 180 181 |
# File 'lib/spoom/sorbet/errors.rb', line 177 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
: -> REXML::Element
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/spoom/sorbet/errors.rb', line 189 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
: -> String
184 185 186 |
# File 'lib/spoom/sorbet/errors.rb', line 184 def to_s "#{file}:#{line}: #{} (#{code})" end |