enterprise-contract / ec-cli

Enterprise Contract command line interface
https://enterprisecontract.dev/docs/ec-cli/main/index.html
Apache License 2.0
26 stars 25 forks source link

Fix logic for no matching rule #1627

Closed lcarva closed 2 months ago

lcarva commented 2 months ago

If a source group produces no warnings, failures, or successes, we want to raise an error as that is a no-op and likely indicates a typo in the policy configuration.

This commit fix the check by ensuring the total number of matching rules is computed after the exclude/include from the policy config is applied.

Ref: EC-583

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 72.71%. Comparing base (e72483b) to head (cf489c2). Report is 9 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/graphs/tree.svg?width=650&height=150&src=pr&token=CY5ORXJB33&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract)](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) ```diff @@ Coverage Diff @@ ## main #1627 +/- ## ========================================== - Coverage 80.79% 72.71% -8.08% ========================================== Files 65 72 +7 Lines 4738 4996 +258 ========================================== - Hits 3828 3633 -195 - Misses 910 1363 +453 ``` | [Flag](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | Coverage Δ | | |---|---|---| | [acceptance](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `72.71% <100.00%> (?)` | | | [generative](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `?` | | | [integration](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `?` | | | [unit](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | Coverage Δ | | |---|---|---| | [internal/evaluator/conftest\_evaluator.go](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627?src=pr&el=tree&filepath=internal%2Fevaluator%2Fconftest_evaluator.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#diff-aW50ZXJuYWwvZXZhbHVhdG9yL2NvbmZ0ZXN0X2V2YWx1YXRvci5nbw==) | `77.91% <100.00%> (-6.25%)` | :arrow_down: | ... and [69 files with indirect coverage changes](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1627/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract)
lcarva commented 2 months ago

Had to update one of the acceptance tests after all since it was actually relying on the bug to succeed.