Skip to content

Commit

Permalink
Add linting and fmt (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
VJftw committed Apr 9, 2021
1 parent f25b9f2 commit 3eda5dd
Show file tree
Hide file tree
Showing 84 changed files with 620 additions and 504 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint
on: [push]
jobs:
build:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Install python dependencies
run: sudo apt-get update && sudo apt-get install -y python3-setuptools python3-pip

- name: Check out code
uses: actions/checkout@v2

- name: Lint
run: ./pleasew lint
6 changes: 6 additions & 0 deletions .plzconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ flag = --context
[alias "dracon"]
cmd = run //scripts/development/kind:dracon --
flag = --pipeline

[alias "lint"]
cmd = run sequential --include lint //scripts/lint/...

[alias "fmt-all"]
cmd = run sequential --include fmt //scripts/fmt/...
2 changes: 1 addition & 1 deletion cmd/dracon/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ go_binary(
},
stamp = True,
static = True,
visibility = ["//scripts/..."],
deps = [
"//cmd/dracon/cmd",
"//third_party/go:spf13_cobra",
],
visibility = ["//scripts/..."],
)
2 changes: 1 addition & 1 deletion cmd/dracon/cmd/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
go_library(
name = "cmd",
srcs = [
"cronjob.go",
"root.go",
"run.go",
"setup.go",
"version.go",
"cronjob.go",
],
visibility = ["PUBLIC"],
deps = [
Expand Down
4 changes: 2 additions & 2 deletions cmd/enricher/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ go_binary(
],
static = True,
deps = [
"//api/proto:v1",
"//pkg/enrichment",
"//pkg/enrichment/db",
"//api/proto:v1",
"//pkg/putil",
"//third_party/go:protobuf",
"//third_party/go:spf13_cobra",
"//third_party/go:spf13_viper",
"//third_party/go:protobuf",
],
)

Expand Down
3 changes: 1 addition & 2 deletions common/jira/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

filegroup(
name = "config_file",
srcs = ["config.yaml"],
visibility = ["PUBLIC"] # public visibility as both producers and consumers need access to this
visibility = ["PUBLIC"], # public visibility as both producers and consumers need access to this
)
6 changes: 3 additions & 3 deletions common/jira/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go_library(
"config.go",
"types.go",
],
visibility = [
"PUBLIC",
],
deps = [
"//third_party/go:yaml.v2",
],
visibility = [
"PUBLIC"
],
)

go_test(
Expand Down
8 changes: 4 additions & 4 deletions common/jira/document/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go_library(
"document.go",
"types.go",
],
deps = [
"//third_party/go:protobuf",
"//api/proto:v1",
],
visibility = [
"PUBLIC",
],
deps = [
"//api/proto:v1",
"//third_party/go:protobuf",
],
)
9 changes: 4 additions & 5 deletions common/jira/jira/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ go_library(
"api.go",
"apiutils.go",
],
visibility = [
"PUBLIC",
],
deps = [
"//common/jira/config",
"//third_party/go:go-jira",
"//third_party/go:tgo",
"//common/jira/config:config",
],
visibility = [
"PUBLIC"
],
)


go_test(
name = "jira_test",
srcs = [
Expand Down
10 changes: 5 additions & 5 deletions common/jira/jira/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ var (
"{code}\n",
Summary: "bar1:baz2 Unit Test Title",
Components: []*jira.Component{
&jira.Component{Name: "c1"},
&jira.Component{Name: "c2"},
&jira.Component{Name: "c3"},
{Name: "c1"},
{Name: "c2"},
{Name: "c3"},
},
AffectsVersions: []*jira.AffectsVersion{
&jira.AffectsVersion{Name: "V1"},
&jira.AffectsVersion{Name: "V2"},
{Name: "V1"},
{Name: "V2"},
},
Labels: []string(nil),
Unknowns: tcontainer.MarshalMap{
Expand Down
2 changes: 1 addition & 1 deletion common/jira/jira/apiutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func makeCustomField(fieldType string, values []string) interface{} {
log.Fatalf("Error parsing float field-type: %v", err)
}
case "simple-value":
return values[0]
return values[0]
default:
log.Printf("Warning: Field type %s is not supported. Edit your config.yaml file, as this field will not be displayed correctly.", fieldType)
return nil
Expand Down
12 changes: 6 additions & 6 deletions common/jira/jira/apiutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func TestSetDefaultFields(t *testing.T) {
Name: "Vulnerability",
},
Components: []*jira.Component{
&jira.Component{Name: "c1"},
&jira.Component{Name: "c2"},
&jira.Component{Name: "c3"},
{Name: "c1"},
{Name: "c2"},
{Name: "c3"},
},
AffectsVersions: []*jira.AffectsVersion{
&jira.AffectsVersion{Name: "V1"},
&jira.AffectsVersion{Name: "V2"},
{Name: "V1"},
{Name: "V2"},
},
Labels: []string(nil),
CustomFields: tcontainer.MarshalMap{
Expand All @@ -50,7 +50,7 @@ func TestMakeCustomField(t *testing.T) {
res3 := makeCustomField("float", []string{"4.22"})
exp3 := 4.22

res4 := makeCustomField("simple-value",[]string{"test-value"})
res4 := makeCustomField("simple-value", []string{"test-value"})
exp4 := "test-value"

assert.EqualValues(t, res1, exp1)
Expand Down
4 changes: 2 additions & 2 deletions consumers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ python_test(
"consumer_test.py",
],
deps = [
"//third_party/python:protobuf",
"//api/proto:v1",
":consumers_base_python",
"//api/proto:v1",
"//third_party/python:protobuf",
],
)

Expand Down
2 changes: 1 addition & 1 deletion consumers/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestLoadToolResponse(t *testing.T) {
assert.Nil(t, err)
defer os.Remove(tmpFile.Name())
issues := []*v1.Issue{
&v1.Issue{
{
Target: "/dracon/source/foobar",
Title: "/dracon/source/barfoo",
Description: "/dracon/source/example.yaml",
Expand Down
8 changes: 4 additions & 4 deletions consumers/defectdojo_c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ python_binary(
main = "defectdojo_c.py",
visibility = ["//security/dracon/..."],
deps = [
"//api/proto:v1",
"//consumers:consumers_base_python",
"//third_party/python:protobuf",
"//third_party/python:defectdojo_api",
"//api/proto:v1",
"//third_party/python:protobuf",
],
)

python_test(
name = "defectdojo_test",
srcs = ["defectdojo_test.py"],
deps = [
"//third_party/python:protobuf",
":defectdojo",
"//api/proto:v1",
"//consumers:consumers_base_python",
":defectdojo",
"//third_party/python:protobuf",
],
)

Expand Down
9 changes: 4 additions & 5 deletions consumers/elasticsearch_c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ go_binary(
],
static = True,
deps = [
"//consumers",
"//api/proto:v1",
"//consumers",
"//third_party/go:elastic_go-elasticsearch_v7",
"//third_party/go:protobuf",
],
Expand All @@ -17,15 +17,14 @@ go_binary(
go_test(
name = "elasticsearch_c_test",
srcs = [
"main.go",
"main_test.go",
"main.go"

],
deps = [
"//consumers",
"//api/proto:v1",
"//third_party/go:gogo_protobuf",
"//consumers",
"//third_party/go:elastic_go-elasticsearch_v7",
"//third_party/go:gogo_protobuf",
"//third_party/go:stretchr_testify",
],
)
Expand Down
2 changes: 1 addition & 1 deletion consumers/elasticsearch_c/main_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
v1 "github.com/thought-machine/dracon/api/proto/v1"
"bytes"
"encoding/json"
v1 "github.com/thought-machine/dracon/api/proto/v1"
"net/http"
"net/http/httptest"
"os"
Expand Down
9 changes: 4 additions & 5 deletions consumers/jira_c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ go_binary(
"main.go",
],
deps = [
"//consumers",
"//common/jira/config:config",
"//consumers/jira_c/utils:utils",
"//common/jira/jira:jira",
"//api/proto:v1",
"//common/jira/config",
"//common/jira/jira",
"//consumers",
"//consumers/jira_c/utils",
"//third_party/go:protobuf",
"//third_party/go:yaml.v2",
],
)


docker_image(
name = "image",
srcs = [
Expand Down
12 changes: 6 additions & 6 deletions consumers/jira_c/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ go_library(
srcs = [
"utils.go",
],
visibility = [
"//consumers/jira_c",
],
deps = [
"//consumers",
"//common/jira/document:document",
"//api/proto:v1",
"//common/jira/document",
"//consumers",
"//third_party/go:protobuf",
],
visibility = [
"//consumers/jira_c:jira_c",
],
)

Expand All @@ -21,8 +21,8 @@ go_test(
],
deps = [
":utils",
"//consumers",
"//api/proto:v1",
"//consumers",
"//third_party/go:gogo_protobuf",
"//third_party/go:protobuf",
"//third_party/go:stretchr_testify",
Expand Down
Loading

0 comments on commit 3eda5dd

Please sign in to comment.