mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
make: dockerize linter
This commit is contained in:
parent
1741896e33
commit
f0bf9302cc
7 changed files with 1615 additions and 16 deletions
103
.golangci.yml
103
.golangci.yml
|
|
@ -2,37 +2,64 @@ run:
|
|||
# timeout for analysis
|
||||
deadline: 4m
|
||||
|
||||
# Linting uses a lot of memory. Keep it under control by only running a single
|
||||
# worker.
|
||||
concurrency: 1
|
||||
skip-files:
|
||||
- "\\.pb\\.go$"
|
||||
- "\\.pb\\.gw\\.go$"
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
# Don't report about shadowed variables
|
||||
check-shadowing: false
|
||||
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
simplify: true
|
||||
|
||||
tagliatelle:
|
||||
case:
|
||||
rules:
|
||||
json: snake
|
||||
|
||||
whitespace:
|
||||
multi-func: true
|
||||
multi-if: true
|
||||
|
||||
gosec:
|
||||
excludes:
|
||||
- G402 # Look for bad TLS connection settings.
|
||||
- G306 # Poor file permissions used when writing to a new file.
|
||||
|
||||
staticcheck:
|
||||
go: "1.18"
|
||||
checks: ["-SA1019"]
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
# Global variables are used in many places throughout the code base.
|
||||
# Global variables are used in many places throughout the code base.
|
||||
- gochecknoglobals
|
||||
|
||||
# Some lines are over 80 characters on purpose and we don't want to make them
|
||||
# even longer by marking them as 'nolint'.
|
||||
- lll
|
||||
|
||||
# We don't care (enough) about misaligned structs to lint that.
|
||||
- maligned
|
||||
# We want to allow short variable names.
|
||||
- varnamelen
|
||||
|
||||
# We want to allow TODOs.
|
||||
- godox
|
||||
|
||||
# We have long functions, especially in tests. Moving or renaming those would
|
||||
# trigger funlen problems that we may not want to solve at that time.
|
||||
- funlen
|
||||
|
||||
# Disable for now as we haven't yet tuned the sensitivity to our codebase
|
||||
# yet. Enabling by default for example, would also force new contributors to
|
||||
# yet. Enabling by default for example, would also force new contributors to
|
||||
# potentially extensively refactor code, when they want to smaller change to
|
||||
# land.
|
||||
- gocyclo
|
||||
- gocognit
|
||||
- cyclop
|
||||
|
||||
# Instances of table driven tests that don't pre-allocate shouldn't trigger
|
||||
# the linter.
|
||||
|
|
@ -40,7 +67,69 @@ linters:
|
|||
|
||||
# Init functions are used by loggers throughout the codebase.
|
||||
- gochecknoinits
|
||||
|
||||
# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
|
||||
- errorlint
|
||||
|
||||
# Deprecated linters. See https://golangci-lint.run/usage/linters/.
|
||||
- interfacer
|
||||
- golint
|
||||
- maligned
|
||||
- scopelint
|
||||
|
||||
# New linters that need a code adjustment first.
|
||||
- wrapcheck
|
||||
- nolintlint
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- testpackage
|
||||
- gofumpt
|
||||
- gomoddirectives
|
||||
- ireturn
|
||||
- maintidx
|
||||
- nlreturn
|
||||
- dogsled
|
||||
- gci
|
||||
- containedctx
|
||||
- contextcheck
|
||||
- errname
|
||||
- exhaustivestruct
|
||||
- goerr113
|
||||
- gomnd
|
||||
- ifshort
|
||||
- noctx
|
||||
- nestif
|
||||
- wsl
|
||||
- exhaustive
|
||||
- forcetypeassert
|
||||
- nilerr
|
||||
- nilnil
|
||||
- stylecheck
|
||||
- thelper
|
||||
|
||||
# Additions compared to LND
|
||||
- exhaustruct
|
||||
|
||||
issues:
|
||||
# Only show newly introduced problems.
|
||||
new-from-rev: 36838cf7f464cf73b0201798063b2caffeae4250
|
||||
|
||||
exclude-rules:
|
||||
|
||||
# Allow fmt.Printf() in test files
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- forbidigo
|
||||
|
||||
# Allow fmt.Printf() in loopd
|
||||
- path: cmd/loopd/*
|
||||
linters:
|
||||
- forbidigo
|
||||
- path: loopd/*
|
||||
linters:
|
||||
- forbidigo
|
||||
|
||||
# Allow fmt.Printf() in loop
|
||||
- path: cmd/loop/*
|
||||
linters:
|
||||
- forbidigo
|
||||
23
Makefile
23
Makefile
|
|
@ -1,6 +1,7 @@
|
|||
.DEFAULT_GOAL := build
|
||||
|
||||
PKG := github.com/lightninglabs/loop
|
||||
TOOLS_DIR := tools
|
||||
|
||||
GOTEST := GO111MODULE=on go test -v
|
||||
|
||||
|
|
@ -16,18 +17,20 @@ DEV_TAGS = dev
|
|||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
|
||||
|
||||
LINT_BIN := $(GO_BIN)/golangci-lint
|
||||
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
LINT_COMMIT := v1.18.0
|
||||
LINT = $(LINT_BIN) run -v
|
||||
|
||||
DEPGET := cd /tmp && GO111MODULE=on go get -v
|
||||
XARGS := xargs -L 1
|
||||
|
||||
TEST_FLAGS = -test.timeout=20m
|
||||
|
||||
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
|
||||
|
||||
# Linting uses a lot of memory, so keep it under control by limiting the number
|
||||
# of workers if requested.
|
||||
ifneq ($(workers),)
|
||||
LINT_WORKERS = --concurrency=$(workers)
|
||||
endif
|
||||
|
||||
DOCKER_TOOLS = docker run -v $$(pwd):/build loop-tools
|
||||
|
||||
GREEN := "\\033[0;32m"
|
||||
NC := "\\033[0m"
|
||||
define print
|
||||
|
|
@ -46,9 +49,13 @@ fmt:
|
|||
@$(call print, "Formatting source.")
|
||||
gofmt -l -w -s $(GOFILES_NOVENDOR)
|
||||
|
||||
lint: $(LINT_BIN)
|
||||
lint: docker-tools
|
||||
@$(call print, "Linting source.")
|
||||
$(LINT)
|
||||
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
|
||||
|
||||
docker-tools:
|
||||
@$(call print, "Building tools docker image.")
|
||||
docker build -q -t loop-tools $(TOOLS_DIR)
|
||||
|
||||
mod-tidy:
|
||||
@$(call print, "Tidying modules.")
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ func (s *swapClientServer) Monitor(in *clientrpc.MonitorRequest,
|
|||
}
|
||||
|
||||
// Concatenate both sets.
|
||||
filteredSwaps := append(pendingSwaps, completedSwaps...)
|
||||
filteredSwaps := append(pendingSwaps, completedSwaps...) // nolint: gocritic
|
||||
|
||||
// Sort again, but this time old to new.
|
||||
sort.Slice(filteredSwaps, func(i, j int) bool {
|
||||
|
|
|
|||
16
tools/Dockerfile
Normal file
16
tools/Dockerfile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
FROM golang:1.18.0-buster
|
||||
|
||||
RUN apt-get update && apt-get install -y git
|
||||
ENV GOCACHE=/tmp/build/.cache
|
||||
ENV GOMODCACHE=/tmp/build/.modcache
|
||||
|
||||
COPY . /tmp/tools
|
||||
|
||||
RUN cd /tmp \
|
||||
&& mkdir -p /tmp/build/.cache \
|
||||
&& mkdir -p /tmp/build/.modcache \
|
||||
&& cd /tmp/tools \
|
||||
&& go install -trimpath -tags=tools github.com/golangci/golangci-lint/cmd/golangci-lint \
|
||||
&& chmod -R 777 /tmp/build/
|
||||
|
||||
WORKDIR /build
|
||||
5
tools/go.mod
Normal file
5
tools/go.mod
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module github.com/lightninglabs/loop/tools
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/golangci/golangci-lint v1.46.2 // indirect
|
||||
1474
tools/go.sum
Normal file
1474
tools/go.sum
Normal file
File diff suppressed because it is too large
Load diff
8
tools/tools.go
Normal file
8
tools/tools.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
//go:build tools
|
||||
// +build tools
|
||||
|
||||
package loop
|
||||
|
||||
import (
|
||||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue