Merge pull request #3331 from halseth/golangci-linter
[build, tooling] change linter gometalinter->golangci-lint
This commit is contained in:
commit
c963fcbed8
18
.golangci.yml
Normal file
18
.golangci.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
run:
|
||||||
|
# timeout for analysis
|
||||||
|
deadline: 4m
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
govet:
|
||||||
|
# Don't report about shadowed variables
|
||||||
|
check-shadowing: false
|
||||||
|
gofmt:
|
||||||
|
# simplify code: gofmt with `-s` option, true by default
|
||||||
|
simplify: true
|
||||||
|
|
||||||
|
linters:
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- golint
|
||||||
|
- govet
|
20
Makefile
20
Makefile
@ -3,13 +3,13 @@ ESCPKG := github.com\/lightningnetwork\/lnd
|
|||||||
|
|
||||||
BTCD_PKG := github.com/btcsuite/btcd
|
BTCD_PKG := github.com/btcsuite/btcd
|
||||||
GOVERALLS_PKG := github.com/mattn/goveralls
|
GOVERALLS_PKG := github.com/mattn/goveralls
|
||||||
LINT_PKG := gopkg.in/alecthomas/gometalinter.v2
|
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||||
GOACC_PKG := github.com/ory/go-acc
|
GOACC_PKG := github.com/ory/go-acc
|
||||||
|
|
||||||
GO_BIN := ${GOPATH}/bin
|
GO_BIN := ${GOPATH}/bin
|
||||||
BTCD_BIN := $(GO_BIN)/btcd
|
BTCD_BIN := $(GO_BIN)/btcd
|
||||||
GOVERALLS_BIN := $(GO_BIN)/goveralls
|
GOVERALLS_BIN := $(GO_BIN)/goveralls
|
||||||
LINT_BIN := $(GO_BIN)/gometalinter.v2
|
LINT_BIN := $(GO_BIN)/golangci-lint
|
||||||
GOACC_BIN := $(GO_BIN)/go-acc
|
GOACC_BIN := $(GO_BIN)/go-acc
|
||||||
|
|
||||||
BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG)
|
BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG)
|
||||||
@ -32,7 +32,6 @@ GOTEST := GO111MODULE=on go test -v
|
|||||||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||||
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
|
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
|
||||||
GOLISTCOVER := $(shell go list -f '{{.ImportPath}}' ./... | sed -e 's/^$(ESCPKG)/./')
|
GOLISTCOVER := $(shell go list -f '{{.ImportPath}}' ./... | sed -e 's/^$(ESCPKG)/./')
|
||||||
GOLISTLINT := $(shell go list -f '{{.Dir}}' ./... | grep -v 'lnrpc')
|
|
||||||
|
|
||||||
RM := rm -f
|
RM := rm -f
|
||||||
CP := cp
|
CP := cp
|
||||||
@ -43,15 +42,7 @@ include make/testing_flags.mk
|
|||||||
|
|
||||||
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
|
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
|
||||||
|
|
||||||
LINT = $(LINT_BIN) \
|
LINT = $(LINT_BIN) run
|
||||||
--disable-all \
|
|
||||||
--enable=gofmt \
|
|
||||||
--enable=vet \
|
|
||||||
--enable=golint \
|
|
||||||
--line-length=72 \
|
|
||||||
--deadline=4m $(GOLISTLINT) 2>&1 | \
|
|
||||||
grep -v 'ALL_CAPS\|OP_' 2>&1 | \
|
|
||||||
tee /dev/stderr
|
|
||||||
|
|
||||||
GREEN := "\\033[0;32m"
|
GREEN := "\\033[0;32m"
|
||||||
NC := "\\033[0m"
|
NC := "\\033[0m"
|
||||||
@ -72,7 +63,7 @@ $(GOVERALLS_BIN):
|
|||||||
go get -u $(GOVERALLS_PKG)
|
go get -u $(GOVERALLS_PKG)
|
||||||
|
|
||||||
$(LINT_BIN):
|
$(LINT_BIN):
|
||||||
@$(call print, "Fetching gometalinter.v2")
|
@$(call print, "Fetching linter")
|
||||||
GO111MODULE=off go get -u $(LINT_PKG)
|
GO111MODULE=off go get -u $(LINT_PKG)
|
||||||
|
|
||||||
$(GOACC_BIN):
|
$(GOACC_BIN):
|
||||||
@ -166,8 +157,7 @@ fmt:
|
|||||||
|
|
||||||
lint: $(LINT_BIN)
|
lint: $(LINT_BIN)
|
||||||
@$(call print, "Linting source.")
|
@$(call print, "Linting source.")
|
||||||
GO111MODULE=off $(LINT_BIN) --install 1> /dev/null
|
$(LINT)
|
||||||
test -z "$$($(LINT))"
|
|
||||||
|
|
||||||
list:
|
list:
|
||||||
@$(call print, "Listing commands.")
|
@$(call print, "Listing commands.")
|
||||||
|
@ -1790,7 +1790,8 @@ func (c *OpenChannel) RemoveFwdPkg(height uint64) error {
|
|||||||
|
|
||||||
// RevocationLogTail returns the "tail", or the end of the current revocation
|
// RevocationLogTail returns the "tail", or the end of the current revocation
|
||||||
// log. This entry represents the last previous state for the remote node's
|
// log. This entry represents the last previous state for the remote node's
|
||||||
// commitment chain. The ChannelDelta returned by this method will always lag one state behind the most current (unrevoked) state of the remote node's
|
// commitment chain. The ChannelDelta returned by this method will always lag
|
||||||
|
// one state behind the most current (unrevoked) state of the remote node's
|
||||||
// commitment chain.
|
// commitment chain.
|
||||||
func (c *OpenChannel) RevocationLogTail() (*ChannelCommitment, error) {
|
func (c *OpenChannel) RevocationLogTail() (*ChannelCommitment, error) {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
|
@ -1194,11 +1194,7 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
|||||||
fail.Reason = circuit.ErrorEncrypter.EncryptMalformedError(
|
fail.Reason = circuit.ErrorEncrypter.EncryptMalformedError(
|
||||||
fail.Reason,
|
fail.Reason,
|
||||||
)
|
)
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("unable to obfuscate "+
|
|
||||||
"error: %v", err)
|
|
||||||
log.Error(err)
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
// Otherwise, it's a forwarded error, so we'll perform a
|
// Otherwise, it's a forwarded error, so we'll perform a
|
||||||
// wrapper encryption as normal.
|
// wrapper encryption as normal.
|
||||||
|
@ -11,14 +11,14 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
testRootKey = []byte("dummyRootKey")
|
testRootKey = []byte("dummyRootKey")
|
||||||
testId = []byte("dummyId")
|
testID = []byte("dummyId")
|
||||||
testLocation = "lnd"
|
testLocation = "lnd"
|
||||||
testVersion = macaroon.LatestVersion
|
testVersion = macaroon.LatestVersion
|
||||||
expectedTimeCaveatSubstring = "time-before " + string(time.Now().Year())
|
expectedTimeCaveatSubstring = "time-before " + string(time.Now().Year())
|
||||||
)
|
)
|
||||||
|
|
||||||
func createDummyMacaroon(t *testing.T) *macaroon.Macaroon {
|
func createDummyMacaroon(t *testing.T) *macaroon.Macaroon {
|
||||||
dummyMacaroon, err := macaroon.New(testRootKey, testId,
|
dummyMacaroon, err := macaroon.New(testRootKey, testID,
|
||||||
testLocation, testVersion)
|
testLocation, testVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error creating initial macaroon: %v", err)
|
t.Fatalf("Error creating initial macaroon: %v", err)
|
||||||
|
@ -665,7 +665,7 @@ func (c *ClientDB) RegisterChannel(chanID lnwire.ChannelID,
|
|||||||
case err == ErrChannelNotRegistered:
|
case err == ErrChannelNotRegistered:
|
||||||
|
|
||||||
// Unexpected error.
|
// Unexpected error.
|
||||||
case err != nil:
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ func ReadElement(r io.Reader, element interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
// Fail if error is not UnknownElementType.
|
// Fail if error is not UnknownElementType.
|
||||||
case err != nil:
|
default:
|
||||||
if _, ok := err.(UnknownElementType); !ok {
|
if _, ok := err.(UnknownElementType); !ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ func WriteElement(w io.Writer, element interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
// Fail if error is not UnknownElementType.
|
// Fail if error is not UnknownElementType.
|
||||||
case err != nil:
|
default:
|
||||||
if _, ok := err.(UnknownElementType); !ok {
|
if _, ok := err.(UnknownElementType); !ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user