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
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
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Lint
uses: golangci/golangci-lint-action@v3.7.0
with:
version: v1.45
version: v1.54
args : --verbose
- name: Test
run: |
go test -v ./...
make test

View File

@ -4,11 +4,35 @@ run:
linters:
enable:
- gofmt
disable:
- errcheck
- bodyclose
- staticcheck
- unused
- gci
- gomodguard
- tenv
- gosimple
- govet
disable:
- errcheck
- ineffassign
- staticcheck
- 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"
"time"
"github.com/aquasecurity/vuln-list-update/utils"
"github.com/cheggaaa/pb/v3"
"golang.org/x/xerrors"
"github.com/aquasecurity/vuln-list-update/utils"
)
const (

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,10 +8,10 @@ import (
"os"
"testing"
"github.com/aquasecurity/vuln-list-update/oracle/oval"
"github.com/spf13/afero"
"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")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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