Skip to content

Commit 1b5055e

Browse files
committed
ref(*): clean up most code linter warnings
1 parent b2ce935 commit 1b5055e

23 files changed

Lines changed: 50 additions & 65 deletions

File tree

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ test-style:
9292
# display output, then check
9393
$(GOFMT) $(GO_PACKAGES)
9494
@$(GOFMT) $(GO_PACKAGES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
95-
# FIXME: make this mandatory
96-
-$(GOVET) $(GO_PACKAGES_REPO_PATH)
97-
# FIXME: make this mandatory
95+
$(GOVET) $(GO_PACKAGES_REPO_PATH)
9896
@for i in $(addsuffix /...,$(GO_PACKAGES)); do \
9997
$(GOLINT) $$i; \
10098
done
101-
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) test-style &&) echo done
102-
@$(foreach C, $(CLIENTS), $(MAKE) -C $(C) test-style &&) echo done
99+
@$(foreach C, tests $(CLIENTS) $(COMPONENTS), $(MAKE) -C $(C) test-style &&) echo done

builder/Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include ../includes.mk
44
repo_path = github.com/deis/deis/builder
55

66
GO_FILES = types.go utils.go utils_test.go
7-
GO_PACKAGES = bin
7+
GO_PACKAGES = bin tests
88
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
99

1010
COMPONENT = $(notdir $(repo_path))
@@ -71,10 +71,8 @@ test-style:
7171
# display output, then check
7272
$(GOFMT) $(GO_PACKAGES) $(GO_FILES)
7373
@$(GOFMT) $(GO_PACKAGES) $(GO_FILES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
74-
# FIXME: make this mandatory
75-
-$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
76-
# FIXME: make this mandatory
77-
-$(GOLINT) ./...
74+
$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
75+
$(GOLINT) ./...
7876

7977
cedarish/build:
8078
mkdir -p build

builder/bin/generate-buildhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func main() {
2828
var procfile builder.ProcessType
2929
assert(json.Unmarshal([]byte(os.Args[5]), &procfile))
3030

31-
var dockerfile string = os.Args[6]
31+
var dockerfile = os.Args[6]
3232
if dockerfile == "false" {
3333
dockerfile = ""
3434
}

builder/bin/yaml2json-procfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func main() {
2121
os.Exit(1)
2222
}
2323

24-
procfile, err := builder.YamlToJson(bytes)
24+
procfile, err := builder.YamlToJSON(bytes)
2525

2626
if err != nil {
2727
fmt.Println("the procfile does not contains a valid yaml structure")

builder/utils.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"gopkg.in/yaml.v2"
1010
)
1111

12-
// YamlToJson takes an input yaml string, parses it and returns a string formatted as json.
13-
func YamlToJson(bytes []byte) (string, error) {
12+
// YamlToJSON takes an input yaml string, parses it and returns a string formatted as json.
13+
func YamlToJSON(bytes []byte) (string, error) {
1414
var anomaly map[string]string
1515

1616
if err := yaml.Unmarshal(bytes, &anomaly); err != nil {
@@ -39,6 +39,7 @@ func ParseConfig(res *http.Response) (*Config, error) {
3939
return &config, err
4040
}
4141

42+
// ParseDomain returns the domain field from the bytes of a build hook response.
4243
func ParseDomain(bytes []byte) (string, error) {
4344
var hook BuildHookResponse
4445
if err := json.Unmarshal(bytes, &hook); err != nil {
@@ -56,6 +57,7 @@ func ParseDomain(bytes []byte) (string, error) {
5657
return hook.Domains[0], nil
5758
}
5859

60+
// ParseReleaseVersion returns the version field from the bytes of a build hook response.
5961
func ParseReleaseVersion(bytes []byte) (int, error) {
6062
var hook BuildHookResponse
6163
if err := json.Unmarshal(bytes, &hook); err != nil {
@@ -69,9 +71,10 @@ func ParseReleaseVersion(bytes []byte) (int, error) {
6971
return hook.Release["version"], nil
7072
}
7173

74+
// GetDefaultType returns the default process types given a YAML byte array.
7275
func GetDefaultType(bytes []byte) (string, error) {
7376
type YamlTypeMap struct {
74-
DefaultProcessTypes ProcessType `default_process_types`
77+
DefaultProcessTypes ProcessType `yaml:"default_process_types"`
7578
}
7679

7780
var p YamlTypeMap
@@ -93,6 +96,7 @@ func GetDefaultType(bytes []byte) (string, error) {
9396
return string(retVal), nil
9497
}
9598

99+
// ParseControllerConfig returns configuration key/value pair strings from a config.
96100
func ParseControllerConfig(bytes []byte) ([]string, error) {
97101
var controllerConfig Config
98102
if err := json.Unmarshal(bytes, &controllerConfig); err != nil {

builder/utils_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func stringInSlice(list []string, s string) bool {
2929
return false
3030
}
3131

32-
func TestYamlToJsonGood(t *testing.T) {
32+
func TestYamlToJSONGood(t *testing.T) {
3333
goodProcfiles := [][]byte{
3434
[]byte(`web: while true; do echo hello; sleep 1; done`),
3535

@@ -42,7 +42,7 @@ worker: while true; do echo hello; sleep 1; done`),
4242
goodProcess := "while true; do echo hello; sleep 1; done"
4343

4444
for _, procfile := range goodProcfiles {
45-
data, err := YamlToJson(procfile)
45+
data, err := YamlToJSON(procfile)
4646
if err != nil {
4747
t.Errorf("expected procfile to be valid, got '%v'", err)
4848
}
@@ -169,7 +169,7 @@ func TestParseControllerConfigGood(t *testing.T) {
169169
}
170170

171171
func TestTimeSerialize(t *testing.T) {
172-
time, err := json.Marshal(&dtime.Time{time.Now().UTC()})
172+
time, err := json.Marshal(&dtime.Time{Time: time.Now().UTC()})
173173

174174
if err != nil {
175175
t.Errorf("expected to be able to serialize time as json, got '%v'", err)

cache/Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include ../includes.mk
33
# the filepath to this repository, relative to $GOPATH/src
44
repo_path = github.com/deis/deis/cache
55

6-
GO_PACKAGES = image
6+
GO_PACKAGES = . tests
77
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
88

99
COMPONENT = $(notdir $(repo_path))
@@ -65,10 +65,8 @@ test-style:
6565
# display output, then check
6666
$(GOFMT) $(GO_PACKAGES)
6767
@$(GOFMT) $(GO_PACKAGES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
68-
# FIXME: make this mandatory
69-
-$(GOVET) $(GO_PACKAGES_REPO_PATH)
70-
# FIXME: make this mandatory
71-
-$(GOLINT) ./...
68+
$(GOVET) $(GO_PACKAGES_REPO_PATH)
69+
$(GOLINT) ./...
7270

7371
test-functional:
7472
@docker history deis/test-etcd >/dev/null 2>&1 || docker pull deis/test-etcd:latest

deisctl/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ test-style:
4747
# display output, then check
4848
$(GOFMT) $(GO_PACKAGES) $(GO_FILES)
4949
@$(GOFMT) $(GO_PACKAGES) $(GO_FILES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
50-
# FIXME: make this mandatory
51-
-$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
52-
# FIXME: make this mandatory
53-
-$(GOLINT) ./...
50+
$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
51+
$(GOLINT) ./...
5452

5553
test-unit:
5654
godep go test -v -cover ./...

logger/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ include ../includes.mk
44
repo_path = github.com/deis/deis/logger
55

66
GO_FILES = main.go
7-
GO_PACKAGES = syslog syslogd
7+
GO_PACKAGES = syslog syslogd tests
88
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
9+
GO_TESTABLE_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,syslog syslogd)
910

1011
COMPONENT = $(notdir $(repo_path))
1112
IMAGE = $(IMAGE_PREFIX)$(COMPONENT):$(BUILD_TAG)
@@ -71,13 +72,11 @@ test-style:
7172
# display output, then check
7273
$(GOFMT) $(GO_PACKAGES) $(GO_FILES)
7374
@$(GOFMT) $(GO_PACKAGES) $(GO_FILES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
74-
# FIXME: make this mandatory
75-
-$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
76-
# FIXME: make this mandatory
77-
-$(GOLINT) ./...
75+
$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
76+
$(GOLINT) ./...
7877

7978
test-unit: test-style
80-
$(GOTEST) $(GO_PACKAGES_REPO_PATH)
79+
$(GOTEST) $(GO_TESTABLE_PACKAGES_REPO_PATH)
8180

8281
coverage:
8382
go test -coverprofile coverage.out ./syslog

logspout/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ test-style:
7171
# display output, then check
7272
$(GOFMT) $(GO_PACKAGES) $(GO_FILES)
7373
@$(GOFMT) $(GO_PACKAGES) $(GO_FILES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
74-
# FIXME: make this mandatory
75-
-$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
76-
# FIXME: make this mandatory
77-
-$(GOLINT) ./...
74+
$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
75+
$(GOLINT) ./...
7876

7977
test-unit:
8078
@echo no unit tests

0 commit comments

Comments
 (0)