Skip to content

None of the error returned by reporters are checked #134

@ccoVeille

Description

@ccoVeille

In pkg/cli/cli.go there is a section where none of the reporter.Print* method that could return errors are checked

if _, ok := c.Reporter.(reporter.JsonReporter); ok {
reporter.PrintSingleGroupJson(reportGroup)
} else if !Quiet {
reporter.PrintSingleGroupStdout(reportGroup)
}
} else if len(GroupOutput) == 2 {
reportGroup, err := GroupByDouble(reports, GroupOutput)
if err != nil {
return 1, fmt.Errorf("unable to group by double value: %v", err)
}
if _, ok := c.Reporter.(reporter.JsonReporter); ok {
reporter.PrintDoubleGroupJson(reportGroup)
} else if !Quiet {
reporter.PrintDoubleGroupStdout(reportGroup)
}
} else if len(GroupOutput) == 3 {
reportGroup, err := GroupByTriple(reports, GroupOutput)
if err != nil {
return 1, fmt.Errorf("unable to group by triple value: %v", err)
}
if _, ok := c.Reporter.(reporter.JsonReporter); ok {
reporter.PrintTripleGroupJson(reportGroup)
} else if !Quiet {
reporter.PrintTripleGroupStdout(reportGroup)
}

This code requires a bit of refactoring, I think.

The addition of quiet mode (great addition BTW) with #124 made it even more complex to read and maintain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    has-prThis issue has an associated PRvalidator-coreIssues that relate to the core validator functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions