@@ -283,7 +283,7 @@ func (p *PolicyToLint) checkResultStructure(content, path string, keys []string)
283283func (p * PolicyToLint ) runRegalLinter (filePath , content string ) {
284284 inputModules , err := rules .InputFromText (filePath , content )
285285 if err != nil {
286- p .processRegalViolation (fmt .Errorf ("%s: %w" , filePath , err ), filePath )
286+ p .processRegalViolation (fmt .Sprintf ("%s: %w" , filePath , err ), filePath )
287287 return
288288 }
289289
@@ -307,7 +307,7 @@ func (p *PolicyToLint) runRegalLinter(filePath, content string) {
307307
308308 // Handle Regal violations by formatting
309309 for _ , v := range report .Violations {
310- p .processRegalViolation (fmt .Errorf ("%s:%d: %s" , filePath , v .Location .Row , v .Description ), filePath )
310+ p .processRegalViolation (fmt .Sprintf ("%s:%d: %s" , filePath , v .Location .Row , v .Description ), filePath )
311311 }
312312}
313313
@@ -357,13 +357,11 @@ func (p *PolicyToLint) loadDefaultConfig() (*config.Config, error) {
357357}
358358
359359// Formats regal violation errors
360- func (p * PolicyToLint ) processRegalViolation (rawErr error , path string ) {
361- if rawErr == nil {
360+ func (p * PolicyToLint ) processRegalViolation (errorStr , path string ) {
361+ if errorStr == "" {
362362 return
363363 }
364364
365- errorStr := rawErr .Error ()
366-
367365 // Replace "opa fmt" with "--format" in error messages
368366 errorStr = strings .ReplaceAll (errorStr , "`opa fmt`" , "`--format`" )
369367 // Regex matches file path, line number and error message like: /path/file:line: message
0 commit comments