Skip to content

Commit 294c665

Browse files
committed
remove error wrapper for violations
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
1 parent 36aca8a commit 294c665

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

  • app/cli/internal/policydevel

app/cli/internal/policydevel/lint.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func (p *PolicyToLint) checkResultStructure(content, path string, keys []string)
283283
func (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

Comments
 (0)