chore: enable more linters (#241)

Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
This commit is contained in:
Teppei Fukuda 2023-09-20 09:23:39 +03:00 committed by GitHub
parent 09c1d4dd53
commit 6e704239a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 116 additions and 53 deletions

View File

@ -6,22 +6,21 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Lint - name: Lint
uses: golangci/golangci-lint-action@v3.7.0 uses: golangci/golangci-lint-action@v3.7.0
with: with:
version: v1.45 version: v1.54
args : --verbose args : --verbose
- name: Test - name: Test
run: | run: |
go test -v ./... make test

View File

@ -4,11 +4,35 @@ run:
linters: linters:
enable: enable:
- gofmt - gofmt
disable: - bodyclose
- errcheck - staticcheck
- unused
- gci
- gomodguard
- tenv
- gosimple - gosimple
- govet - govet
disable:
- errcheck
- ineffassign - ineffassign
- staticcheck
- structcheck - structcheck
- unused linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/aquasecurity/)
- blank
- dot
gomodguard:
blocked:
modules:
- github.com/hashicorp/go-version:
recommendations:
- github.com/aquasecurity/go-version
reason: "`aquasecurity/go-version` is degisned for our use-cases"
- github.com/Masterminds/semver:
recommendations:
- github.com/aquasecurity/go-version
reason: "`aquasecurity/go-version` is degisned for our use-cases"

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
export SHELL := /bin/bash
export SHELLOPTS := errexit
GOPATH ?= $(shell go env GOPATH)
BIN_DIR := $(GOPATH)/bin
GOLANGCI_LINT := $(BIN_DIR)/golangci-lint
.PHONY: lint lintfix test build
$(GOLANGCI_LINT):
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) v1.54.2
lint: $(GOLANGCI_LINT)
@$(GOLANGCI_LINT) run
lintfix: $(GOLANGCI_LINT)
@$(GOLANGCI_LINT) run --fix
test:
go test -race ./...
build:
go build -o vuln-list-update .

View File

@ -10,9 +10,10 @@ import (
"strings" "strings"
"time" "time"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb/v3" "github.com/cheggaaa/pb/v3"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
const ( const (

View File

@ -8,10 +8,11 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/alma"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/alma"
) )
func TestUpdate(t *testing.T) { func TestUpdate(t *testing.T) {

View File

@ -6,14 +6,16 @@ import (
"compress/gzip" "compress/gzip"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"github.com/aquasecurity/vuln-list-update/utils"
"golang.org/x/xerrors"
"gopkg.in/cheggaaa/pb.v1"
"log" "log"
"net/url" "net/url"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"golang.org/x/xerrors"
"gopkg.in/cheggaaa/pb.v1"
"github.com/aquasecurity/vuln-list-update/utils"
) )
const ( const (

View File

@ -10,10 +10,10 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/assert"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/amazon" "github.com/aquasecurity/vuln-list-update/amazon"
"github.com/stretchr/testify/assert"
) )
func TestConfig_Update(t *testing.T) { func TestConfig_Update(t *testing.T) {

View File

@ -7,10 +7,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb/v3" "github.com/cheggaaa/pb/v3"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
const ( const (

View File

@ -1,7 +1,6 @@
package arch_test package arch_test
import ( import (
"github.com/aquasecurity/vuln-list-update/arch"
"io" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -11,6 +10,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/arch"
) )
func TestUpdate(t *testing.T) { func TestUpdate(t *testing.T) {

View File

@ -9,10 +9,11 @@ import (
"os" "os"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/chainguard"
"github.com/spf13/afero" "github.com/spf13/afero"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/chainguard"
) )
var update = flag.Bool("update", false, "update golden files") var update = flag.Bool("update", false, "update golden files")

View File

@ -11,8 +11,9 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/aquasecurity/vuln-list-update/utils"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
type CWEConfig struct { type CWEConfig struct {

View File

@ -9,9 +9,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
func TestUpdate(t *testing.T) { func TestUpdate(t *testing.T) {

View File

@ -10,12 +10,13 @@ import (
"strings" "strings"
"time" "time"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb" "github.com/cheggaaa/pb"
githubql "github.com/shurcooL/githubv4" githubql "github.com/shurcooL/githubv4"
"github.com/shurcooL/graphql" "github.com/shurcooL/graphql"
"github.com/spf13/afero" "github.com/spf13/afero"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
// https://developer.github.com/v4/enum/securityadvisoryecosystem/ // https://developer.github.com/v4/enum/securityadvisoryecosystem/

View File

@ -7,8 +7,9 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/aquasecurity/vuln-list-update/utils"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
type Operations interface { type Operations interface {

View File

@ -2,11 +2,13 @@ package kevc
import ( import (
"encoding/json" "encoding/json"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb"
"golang.org/x/xerrors"
"log" "log"
"path/filepath" "path/filepath"
"github.com/cheggaaa/pb"
"golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
const ( const (

View File

@ -1,14 +1,16 @@
package kevc_test package kevc_test
import ( import (
"github.com/aquasecurity/vuln-list-update/kevc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/kevc"
) )
func TestUpdate(t *testing.T) { func TestUpdate(t *testing.T) {

View File

@ -11,10 +11,11 @@ import (
"strings" "strings"
"time" "time"
"github.com/aquasecurity/vuln-list-update/utils"
jsonpointer "github.com/mattn/go-jsonpointer" jsonpointer "github.com/mattn/go-jsonpointer"
"golang.org/x/xerrors" "golang.org/x/xerrors"
pb "gopkg.in/cheggaaa/pb.v1" pb "gopkg.in/cheggaaa/pb.v1"
"github.com/aquasecurity/vuln-list-update/utils"
) )
type NVD struct { type NVD struct {

View File

@ -9,10 +9,11 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/spf13/afero" "github.com/spf13/afero"
"golang.org/x/xerrors" "golang.org/x/xerrors"
pb "gopkg.in/cheggaaa/pb.v1" pb "gopkg.in/cheggaaa/pb.v1"
"github.com/aquasecurity/vuln-list-update/utils"
) )
var ( var (

View File

@ -8,10 +8,10 @@ import (
"os" "os"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/oracle/oval" "github.com/spf13/afero"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/spf13/afero" "github.com/aquasecurity/vuln-list-update/oracle/oval"
) )
var update = flag.Bool("update", false, "update golden files") var update = flag.Bool("update", false, "update golden files")

View File

@ -5,10 +5,11 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/oracle/oval"
"github.com/kylelemons/godebug/pretty" "github.com/kylelemons/godebug/pretty"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/oracle/oval"
) )
func TestRedhatCVEJSON_UnmarshalJSON(t *testing.T) { func TestRedhatCVEJSON_UnmarshalJSON(t *testing.T) {

View File

@ -8,9 +8,10 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/osv"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/osv"
) )
func Test_Update(t *testing.T) { func Test_Update(t *testing.T) {

View File

@ -7,10 +7,11 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb" "github.com/cheggaaa/pb"
"github.com/spf13/afero" "github.com/spf13/afero"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
const ( const (

View File

@ -10,10 +10,9 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/spf13/afero"
) )
var update = flag.Bool("update", false, "update golden files") var update = flag.Bool("update", false, "update golden files")

View File

@ -6,8 +6,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/redhat/securitydataapi"
"github.com/kylelemons/godebug/pretty" "github.com/kylelemons/godebug/pretty"
"github.com/aquasecurity/vuln-list-update/redhat/securitydataapi"
) )
func TestRedhatCVEJSON_UnmarshalJSON(t *testing.T) { func TestRedhatCVEJSON_UnmarshalJSON(t *testing.T) {

View File

@ -15,9 +15,10 @@ import (
"strings" "strings"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb/v3" "github.com/cheggaaa/pb/v3"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
const ( const (

View File

@ -7,9 +7,10 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/rocky"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/rocky"
) )
func Test_Update(t *testing.T) { func Test_Update(t *testing.T) {

View File

@ -11,10 +11,11 @@ import (
"strings" "strings"
"unicode/utf8" "unicode/utf8"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb" "github.com/cheggaaa/pb"
"github.com/spf13/afero" "github.com/spf13/afero"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
) )
var ( var (

View File

@ -8,11 +8,10 @@ import (
"os" "os"
"testing" "testing"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/spf13/afero"
"github.com/aquasecurity/vuln-list-update/suse/cvrf" "github.com/aquasecurity/vuln-list-update/suse/cvrf"
) )

View File

@ -9,12 +9,10 @@ import (
"strings" "strings"
"time" "time"
"github.com/aquasecurity/vuln-list-update/git"
"github.com/araddon/dateparse" "github.com/araddon/dateparse"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/git"
"github.com/aquasecurity/vuln-list-update/utils" "github.com/aquasecurity/vuln-list-update/utils"
) )

View File

@ -6,7 +6,6 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -9,10 +9,11 @@ import (
"os" "os"
"testing" "testing"
"github.com/aquasecurity/vuln-list-update/wolfi"
"github.com/spf13/afero" "github.com/spf13/afero"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/aquasecurity/vuln-list-update/wolfi"
) )
var update = flag.Bool("update", false, "update golden files") var update = flag.Bool("update", false, "update golden files")