Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
issue #28: simplify repl.NewCoverageExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Jun 25, 2020
1 parent 068de0d commit 978ae9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func NewCoverageCommand(
return printer.PrintCoverage(reporter.Report(metrics))
}
prompt.New(
repl.NewCoverageExecutor(config.Graphite.Prefix, metrics, queries, printer, logger),
repl.NewCoverageExecutor(config.Graphite.Prefix, metrics, reporter, printer, logger),
repl.NewMetricsCompleter(metrics),
).Run()
return nil
Expand Down
11 changes: 3 additions & 8 deletions internal/repl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"github.com/kamilsk/grafaman/internal/filter"
"github.com/kamilsk/grafaman/internal/model"
"github.com/kamilsk/grafaman/internal/provider"
"github.com/kamilsk/grafaman/internal/reporter/coverage"
)

func NewCoverageExecutor(
prefix string,
metrics provider.Metrics,
queries provider.Queries,
reporter interface {
Report(provider.Metrics) model.Report
},
printer interface{ PrintCoverage(model.Report) error },
logger *logrus.Logger,
) func(string) {
Expand All @@ -26,12 +27,6 @@ func NewCoverageExecutor(
}
sort.Sort(metrics)

reporter, err := coverage.New(queries)
if err != nil {
logger.WithError(err).Error("repl: make report")
return
}

if err := printer.PrintCoverage(reporter.Report(metrics)); err != nil {
logger.WithError(err).Error("repl: print coverage report")
return
Expand Down

0 comments on commit 978ae9c

Please sign in to comment.