Skip to content

Commit

Permalink
Show all issues on lint (#869)
Browse files Browse the repository at this point in the history
* Show all issues on lint

* fix lint
  • Loading branch information
otherview authored Oct 30, 2024
1 parent b6380d5 commit af88757
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
version: v1.60.3
# use the default if on main branch, otherwise use the pull request config
args: --timeout=30m --config=.golangci.yml
only-new-issues: true
only-new-issues: false
skip-cache: true
44 changes: 0 additions & 44 deletions api/accounts/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
package accounts_test

import (
"bytes"
"encoding/json"
"fmt"
"io"
"math/big"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -578,45 +576,3 @@ func batchCallWithNonExistingRevision(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, statusCode, "bad revision")
assert.Equal(t, "revision: leveldb: not found\n", string(res), "revision not found")
}

func httpPost(t *testing.T, url string, body interface{}) ([]byte, int) {
data, err := json.Marshal(body)
if err != nil {
t.Fatal(err)
}
res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) //#nosec G107
if err != nil {
t.Fatal(err)
}
r, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatal(err)
}
return r, res.StatusCode
}

func httpGet(t *testing.T, url string) ([]byte, int) {
res, err := http.Get(url) //#nosec G107
if err != nil {
t.Fatal(err)
}
r, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatal(err)
}
return r, res.StatusCode
}

func httpGetAccount(t *testing.T, path string) *accounts.Account {
res, statusCode := httpGet(t, ts.URL+"/accounts/"+path)
var acc accounts.Account
if err := json.Unmarshal(res, &acc); err != nil {
t.Fatal(err)
}

assert.Equal(t, http.StatusOK, statusCode, "get account failed")

return &acc
}
14 changes: 0 additions & 14 deletions api/blocks/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package blocks_test

import (
"encoding/json"
"io"
"math"
"math/big"
"net/http"
Expand Down Expand Up @@ -267,16 +266,3 @@ func checkExpandedBlock(t *testing.T, expBl *block.Block, actBl *blocks.JSONExpa
assert.Equal(t, tx.ID(), actBl.Transactions[i].ID, "txid should be equal")
}
}

func httpGet(t *testing.T, url string) ([]byte, int) {
res, err := http.Get(url) //#nosec G107
if err != nil {
t.Fatal(err)
}
r, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatal(err)
}
return r, res.StatusCode
}
19 changes: 0 additions & 19 deletions api/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
package events_test

import (
"bytes"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -212,23 +210,6 @@ func createDb(t *testing.T) *logdb.LogDB {
}

// Utilities functions
func httpPost(t *testing.T, url string, body interface{}) ([]byte, int) {
data, err := json.Marshal(body)
if err != nil {
t.Fatal(err)
}
res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) //#nosec G107
if err != nil {
t.Fatal(err)
}
r, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatal(err)
}
return r, res.StatusCode
}

func insertBlocks(t *testing.T, db *logdb.LogDB, n int) {
b := new(block.Builder).Build()
for i := 0; i < n; i++ {
Expand Down
15 changes: 0 additions & 15 deletions api/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package node_test

import (
"io"
"net/http"
"net/http/httptest"
"testing"
"time"
Expand Down Expand Up @@ -54,16 +52,3 @@ func initCommServer(t *testing.T) {
node.New(comm).Mount(router, "/node")
ts = httptest.NewServer(router)
}

func httpGet(t *testing.T, url string) []byte {
res, err := http.Get(url) //#nosec G107
if err != nil {
t.Fatal(err)
}
r, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatal(err)
}
return r
}

0 comments on commit af88757

Please sign in to comment.