Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyluiz committed Dec 13, 2024
1 parent 8587c6c commit b89f5b4
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/handler/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var plugin = &cobra.Command{
Short: "Run an Unchained plugin locally",
Long: `Run an Unchained plugin locally`,

Run: func(cmd *cobra.Command, _ []string) {
Run: func(_ *cobra.Command, _ []string) {
os.Exit(1)
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/model/correctness.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Correctness) FromSia(sia sia.Sia) *Correctness {
func (c *Correctness) Bls() (bls12381.G1Affine, error) {
hash, err := bls.Hash(c.Sia().Bytes())
if err != nil {
utils.Logger.Error("Can't hash bls: %v", err)
utils.Logger.Error("Can't hash bls: %v", "error", err.Error())
return bls12381.G1Affine{}, err
}

Expand Down
2 changes: 1 addition & 1 deletion internal/model/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (e *EventLog) FromSia(sia sia.Sia) *EventLog {
func (e *EventLog) Bls() (bls12381.G1Affine, error) {
hash, err := bls.Hash(e.Sia().Bytes())
if err != nil {
utils.Logger.Error("Can't hash bls: %v", err)
utils.Logger.With("Error", err).Error("Can't hash bls")
return bls12381.G1Affine{}, err
}

Expand Down
1 change: 1 addition & 0 deletions internal/service/ai/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (tc *TxChecker) CheckTransaction(txHash common.Hash, toAddress common.Addre
return false, fmt.Errorf("could not retrieve block header: %w", err)
}

//nolint:gosec // refactoring needed
blockTime := time.Unix(int64(header.Time), 0)
if time.Since(blockTime) > 5*time.Minute {
tc.txCache.MarkExpired(txHash)
Expand Down
6 changes: 5 additions & 1 deletion internal/service/evmlog/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (s *service) ProcessBlocks(ctx context.Context, chain string) error {
}

query := goEthereum.FilterQuery{
//nolint:gosec //refactoring needed
FromBlock: big.NewInt(int64(fromBlock)),
//nolint:gosec // refactoring needed
ToBlock: big.NewInt(int64(toBlock)),
Addresses: []common.Address{contractAddress},
}
Expand Down Expand Up @@ -139,7 +141,9 @@ func (s *service) ProcessBlocks(ctx context.Context, chain string) error {
value := eventData[key]

if strings.HasPrefix(argTypes[key], "uint") || strings.HasPrefix(argTypes[key], "int") {
value = value.(*big.Int).String()
if bigInt, ok := value.(*big.Int); ok {
value = bigInt.String()
}
}

args = append(
Expand Down
2 changes: 2 additions & 0 deletions internal/service/pos/pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (s *service) GetVotingPowerOfEvm(ctx context.Context, evmAddress string) (*
return nil, err
}
address := common.HexToAddress(evmAddress)
//nolint:gosec // refactoring needed
return s.GetVotingPower(address, big.NewInt(int64(block)))
}

Expand All @@ -99,6 +100,7 @@ func (s *service) GetVotingPowerOfPublicKey(ctx context.Context, pkBytes [96]byt
if err != nil {
return nil, err
}
//nolint:gosec // refactoring needed
return s.GetVotingPower(addrHex, big.NewInt(int64(block)))
}

Expand Down
7 changes: 6 additions & 1 deletion internal/service/pos/pos_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ func (m *MockService) GetVotingPowerOfPublicKey(_ context.Context, pkBytes [96]b

func (m *MockService) GetSchnorrSigners(_ context.Context) ([]common.Address, error) {
args := m.Called()
return args.Get(0).([]common.Address), args.Error(1)
if result := args.Get(0); result != nil {
if addresses, ok := result.([]common.Address); ok {
return addresses, args.Error(1)
}
}
return nil, args.Error(1)
}
1 change: 1 addition & 0 deletions internal/service/rpc/runtime/unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type UnixPayload struct {
func NewUnixPayload(params *dto.RPCRequest) *UnixPayload {
payload := params.Sia().Bytes()
return &UnixPayload{
//nolint:gosec // refactoring needed
Size: uint32(len(payload)),
Params: payload,
}
Expand Down
1 change: 1 addition & 0 deletions internal/service/uniswap/uniswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (s *service) GetPriceAtBlockFromPair(

data, err := pair.Slot0(
&bind.CallOpts{
//nolint:gosec // refactoring needed
BlockNumber: big.NewInt(int64(blockNumber)),
})

Expand Down
2 changes: 1 addition & 1 deletion internal/transport/client/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func Send(opCode consts.OpCode, payload []byte) {
append([]byte{byte(opCode)}, payload...),
)
if err != nil {
utils.Logger.Error("Can't send packet: %v", err)
utils.Logger.With("Error", err).Error("Can't send packet")
}
}

Expand Down
8 changes: 4 additions & 4 deletions internal/transport/server/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func WithWebsocket() func() {

// multiplexer is a function that routes incoming messages to the appropriate handler.
func multiplexer(w http.ResponseWriter, r *http.Request) {
upgrader.CheckOrigin = func(r *http.Request) bool { return true } // remove this line in production
upgrader.CheckOrigin = func(_ *http.Request) bool { return true } // remove this line in production

conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
utils.Logger.Error("Can't upgrade the HTTP connection: %v", err)
utils.Logger.With("Error", err).Error("Can't upgrade the HTTP connection")
return
}

Expand All @@ -45,11 +45,11 @@ func multiplexer(w http.ResponseWriter, r *http.Request) {
for {
_, payload, err := conn.ReadMessage()
if err != nil {
utils.Logger.Error("Can't read message: %v", err)
utils.Logger.With("Error", err).Error("Can't read message")

err := conn.Close()
if err != nil {
utils.Logger.Error("Can't close connection: %v", err)
utils.Logger.With("Error", err).Error("Can't close connection")
}

break
Expand Down

0 comments on commit b89f5b4

Please sign in to comment.