@@ -128,23 +128,18 @@ def _parse_full(cls, output: str) -> Flags:
128128 """
129129 Parse the full formatted GNATcheck output.
130130 """
131- # Prepare the result
132- res = Flags ()
133-
134- # Parse the gnatcheck full output
135- is_parsing = False
136- for line in output .splitlines ():
137- if not is_parsing :
138- is_parsing = "2. Exempted Coding Standard Violations" in line
139- else :
140- search_result = cls .flag_line_pattern .search (line )
141- if search_result is not None :
142- (file , _ , line_num ) = search_result .groups ()
143- res .add_flag (file , int (line_num ))
144- is_parsing = "5. Language violations" not in line
145-
146- # Return the result
147- return res
131+ # Remove useless parts of the full output
132+ try :
133+ output = output [output .index ("2. Exempted Coding Standard Violations" ):]
134+ output = output [:output .index ("5. Language violations" )]
135+
136+ # Then use the "short" parser since we remove the useless part of the
137+ # "full" format.
138+ return cls ._parse_short_and_brief (output )
139+ except ValueError :
140+ # When catching this error, it means that the `index` method failed
141+ # to find required textual bounds.
142+ return {}
148143
149144 @classmethod
150145 def _parse_short_and_brief (cls , output : str ) -> Flags :
@@ -158,7 +153,7 @@ def _parse_short_and_brief(cls, output: str) -> Flags:
158153 for line in output .splitlines ():
159154 search_result = cls .flag_line_pattern .search (line )
160155 if search_result is not None :
161- (file , _ , line_num ) = search_result .groups ()
156+ (file , _ , line_num , _ ) = search_result .groups ()
162157 res .add_flag (file , int (line_num ))
163158
164159 # Return the result
0 commit comments