@@ -178,33 +178,61 @@ func parseAndDisplayZizmorOutput(stdout, stderr string, verbose bool) (int, erro
178178 continue
179179 }
180180
181- // Format: π zizmor xx warnings in <filepath>
182- warningText := "warnings"
183- if count == 1 {
184- warningText = "warning"
181+ // Read file content for context display
182+ fileContent , err := os .ReadFile (filePath )
183+ var fileLines []string
184+ if err == nil {
185+ fileLines = strings .Split (string (fileContent ), "\n " )
185186 }
186- fmt .Fprintf (os .Stderr , "π zizmor %d %s in %s\n " , count , warningText , filePath )
187187
188- // Display detailed findings
188+ // Display detailed findings using CompilerError format
189189 for _ , finding := range findings {
190190 severity := finding .Determinations .Severity
191191 ident := finding .Ident
192192 desc := finding .Desc
193193
194194 // Find the primary location (first location in the list)
195- var locationInfo string
196195 if len (finding .Locations ) > 0 {
197196 loc := finding .Locations [0 ]
198197 row := loc .Concrete .Location .StartPoint .Row
199198 col := loc .Concrete .Location .StartPoint .Column
200199 // Zizmor uses 0-based indexing, convert to 1-based for user display
201- if row > 0 || col > 0 {
202- locationInfo = fmt .Sprintf (" at line %d, column %d" , row + 1 , col + 1 )
200+ lineNum := row + 1
201+ colNum := col + 1
202+
203+ // Create context lines around the error
204+ var context []string
205+ if len (fileLines ) > 0 && lineNum > 0 && lineNum <= len (fileLines ) {
206+ startLine := max (1 , lineNum - 2 )
207+ endLine := min (len (fileLines ), lineNum + 2 )
208+
209+ for i := startLine ; i <= endLine ; i ++ {
210+ if i - 1 < len (fileLines ) {
211+ context = append (context , fileLines [i - 1 ])
212+ }
213+ }
214+ }
215+
216+ // Map severity to error type
217+ errorType := "warning"
218+ if severity == "High" || severity == "Critical" {
219+ errorType = "error"
203220 }
204- }
205221
206- errorMsg := fmt .Sprintf (" - [%s] %s%s: %s" , severity , ident , locationInfo , desc )
207- fmt .Fprintln (os .Stderr , console .FormatErrorMessage (errorMsg ))
222+ // Create and format CompilerError
223+ compilerErr := console.CompilerError {
224+ Position : console.ErrorPosition {
225+ File : filePath ,
226+ Line : lineNum ,
227+ Column : colNum ,
228+ },
229+ Type : errorType ,
230+ Message : fmt .Sprintf ("[%s] %s: %s" , severity , ident , desc ),
231+ Context : context ,
232+ }
233+
234+ fmt .Fprint (os .Stderr , console .FormatError (compilerErr ))
235+ }
208236 }
209237 }
210238
0 commit comments