-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
report when overall threshold present (or) overrides are present #141
Changes from 3 commits
5e8035d
60426fa
aa2be83
1313a75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,11 +74,19 @@ func GenerateCoverageStats(cfg Config) ([]coverage.Stats, error) { | |
} | ||
|
||
func Analyze(cfg Config, current, base []coverage.Stats) AnalyzeResult { | ||
var hasFileOverrides, hasPackageOverrides bool | ||
|
||
thr := cfg.Threshold | ||
overrideRules := compileOverridePathRules(cfg) | ||
|
||
if len(cfg.Override) > 0 { | ||
hasFileOverrides, hasPackageOverrides = detectOverrides(cfg.Override) | ||
} | ||
|
||
return AnalyzeResult{ | ||
Threshold: thr, | ||
HasFileOverrides: hasFileOverrides, | ||
HasPackageOverrides: hasPackageOverrides, | ||
FilesBelowThreshold: checkCoverageStatsBelowThreshold(current, thr.File, overrideRules), | ||
PackagesBelowThreshold: checkCoverageStatsBelowThreshold( | ||
makePackageStats(current), thr.Package, overrideRules, | ||
|
@@ -89,6 +97,27 @@ func Analyze(cfg Config, current, base []coverage.Stats) AnalyzeResult { | |
} | ||
} | ||
|
||
func detectOverrides(overrides []Override) (bool, bool) { | ||
hasFileOverrides := false | ||
hasPackageOverrides := false | ||
|
||
for _, override := range overrides { | ||
if strings.HasSuffix(override.Path, ".go") { | ||
hasFileOverrides = true | ||
} | ||
|
||
if strings.HasPrefix(override.Path, "^") { | ||
hasPackageOverrides = true | ||
} | ||
|
||
if hasFileOverrides && hasPackageOverrides { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't have anything against of merging this |
||
return hasFileOverrides, hasPackageOverrides | ||
} | ||
} | ||
|
||
return hasFileOverrides, hasPackageOverrides | ||
} | ||
|
||
func saveCoverageBreakdown(cfg Config, stats []coverage.Stats) error { | ||
if cfg.BreakdownFileName == "" { | ||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(cfg.Override) > 0 {
seems unnecessary,detectOverrides
should return correct result for any size ofcfg.Override