Skip to content

Commit

Permalink
Go Vet, Go Fmt, and Golint
Browse files Browse the repository at this point in the history
  • Loading branch information
James C. Scott committed Oct 3, 2016
1 parent 9cbd029 commit 5a1890f
Show file tree
Hide file tree
Showing 33 changed files with 80 additions and 85 deletions.
4 changes: 2 additions & 2 deletions commands/diff/inventory.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package diff

import (
"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/tools/certifications"
"fmt"
"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/tools/certifications"
)

// Inventory maintains the inventory of all the controls within a given workspace.
Expand Down
2 changes: 1 addition & 1 deletion commands/diff/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package diff_test
import (
. "github.com/opencontrol/compliance-masonry/commands/diff"

"errors"
. "github.com/onsi/ginkgo"
"github.com/stretchr/testify/assert"
"os"
"path/filepath"
"errors"
)

var _ = Describe("Inventory", func() {
Expand Down
1 change: 1 addition & 0 deletions commands/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/opencontrol/compliance-masonry/tools/certifications"
)

// MakeGitbook is the wrapper function that will create a gitbook for the specified certification.
func MakeGitbook(config gitbook.Config) (string, []error) {
warning := ""
certificationPath, err := certifications.GetCertification(config.OpencontrolDir, config.Certification)
Expand Down
2 changes: 1 addition & 1 deletion commands/docs/gitbook/gitbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"

"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/tools/fs"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/tools/fs"
)

// Config contains data for gitbook export configurations
Expand Down
3 changes: 1 addition & 2 deletions commands/docs/gitbook/gitbookCertification.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (openControl *OpenControlGitBook) getParameters(text string, parameters []c
return text
}

func (openControl *OpenControlGitBook) getParameter(text string, parameter common.Section) string{
func (openControl *OpenControlGitBook) getParameter(text string, parameter common.Section) string {
text = fmt.Sprintf("%s\n###### %s\n", text, parameter.GetKey())
text = fmt.Sprintf("%s%s\n", text, parameter.GetText())
return text
Expand Down Expand Up @@ -85,7 +85,6 @@ func (openControl *OpenControlGitBook) getControlOrigin(text string, controlOrig
return text
}


func (openControl *OpenControlGitBook) exportControl(control *ControlGitbook) (string, string) {
key := replaceParentheses(fmt.Sprintf("%s-%s", control.standardKey, control.controlKey))
text := fmt.Sprintf("#%s\n##%s\n", key, control.GetName())
Expand Down
4 changes: 2 additions & 2 deletions commands/docs/gitbook/gitbookComponents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package gitbook
import (
"testing"

v2 "github.com/opencontrol/compliance-masonry/lib/components/versions/2_0_0"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/blang/semver"
"github.com/opencontrol/compliance-masonry/lib/common"
v2 "github.com/opencontrol/compliance-masonry/lib/components/versions/2_0_0"
)

type componentExportTest struct {
Expand Down
2 changes: 1 addition & 1 deletion commands/get/get.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package get

import (
"github.com/opencontrol/compliance-masonry/commands/get/resources"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/lib/opencontrol"
"github.com/opencontrol/compliance-masonry/commands/get/resources"
)

// Get will retrieve all of the resources for the schemas and the resources for all the dependent schemas.
Expand Down
4 changes: 2 additions & 2 deletions commands/get/resources/mocks/Getter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package mocks

import (
"github.com/stretchr/testify/mock"
"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/stretchr/testify/mock"
)

// Getter is an autogenerated mock type for the Getter type
Expand Down
2 changes: 1 addition & 1 deletion lib/certifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func (ws *LocalWorkspace) LoadCertification(certificationFile string) error {
}
ws.Certification = cert
return nil
}
}
2 changes: 1 addition & 1 deletion lib/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ var (
ErrCertificationSchema = errors.New("Unable to parse certification")
// ErrStandardSchema is raised a standard cannot be parsed
ErrStandardSchema = errors.New("Unable to parse standard")
)
)
8 changes: 4 additions & 4 deletions lib/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package lib
import (
"sync"

"github.com/opencontrol/compliance-masonry/lib/components"
"github.com/opencontrol/compliance-masonry/lib/common"
"fmt"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/lib/components"
)

// componentsMap struct is a thread-safe structure mapping for components
Expand Down Expand Up @@ -39,7 +39,7 @@ func (components *componentsMap) Get(key string) common.Component {
func (components *componentsMap) CompareAndAdd(component common.Component) bool {
components.Lock()
defer components.Unlock()
_, exists := components.mapping[component.GetKey()];
_, exists := components.mapping[component.GetKey()]
if !exists {
components.mapping[component.GetKey()] = component
return true
Expand Down Expand Up @@ -74,4 +74,4 @@ func (ws *LocalWorkspace) LoadComponent(componentDir string) error {
return fmt.Errorf("Component: %s exists!\n", component.GetKey())
}
return nil
}
}
8 changes: 3 additions & 5 deletions lib/components/component.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package components

import (
"github.com/blang/semver"
"errors"
"fmt"
"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/blang/semver"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/opencontrol/compliance-masonry/tools/fs"
"path/filepath"
)
Expand All @@ -27,7 +27,7 @@ func Load(path string) (common.Component, error) {
}
// Parse the component.
var component common.Component
component, err = parseComponent(componentData,fileName)
component, err = parseComponent(componentData, fileName)
if err != nil {
return nil, err
}
Expand All @@ -38,8 +38,6 @@ func Load(path string) (common.Component, error) {
return component, nil
}



// BaseComponentParseError is the type of error that will be returned if the parsing failed for ONLY the `Base` struct.
type BaseComponentParseError struct {
message string
Expand Down
3 changes: 1 addition & 2 deletions lib/components/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package components

import "testing"


type keyTest struct {
input string
expected string
Expand All @@ -25,4 +24,4 @@ func TestGetKey(t *testing.T) {
t.Errorf("Expected: `%s`, Actual: `%s`", example.expected, actual)
}
}
}
}
6 changes: 3 additions & 3 deletions lib/components_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package lib

import (
"testing"
"github.com/opencontrol/compliance-masonry/lib/common/mocks"
"github.com/opencontrol/compliance-masonry/lib/result"
"github.com/stretchr/testify/assert"
"path/filepath"
"github.com/opencontrol/compliance-masonry/lib/result"
"testing"
)

func TestAddComponent(t *testing.T) {
Expand Down Expand Up @@ -60,4 +60,4 @@ func TestBadLoadComponent(t *testing.T) {
err := ws.LoadComponent("fake.file")
// Should return an error because it can't load the file.
assert.Equal(t, "Component files does not exist", err.Error())
}
}
3 changes: 1 addition & 2 deletions lib/opencontrol/mocks/SchemaParser.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package mocks


import (
"github.com/stretchr/testify/mock"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/stretchr/testify/mock"
)

// SchemaParser is an autogenerated mock type for the SchemaParser type
Expand Down
2 changes: 1 addition & 1 deletion lib/opencontrol/opencontrol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

var _ = Describe("Base", func() {

Describe("Retrieving the schema version", func(){
Describe("Retrieving the schema version", func() {
table.DescribeTable("GetSchemaVersion", func(b Base, expectedVersion string) {
assert.Equal(GinkgoT(), b.GetSchemaVersion(), expectedVersion)
},
Expand Down
5 changes: 2 additions & 3 deletions lib/opencontrol/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"errors"
"github.com/blang/semver"
"github.com/opencontrol/compliance-masonry/lib/common"
"gopkg.in/yaml.v2"
v1_0_0 "github.com/opencontrol/compliance-masonry/lib/opencontrol/versions/1.0.0"

"gopkg.in/yaml.v2"
)

var (
// SchemaV1_0_0 is the semantic versioning representation in object form for version 1.0.0
SchemaV1_0_0 = semver.Version{1, 0, 0, nil, nil}
SchemaV1_0_0 = semver.Version{Major: 1, Minor: 0, Patch: 0, Pre: nil, Build: nil}
)

const (
Expand Down
17 changes: 8 additions & 9 deletions lib/opencontrol/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
. "github.com/opencontrol/compliance-masonry/lib/opencontrol"

. "github.com/onsi/ginkgo"
"github.com/stretchr/testify/assert"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/lib/opencontrol/mocks"
"github.com/opencontrol/compliance-masonry/lib/opencontrol/versions/1.0.0"
"github.com/stretchr/testify/assert"
)

var _ = Describe("Parse", func() {
var (
parser SchemaParser
err error
parser SchemaParser
err error
openControl common.OpenControl
)

Expand Down Expand Up @@ -52,10 +52,9 @@ var _ = Describe("Parse", func() {
})
})


var _ = Describe("Parsing the scchema", func() {
Describe("Parsing v1.0.0", func() {
data := []byte (`
data := []byte(`
schema_version: "1.0.0"
name: test
metadata:
Expand Down Expand Up @@ -88,9 +87,9 @@ dependencies:
assert.Equal(GinkgoT(), []string{"./cert-1.yaml"}, opencontrol.GetCertifications())
assert.Equal(GinkgoT(), []string{"./standard-1.yaml"}, opencontrol.GetStandards())
assert.Equal(GinkgoT(), []string{"./component-1", "./component-2", "./component-3"}, opencontrol.GetComponents())
assert.Equal(GinkgoT(), []common.RemoteSource{schema.VCSEntry{URL:"github.com/18F/NIST-800-53", Revision:"master", Path:""}}, opencontrol.GetStandardsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{schema.VCSEntry{URL:"github.com/18F/cg-complinace", Revision:"master", Path:""}}, opencontrol.GetComponentsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{schema.VCSEntry{URL:"github.com/18F/LATO", Revision:"master", Path:""}}, opencontrol.GetCertificationsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{schema.VCSEntry{URL: "github.com/18F/NIST-800-53", Revision: "master", Path: ""}}, opencontrol.GetStandardsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{schema.VCSEntry{URL: "github.com/18F/cg-complinace", Revision: "master", Path: ""}}, opencontrol.GetComponentsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{schema.VCSEntry{URL: "github.com/18F/LATO", Revision: "master", Path: ""}}, opencontrol.GetCertificationsDependencies())

})
})
Expand Down Expand Up @@ -124,4 +123,4 @@ dependencies:
assert.Nil(GinkgoT(), opencontrol)
})
})
})
})
2 changes: 1 addition & 1 deletion lib/opencontrol/versions/1.0.0/opencontrol.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package schema

import (
"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/tools/constants"
)

const (
Expand Down
13 changes: 6 additions & 7 deletions lib/opencontrol/versions/1.0.0/opencontrol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
. "github.com/onsi/ginkgo/extensions/table"
"github.com/stretchr/testify/assert"

"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/tools/constants"
)

var _ = Describe("Opencontrol", func() {
Describe("Getter functions for v1.0.0", func() {
opencontrol := OpenControl{
Name: "test",
Name: "test",
Meta: Metadata{
Description: "A system to test parsing",
Maintainers: []string{
Expand Down Expand Up @@ -54,14 +54,13 @@ var _ = Describe("Opencontrol", func() {
assert.Equal(GinkgoT(), []string{"./cert-1.yaml"}, opencontrol.GetCertifications())
assert.Equal(GinkgoT(), []string{"./standard-1.yaml"}, opencontrol.GetStandards())
assert.Equal(GinkgoT(), []string{"./component-1", "./component-2", "./component-3"}, opencontrol.GetComponents())
assert.Equal(GinkgoT(), []common.RemoteSource{VCSEntry{URL:"github.com/18F/NIST-800-53", Revision:"master", Path:""}}, opencontrol.GetStandardsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{VCSEntry{URL:"github.com/18F/cg-complinace", Revision:"master", Path:""}}, opencontrol.GetComponentsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{VCSEntry{URL:"github.com/18F/LATO", Revision:"master", Path:""}}, opencontrol.GetCertificationsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{VCSEntry{URL: "github.com/18F/NIST-800-53", Revision: "master", Path: ""}}, opencontrol.GetStandardsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{VCSEntry{URL: "github.com/18F/cg-complinace", Revision: "master", Path: ""}}, opencontrol.GetComponentsDependencies())
assert.Equal(GinkgoT(), []common.RemoteSource{VCSEntry{URL: "github.com/18F/LATO", Revision: "master", Path: ""}}, opencontrol.GetCertificationsDependencies())
})

})


var _ = Describe("VCSEntry", func() {
Describe("Retrieving the config file", func() {
DescribeTable("GetConfigFile", func(e VCSEntry, expectedPath string) {
Expand All @@ -79,4 +78,4 @@ var _ = Describe("VCSEntry", func() {
e := VCSEntry{URL: "testurl"}
assert.Equal(GinkgoT(), "testurl", e.GetURL())
})
})
})
2 changes: 1 addition & 1 deletion lib/result/justifications.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package result

import (
"sync"
"github.com/opencontrol/compliance-masonry/lib/common"
"sync"
)

// Verification struct holds data for a specific component and verification
Expand Down
4 changes: 2 additions & 2 deletions lib/standards/standard.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package standards

import (
"io/ioutil"
"github.com/opencontrol/compliance-masonry/lib/common"
v1_0_0 "github.com/opencontrol/compliance-masonry/lib/standards/versions/1_0_0"
"gopkg.in/yaml.v2"
"io/ioutil"
)

// Load will read the file at the given path and attempt to return a standard object.
Expand All @@ -19,4 +19,4 @@ func Load(path string) (common.Standard, error) {
return nil, common.ErrStandardSchema
}
return standard, nil
}
}

0 comments on commit 5a1890f

Please sign in to comment.