mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-1521] use staticcheck (#1015)
* [NOD-1521] Use static check as part of jenkins to check for swallowed errors * [NOD-1521] added staticcheck installation * [NOD-1521] Fix static check errors Co-authored-by: Ori Newman <orinewman1@gmail.com>
This commit is contained in:
parent
23c1ea6c31
commit
8290fadd3a
@ -222,6 +222,10 @@ func (flow *handleRelayInvsFlow) processAndRelayBlock(requestQueue *hashesQueueS
|
||||
return err
|
||||
}
|
||||
selectedTipBlueScore, err := blocks.ExtractBlueScore(virtualSelectedParent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if blueScore > selectedTipBlueScore+maxOrphanBlueScoreDiff {
|
||||
log.Infof("Orphan block %s has blue score %d and the selected tip blue score is "+
|
||||
"%d. Ignoring orphans with a blue score difference from the selected tip greater than %d",
|
||||
|
@ -6,7 +6,8 @@ RUN mkdir -p /go/src/github.com/kaspanet/kaspad
|
||||
WORKDIR /go/src/github.com/kaspanet/kaspad
|
||||
|
||||
RUN apk add --no-cache curl git openssh binutils gcc musl-dev
|
||||
RUN go get -u golang.org/x/lint/golint
|
||||
RUN go get -u golang.org/x/lint/golint \
|
||||
honnef.co/go/tools/cmd/staticcheck
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
@ -20,6 +21,7 @@ WORKDIR /go/src/github.com/kaspanet/kaspad/cmd/kaspactl
|
||||
RUN GOFMT_RESULT=`go fmt ./...`; echo $GOFMT_RESULT; test -z "$GOFMT_RESULT"
|
||||
RUN go vet ./...
|
||||
RUN golint -set_exit_status ./...
|
||||
RUN staticcheck -checks SA4006 ./...
|
||||
RUN GOOS=linux go build -a -installsuffix cgo -o kaspactl .
|
||||
|
||||
# --- multistage docker build: stage #2: runtime image
|
||||
|
@ -6,7 +6,8 @@ RUN mkdir -p /go/src/github.com/kaspanet/kaspad
|
||||
WORKDIR /go/src/github.com/kaspanet/kaspad
|
||||
|
||||
RUN apk add --no-cache curl git openssh binutils gcc musl-dev
|
||||
RUN go get -u golang.org/x/lint/golint
|
||||
RUN go get -u golang.org/x/lint/golint \
|
||||
honnef.co/go/tools/cmd/staticcheck
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
@ -20,6 +21,7 @@ WORKDIR /go/src/github.com/kaspanet/kaspad/cmd/kaspaminer
|
||||
RUN GOFMT_RESULT=`go fmt ./...`; echo $GOFMT_RESULT; test -z "$GOFMT_RESULT"
|
||||
RUN go vet ./...
|
||||
RUN golint -set_exit_status ./...
|
||||
RUN staticcheck -checks SA4006 ./...
|
||||
RUN GOOS=linux go build -a -installsuffix cgo -o kaspaminer .
|
||||
|
||||
# --- multistage docker build: stage #2: runtime image
|
||||
|
@ -10,7 +10,8 @@ RUN go get -u golang.org/x/lint/golint \
|
||||
github.com/kisielk/errcheck \
|
||||
github.com/opennota/check/cmd/aligncheck \
|
||||
github.com/opennota/check/cmd/structcheck \
|
||||
github.com/opennota/check/cmd/varcheck
|
||||
github.com/opennota/check/cmd/varcheck \
|
||||
honnef.co/go/tools/cmd/staticcheck
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
@ -25,6 +26,7 @@ RUN golint -set_exit_status ./...
|
||||
# RUN aligncheck ./...
|
||||
# RUN structcheck -e ./...
|
||||
# RUN varcheck -e ./...
|
||||
RUN staticcheck -checks SA4006 ./...
|
||||
RUN GOOS=linux go build -a -installsuffix cgo -o kaspad .
|
||||
|
||||
# Remove the line below and uncomment the line after it for testing with coverage
|
||||
|
@ -81,7 +81,7 @@ func TestLevelDBTransactionSanity(t *testing.T) {
|
||||
|
||||
// Get from the key previously put to. Since the tx is not
|
||||
// yet committed, this should return ErrNotFound.
|
||||
getData, err := ldb.Get(key)
|
||||
_, err = ldb.Get(key)
|
||||
if err == nil {
|
||||
t.Fatalf("TestLevelDBTransactionSanity: Get " +
|
||||
"unexpectedly succeeded")
|
||||
@ -100,7 +100,7 @@ func TestLevelDBTransactionSanity(t *testing.T) {
|
||||
|
||||
// Get from the key previously put to. Now that the tx was
|
||||
// committed, this should succeed.
|
||||
getData, err = ldb.Get(key)
|
||||
getData, err := ldb.Get(key)
|
||||
if err != nil {
|
||||
t.Fatalf("TestLevelDBTransactionSanity: Get "+
|
||||
"returned unexpected error: %s", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user