Skip to content

Commit

Permalink
Merge pull request #251 from opencontrol/errcheck
Browse files Browse the repository at this point in the history
ensure that errors are handled
  • Loading branch information
jcscottiii authored Apr 3, 2017
2 parents a1cd8df + 4ad73aa commit 84402b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 5 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- run:
name: Install Git
command: apk add --no-cache bash git
command: apk add --no-cache bash gcc git musl-dev
- checkout

- run:
Expand All @@ -19,9 +19,13 @@ jobs:
command: |
go get \
github.com/axw/gocov/gocov \
github.com/kisielk/errcheck \
github.com/Masterminds/glide \
github.com/mattn/goveralls \
golang.org/x/tools/cmd/cover
- run:
name: Run tests
command: ./circleci/coverage.sh
- run:
name: Check for unhandled errors
command: errcheck
13 changes: 9 additions & 4 deletions lib/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package lib

import (
"errors"
"github.com/codegangsta/cli"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/lib/result"
"io/ioutil"
"os"
"path/filepath"
"sync"

"github.com/codegangsta/cli"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/lib/result"
)

// localWorkspace struct combines components, standards, and a certification data
Expand Down Expand Up @@ -56,10 +57,14 @@ func LoadData(openControlDir string, certificationPath string) (common.Workspace
certificationErr = ws.LoadCertification(certificationPath)
}(&wg)
wg.Wait()

var errs []error
// errs = append(errs, certificationErr)
if certificationErr != nil {
errs = append(errs, certificationErr)
}
errs = append(errs, componentsErrs...)
errs = append(errs, standardsErrs...)

return ws, errs
}

Expand Down
5 changes: 4 additions & 1 deletion masonry-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,8 @@ func NewCLIApp() *cli.App {

func main() {
app := NewCLIApp()
app.Run(os.Args)
err := app.Run(os.Args)
if err != nil {
log.Fatalln(err)
}
}
6 changes: 3 additions & 3 deletions masonry-go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("Masonry CLI", func() {
})
})
AfterEach(func() {
os.RemoveAll(exportTempDir)
_ = os.RemoveAll(exportTempDir)
})
})

Expand Down Expand Up @@ -115,8 +115,8 @@ func Masonry(args ...string) *Session {
stdin, err := cmd.StdinPipe()
Expect(err).ToNot(HaveOccurred())
buffer := bufio.NewWriter(stdin)
buffer.WriteString(strings.Join(args, " "))
buffer.Flush()
_, _ = buffer.WriteString(strings.Join(args, " "))
_ = buffer.Flush()
session, err := Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
return session
Expand Down

0 comments on commit 84402b6

Please sign in to comment.