Skip to content

regal lint hint displays incorrect number of fixable violations #1813

@gusega

Description

@gusega

I run the following command:

regal \
lint \
--disable-all \
--enable use-rego-v1 \
--enable use-assignment-operator \
--enable no-whitespace-comment \
--enable directory-package-mismatch \
--enable non-raw-regex-pattern \
mypolicies_folder

Acutal result

Rule:           directory-package-mismatch                                                                                                                                                           
Description:    Directory structure should mirror package                                                                                                                                            
Category:       idiomatic                                                                                                                                                                            
Location:       policy1.rego:1:9        
Text:           package touchpoint.servicestatusoverridebreaktheglass                                                                                                                                
Documentation:  https://www.openpolicyagent.org/projects/regal/rules/idiomatic/directory-package-mismatch                                                                                            
                                                                                                                                                                                                     
Rule:           non-raw-regex-pattern                                                                                                                                                                
Description:    Use raw strings for regex patterns                                                                                                                                                   
Category:       idiomatic                                                                                                                                                                            
Location:       policy1.rego:70:14      
Text:           regex.match("\\s", input.request.metadata.name)                                                                                                                                      
Documentation:  https://www.openpolicyagent.org/projects/regal/rules/idiomatic/non-raw-regex-pattern                                                                                                 
                                                                                                                                                                                                     
Rule:           directory-package-mismatch                                                                                                                                                           
Description:    Directory structure should mirror package                                                                                                                                            
Category:       idiomatic                                                                                                                                                                            
Location:       policy1_test.rego:1:9   
Text:           package touchpoint.servicestatusoverridebreaktheglass.test                                                                                                                           
Documentation:  https://www.openpolicyagent.org/projects/regal/rules/idiomatic/directory-package-mismatch               

                                                                                                                                                                                                     
Rule:           no-whitespace-comment                                                                                                                                                                
Description:    Comment should start with whitespace                                                                                                                                                 
Category:       style                                                                                                                                                                                
Location:       policy1_test.rego:257:1 
Text:           #opa test -f pretty -r data.touchpoint.servicestatusoverridebreaktheglass -b . -v                                                                                                    
Documentation:  https://www.openpolicyagent.org/projects/regal/rules/style/no-whitespace-comment                                                                                                     
                                                                                                                                                                                                     
Rule:           no-whitespace-comment                                                                                                                                                                
Description:    Comment should start with whitespace                                                                                                                                                 
Category:       style                                                                                                                                                                                
Location:       policy_2_test.rego:822:1   
Text:           #opa test -f pretty -r data.touchpoint.servicestatusoverride -b . -v                                                                                                                 
Documentation:  https://www.openpolicyagent.org/projects/regal/rules/style/no-whitespace-comment                                                                                                     

581 files linted. 5 violations found in 3 files.

Hint: 3/5 violations can be automatically fixed (directory-package-mismatch, no-whitespace-comment, non-raw-regex-pattern)
      Run regal fix --help for more details.

Expected result

...
Hint: 5/5 violations can be fixed automatically (directory-package-mismatch, no-whitespace-comment, non-raw-regex-pattern)
...

Additional info
I suppose the hint displays the number of fixable rules as the first number and the total number of violations as the second number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions