Skip to content

Commit

Permalink
Dep Upgrades and Minor Updates (#99)
Browse files Browse the repository at this point in the history
* Upgraded super linter, ignore specific linter

* Fixed lots of deprecations

* Upgraded linter version

* Formatting dep imports

* Added nolint for nested ctx

* Fixed imports

* Lots of upgrades, had to add replacements

There are code breaking changes letting the deps upgrade to the newest versions

* Turn off go mod checking in super linter

* Upgraded deps

* Updated linter version
  • Loading branch information
mrz1836 authored Sep 3, 2024
1 parent b161ae8 commit 4e73706
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 204 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ jobs:
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v5
uses: github/super-linter@v6
env:
VALIDATE_EDITORCONFIG: false # Not needed in this project
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: false
VALIDATE_JSCPD: false
VALIDATE_GO: false # Already running in Go tests
VALIDATE_GITLEAKS: false # False positives for public keys
VALIDATE_CHECKOV: false # False positive
VALIDATE_GO_MODULES: false # Already running in Go tests
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88 changes: 39 additions & 49 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
timeout: 6m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand All @@ -19,31 +19,10 @@ run:
build-tags:
- mytag

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- .github
- .make
- dist

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- ".*\\.my\\.go$"
- lib/bad.go

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -58,11 +37,11 @@ run:
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false


# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats:
- format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand All @@ -76,7 +55,6 @@ output:
# add a prefix to the output file references; default is no prefix
path-prefix: ""


# all available settings of specific linters
linters-settings:
dogsled:
Expand All @@ -94,10 +72,9 @@ linters-settings:
# default is false: such cases aren't reported by default.
check-blank: false

# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude-functions: fmt:.*,io/ioutil:^Read.*

# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
Expand All @@ -111,10 +88,8 @@ linters-settings:
lines: 60
statements: 40
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/org/project
sections:
- prefix(github.com/org/project) # Custom section: groups all imports with the specified Prefix.
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
Expand Down Expand Up @@ -184,14 +159,7 @@ linters-settings:
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: [argument, case, condition, operation, return, assign]
govet:
# report about shadowed variables
check-shadowing: true

# settings per analyzer
settings:
Expand All @@ -205,8 +173,9 @@ linters-settings:
# enable or disable analyzers by name
enable:
- atomicalign
- shadow
enable-all: false
#disable:
#disable:
#- shadow
disable-all: false
#depguard:
Expand All @@ -223,9 +192,6 @@ linters-settings:
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 1
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand Down Expand Up @@ -316,7 +282,9 @@ linters-settings:

linters:
enable:
- megacheck
- gosimple
- staticcheck
- unused
- govet
- gofmt
- gosec
Expand All @@ -333,7 +301,7 @@ linters:
- asciicheck
- bidichk
- bodyclose
- contextcheck
- containedctx
- unused
- dogsled
- durationcheck
Expand Down Expand Up @@ -368,18 +336,40 @@ linters:
- gochecknoglobals # this project uses some globals
- godot # some comments do not end in a period
- godox # finds all the HACKs
- goerr113 # requires a lot of fixes for errors with wrapping
- err113 # requires a lot of fixes for errors with wrapping
- gomnd # we have too many raw numbers that are not magic
- gomoddirectives # we use replace as needed
- nilnil # we do not conform to this
- containedctx # needs more work
- contextcheck # having issues with this
disable-all: false
presets:
- bugs
- unused
fast: false

issues:

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
exclude-files:
- ".*\\.my\\.go$"
- lib/bad.go

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
exclude-dirs:
- .github
- .make
- dist

# List of regexps of issue texts to exclude, empty list by default.
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
Expand Down Expand Up @@ -478,4 +468,4 @@ severity:
rules:
- linters:
- dupl
severity: info
severity: info
2 changes: 1 addition & 1 deletion .make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ lint: ## Run the golangci-lint application (install if not found)
GOPATH=$$(go env GOPATH); \
if [ -z "$$GOPATH" ]; then GOPATH=$$HOME/go; fi; \
echo "Installation path: $$GOPATH/bin"; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$GOPATH/bin v1.56.1; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$GOPATH/bin v1.59.1; \
fi; \
fi; \
if [ "$(TRAVIS)" != "" ]; then \
Expand Down
3 changes: 1 addition & 2 deletions app/api/base/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package base
import (
"net/http"

"github.com/bitcoin-sv/alert-system/app/p2p"

"github.com/bitcoin-sv/alert-system/app"
"github.com/bitcoin-sv/alert-system/app/config"
"github.com/bitcoin-sv/alert-system/app/p2p"
apirouter "github.com/mrz1836/go-api-router"
)

Expand Down
4 changes: 1 addition & 3 deletions app/p2p/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import (
"time"

"github.com/bitcoin-sv/alert-system/app/config"
dht "github.com/libp2p/go-libp2p-kad-dht"
"github.com/libp2p/go-libp2p/core/peer"

"github.com/multiformats/go-multiaddr"

dht "github.com/libp2p/go-libp2p-kad-dht"
)

// initDHT will initialize the DHT
Expand Down
12 changes: 4 additions & 8 deletions app/p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,24 @@ import (
"os"
"time"

"github.com/libp2p/go-libp2p/p2p/net/conngater"

maddr "github.com/multiformats/go-multiaddr"

"github.com/libp2p/go-libp2p/core/discovery"

dht "github.com/libp2p/go-libp2p-kad-dht"

"github.com/bitcoin-sv/alert-system/app/config"
"github.com/bitcoin-sv/alert-system/app/models"
"github.com/bitcoin-sv/alert-system/app/models/model"
"github.com/bitcoin-sv/alert-system/app/webhook"
"github.com/libp2p/go-libp2p"
dht "github.com/libp2p/go-libp2p-kad-dht"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/discovery"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
drouting "github.com/libp2p/go-libp2p/p2p/discovery/routing"
dutil "github.com/libp2p/go-libp2p/p2p/discovery/util"
"github.com/libp2p/go-libp2p/p2p/net/conngater"
"github.com/mrz1836/go-datastore"
maddr "github.com/multiformats/go-multiaddr"
)

// Define an interface to handle topic notifications
Expand Down
2 changes: 1 addition & 1 deletion app/p2p/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Thread interface {
// StreamThread is a thread for a stream
type StreamThread struct {
config *config.Config
ctx context.Context // TODO should remove this, should be passed in via methods only
ctx context.Context //nolint:containedctx // TODO should remove this, should be passed in via methods only
latestSequence uint32
myLatestSequence uint32
peer peer.ID
Expand Down
6 changes: 3 additions & 3 deletions app/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"strings"

"github.com/bitcoin-sv/alert-system/app/p2p"
p2palert "github.com/bitcoin-sv/alert-system/app/p2p"

"github.com/bitcoin-sv/alert-system/app/api/base"
"github.com/bitcoin-sv/alert-system/app/config"
Expand All @@ -25,11 +25,11 @@ type Server struct {
Config *config.Config
Router *apirouter.Router
WebServer *http.Server
P2pServer *p2p.Server
P2pServer *p2palert.Server
}

// NewServer will return a new server service
func NewServer(conf *config.Config, serv *p2p.Server) *Server {
func NewServer(conf *config.Config, serv *p2palert.Server) *Server {
return &Server{
Config: conf,
P2pServer: serv,
Expand Down
Loading

0 comments on commit 4e73706

Please sign in to comment.