StyraInc / regal

Regal is a linter for Rego, with the goal of making your Rego magnificent!
https://docs.styra.com/regal
Apache License 2.0
242 stars 32 forks source link

Create aggregate report for 10+ violations #114

Open anderseknert opened 1 year ago

anderseknert commented 1 year ago

Or whatever number makes the most sense. When there are hundreds of violations, it's not a great experience having to scroll over several pages to see them, and even the "compact" view is currently quite dense. It would be nice if we counted the number of violations, and presented an aggregated report grouped by category/rule, and a list of locations.

anderseknert commented 10 months ago

One idea would be to group violations either by rule, or by file. If we currently have an output like this:

Rule:           forbidden-function-call
Description:    Forbidden function call
Category:       custom
Location:       p.rego:4:4
Text:           1 > input.x
Documentation:  https://docs.styra.com/regal/rules/custom/forbidden-function-call

Rule:           forbidden-function-call
Description:    Forbidden function call
Category:       custom
Location:       p.rego:5:4
Text:           1 < input.x
Documentation:  https://docs.styra.com/regal/rules/custom/forbidden-function-call

Rule:           forbidden-function-call
Description:    Forbidden function call
Category:       custom
Location:       p.rego:6:4
Text:           1 >= input.x
Documentation:  https://docs.styra.com/regal/rules/custom/forbidden-function-call

Rule:           forbidden-function-call
Description:    Forbidden function call
Category:       custom
Location:       p.rego:7:4
Text:           1 <= input.x
Documentation:  https://docs.styra.com/regal/rules/custom/forbidden-function-call

We could present it as:

Rule:           forbidden-function-call
Description:    Forbidden function call
Category:       custom
Documentation:  https://docs.styra.com/regal/rules/custom/forbidden-function-call
Locations:      p.rego:4:4        1 > input.x
                p.rego:5:4        1 < input.x
                p.rego:6:4        1 >= input.x
                p.rego:7:4        1 <= input.x

Or something like that. Not sure how we'd best deal with long paths though. Perhaps just one line for the location, and one for the text. It would still save a lot of space compared to listing each violation separately. Maybe listing each location/text separately would be best:

Rule:           forbidden-function-call
Description:    Forbidden function call
Category:       custom
Documentation:  https://docs.styra.com/regal/rules/custom/forbidden-function-call
Location:       p.rego:4:4        
Text:           1 > input.x
Location:       p.rego:5:4        
Text:           1 < input.x
Location:       p.rego:6:4        
Text:           1 >= input.x
Location:       p.rego:7:4
Text:           1 <= input.x
rahulkrishnanfs commented 3 months ago

@anderseknert Could you please assign this to me ?

anderseknert commented 3 months ago

@rahulkrishnanfs done!

rahulkrishnanfs commented 3 months ago

Thanks @anderseknert

anderseknert commented 1 month ago

@rahulkrishnanfs did you find some time to take a look at this? 🙂