Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash every lint/staticcheck error. Add a linter CI action to github. #421

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Taken from https://github.com/golangci/golangci-lint-action
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.19.13
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Dockerfile
/rocketpool/rocketpool-daemon-linux-amd64
/rocketpool/rocketpool-daemon-darwin-arm64
/rocketpool/rocketpool-daemon-linux-arm64
*.swp
6 changes: 3 additions & 3 deletions addons/rescue_node/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type credentialDetails struct {

func (c *credentialDetails) GetTimeLeft() time.Duration {

if c.solo == true {
if c.solo {
return time.Until(c.issued.Add(soloAuthValidity))
}

Expand Down Expand Up @@ -138,7 +138,7 @@ func (r *RescueNode) PrintStatusText(nodeAddr common.Address) {
// Check the Username
usernameNodeAddr, err := r.getCredentialNodeId()
if err != nil {
fmt.Printf("%s%w%s", colorRed, err, colorReset)
fmt.Printf("%s%v%s\n", colorRed, err, colorReset)
} else {
fmt.Printf("Using a credential issued to %s%s%s.\n", colorBlue, usernameNodeAddr.String(), colorReset)
if !bytes.Equal(usernameNodeAddr.Bytes(), nodeAddr.Bytes()) {
Expand All @@ -148,7 +148,7 @@ func (r *RescueNode) PrintStatusText(nodeAddr common.Address) {

credentialDetails, err := r.getCredentialDetails()
if err != nil {
fmt.Printf("%s%w%s", colorRed, err, colorReset)
fmt.Printf("%s%v%s\n", colorRed, err, colorReset)
} else {
if credentialDetails.solo {
fmt.Printf("%s - WARNING: This credential was issued to a solo staker!%s\n", colorYellow, colorReset)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ require (
golang.org/x/crypto v0.6.0
golang.org/x/sync v0.1.0
golang.org/x/term v0.5.0
google.golang.org/protobuf v1.28.1
gopkg.in/yaml.v2 v2.4.0
)

Expand Down Expand Up @@ -174,7 +175,6 @@ require (
gonum.org/v1/gonum v0.12.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gotest.tools/v3 v3.4.0 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
Expand Down
153 changes: 0 additions & 153 deletions rocketpool-cli/minipool/dissolve.go

This file was deleted.

9 changes: 6 additions & 3 deletions rocketpool-cli/minipool/reduce-bond.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ func reduceBondAmount(c *cli.Context) error {
return err
}

fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.\n")
fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.")
fmt.Println()

// Get reduceable minipools
reduceableMinipools := []api.MinipoolDetails{}
Expand Down Expand Up @@ -360,10 +361,12 @@ func forceFeeDistribution(c *cli.Context, rp *rocketpool.Client) error {

balance := eth.WeiToEth(canDistributeResponse.Balance)
if balance == 0 {
fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.\n")
fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.")
fmt.Println()
return nil
}
fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.\n")
fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.")
fmt.Println()

// Print info
rEthShare := balance - canDistributeResponse.NodeShare
Expand Down
8 changes: 5 additions & 3 deletions rocketpool-cli/minipool/rescue-dissolved.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func rescueDissolved(c *cli.Context) error {
return err
}

fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.\nPlease read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.\n")
fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.")
fmt.Println("Please read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.")
fmt.Println()

// Validate the amount
var depositAmount *big.Int
Expand Down Expand Up @@ -90,14 +92,14 @@ func rescueDissolved(c *cli.Context) error {
fmt.Printf("\nPlease upgrade the delegate for these minipools using `rocketpool minipool delegate-upgrade` before rescuing them.%s\n\n", colorReset)
}
if len(balanceCompletedMinipools) > 0 {
fmt.Printf("%NOTE: The following minipools already have 32 ETH or more deposited:\n", colorYellow)
fmt.Printf("%sNOTE: The following minipools already have 32 ETH or more deposited:\n", colorYellow)
for _, mp := range balanceCompletedMinipools {
fmt.Printf("\t%s\n", mp.Address)
}
fmt.Printf("\nThese minipools don't need to be rescued.%s\n\n", colorReset)
}
if len(invalidBeaconStateMinipools) > 0 {
fmt.Printf("%NOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", colorYellow)
fmt.Printf("%sNOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", colorYellow)
for _, mp := range invalidBeaconStateMinipools {
fmt.Printf("\t%s (%s)\n", mp.Address, mp.BeaconState)
}
Expand Down
4 changes: 3 additions & 1 deletion rocketpool-cli/minipool/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ func stakeMinipools(c *cli.Context) error {
return err
}

fmt.Println("\nNOTE: Your validator container will be restarted after this process so it loads the new validator key.\n")
fmt.Println()
fmt.Println("NOTE: Your validator container will be restarted after this process so it loads the new validator key.")
fmt.Println()

// Prompt for confirmation
if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf("Are you sure you want to stake %d minipools?", len(selectedMinipools)))) {
Expand Down
4 changes: 2 additions & 2 deletions rocketpool-cli/minipool/vanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func runWorker(report bool, stop *bool, targetPrefix *big.Int, nodeAddress []byt
salt.FillBytes(saltBytes[:])
hasher.Write(nodeAddress)
hasher.Write(saltBytes[:])
hasher.Read(nodeSalt[:])
_, _ = hasher.Read(nodeSalt[:])
hasher.Reset()

// This block is the fast way to do `crypto.CreateAddress2(minipoolManagerAddress, nodeSalt, initHash)`
Expand All @@ -198,7 +198,7 @@ func runWorker(report bool, stop *bool, targetPrefix *big.Int, nodeAddress []byt
hasher.Write(minipoolManagerAddress.Bytes())
hasher.Write(nodeSalt[:])
hasher.Write(initHash)
hasher.Read(addressResult[:])
_, _ = hasher.Read(addressResult[:])
hasher.Reset()

hashInt.SetBytes(addressResult[12:])
Expand Down
Loading