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

ci: add static checker for code analysis #416

Closed
wants to merge 1 commit into from
Closed

Conversation

mudler
Copy link
Contributor

@mudler mudler commented Jul 12, 2024

This adds a workflow to run golang static checks on PRs to catch simple bugs earlier

This adds a workflow to run golang static checks on PRs to catch simple bugs earlier
Copy link

⚠ goimports failed (.)

pkg/staking/faucet.go
 import (
 	"context"
 	"fmt"
+
 	"github.com/ethereum/go-ethereum/accounts/abi/bind"
 	"github.com/ethereum/go-ethereum/common"
 )
pkg/workers/messages/protos.pb.go
 package messages
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	actor "github.com/asynkron/protoactor-go/actor"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (

Copy link

⚠ errcheck failed (.)

error: failed to check packages: errors while loading package {sec:: [-: malformed import path "{sec:": invalid char '{']

Copy link

⚠ golint failed (.)

Found 157 lint suggestions; failing.

Show Detail
cmd/masa-node-cli/handlers.go:159:10: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/handlers.go:185:9: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/types.go:10:6: exported type AppConfig should have comment or be unexported
cmd/masa-node-cli/types.go:22:6: exported type Gossip should have comment or be unexported
cmd/masa-node-cli/types.go:27:6: exported type SpeakRequest should have comment or be unexported
cmd/masa-node-cli/types.go:35:6: exported type SubscriptionHandler should have comment or be unexported
cmd/masa-node-cli/types.go:41:6: exported type RadioButtons should have comment or be unexported
cmd/masa-node-cli/types.go:48:6: exported type InputBox should have comment or be unexported
cmd/tagger/main.go:23:1: package comment is detached; there should be no blank lines between it and the package statement
cmd/tagger/main.go:100:1: exported function TagProject should have comment or be unexported
pkg/oracle_node.go:40:6: exported type OracleNode should have comment or be unexported
pkg/oracle_node_listener.go:77:6: exported type NodeDataPage should have comment or be unexported
pkg/oracle_node_listener.go:203:2: var remotePeerId should be remotePeerID
pkg/api/api.go:12:6: exported type API should have comment or be unexported
pkg/api/handlers_data.go:31:6: exported type LLMChat should have comment or be unexported
pkg/api/handlers_data.go:40:1: exported function IsBase64 should have comment or be unexported
pkg/api/handlers_data.go:264:4: struct field Url should be URL
pkg/api/handlers_data.go:684:4: struct field Url should be URL
pkg/api/handlers_data.go:825:3: var cfUrl should be cfURL
pkg/api/handlers_data.go:862:1: exported method API.Test should have comment or be unexported
pkg/api/handlers_node.go:442:17: method GetNodeApiKey should be GetNodeAPIKey
pkg/chain/block.go:12:6: exported type Block should have comment or be unexported
pkg/chain/block.go:19:1: exported method Block.Build should have comment or be unexported
pkg/chain/block.go:27:1: exported method Block.Serialize should have comment or be unexported
pkg/chain/block.go:37:1: exported method Block.Deserialize should have comment or be unexported
pkg/chain/block.go:48:1: exported method Block.Print should have comment or be unexported
pkg/chain/chain.go:13:6: exported type Chain should have comment or be unexported
pkg/chain/chain.go:18:1: exported method Chain.Init should have comment or be unexported
pkg/chain/chain.go:43:1: exported method Chain.UpdateLastHash should have comment or be unexported
pkg/chain/chain.go:54:1: exported method Chain.AddBlock should have comment or be unexported
pkg/chain/chain.go:76:1: exported method Chain.IterateLink should have comment or be unexported
pkg/chain/chain.go:96:1: exported method Chain.GetLastBlock should have comment or be unexported
pkg/chain/chain.go:101:1: exported method Chain.GetBlock should have comment or be unexported
pkg/chain/persistance.go:9:2: exported const KeyLastHash should have comment (or a comment on this block) or be unexported
pkg/chain/persistance.go:12:6: exported type Persistance should have comment or be unexported
pkg/chain/persistance.go:16:6: exported type Serializable should have comment or be unexported
pkg/chain/persistance.go:21:1: exported method Persistance.Init should have comment or be unexported
pkg/chain/persistance.go:74:1: exported method Persistance.Get should have comment or be unexported
pkg/chain/persistance.go:96:1: exported method Persistance.GetLastHash should have comment or be unexported
pkg/chain/persistance.go:101:1: exported method Persistance.SaveBlock should have comment or be unexported
pkg/chain/persistance.go:123:1: exported method Persistance.Iterate should have comment or be unexported
pkg/chain/pos.go:16:6: exported type ProofOfStake should have comment or be unexported
pkg/chain/pos.go:44:1: exported method ProofOfStake.Run should have comment or be unexported
pkg/chain/pos.go:68:1: exported function IsValidPoS should have comment or be unexported
pkg/config/app.go:70:2: struct field RpcUrl should be RPCURL
pkg/config/app.go:72:2: struct field AllowedPeerId should be AllowedPeerID
pkg/config/app.go:87:2: struct field ClaudeApiKey should be ClaudeAPIKey
pkg/config/app.go:88:2: struct field ClaudeApiURL should be ClaudeAPIURL
pkg/config/app.go:89:2: struct field ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/app.go:95:2: struct field LLMChatUrl should be LLMChatURL
pkg/config/app.go:96:2: struct field LLMCfUrl should be LLMCfURL
pkg/config/app.go:176:7: struct field Id should be ID
pkg/config/constants.go:82:2: exported const PrivKeyFile should have comment (or a comment on this block) or be unexported
pkg/config/constants.go:85:2: const RpcUrl should be RPCURL
pkg/config/constants.go:117:2: const ClaudeApiKey should be ClaudeAPIKey
pkg/config/constants.go:118:2: const ClaudeApiURL should be ClaudeAPIURL
pkg/config/constants.go:119:2: const ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/constants.go:125:2: const LlmChatUrl should be LlmChatURL
pkg/config/constants.go:126:2: const LlmCfUrl should be LlmCfURL
pkg/config/constants.go:147:1: comment on exported function GetCloudflareModels should be of the form "GetCloudflareModels ..."
pkg/config/welcome.go:7:1: exported function DisplayWelcomeMessage should have comment or be unexported
pkg/consensus/pow.go:20:1: exported function GeneratePoW should have comment or be unexported
pkg/consensus/pow.go:20:18: func parameter peerId should be peerID
pkg/consensus/pow.go:42:1: exported function ComputeProofOfWork should have comment or be unexported
pkg/consensus/pow.go:42:25: func parameter peerId should be peerID
pkg/consensus/signer.go:20:1: exported function GenerateJWTToken should have comment or be unexported
pkg/consensus/signer.go:20:23: func parameter peerId should be peerID
pkg/db/operations.go:13:6: exported type WorkEvent should have comment or be unexported
pkg/db/operations.go:15:2: struct field PeerId should be PeerID
pkg/db/resolver_cache.go:26:6: exported type Record should have comment or be unexported
pkg/db/resolver_cache.go:74:9: if block ends with a return statement, so drop this else and outdent its block
pkg/db/resolver_cache.go:115:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/client.go:18:6: exported type ClaudeClient should have comment or be unexported
pkg/llmbridge/client.go:22:6: exported type GPTClient should have comment or be unexported
pkg/llmbridge/client.go:54:1: exported method GPTClient.SendRequest should have comment or be unexported
pkg/llmbridge/client.go:96:6: exported type Response should have comment or be unexported
pkg/llmbridge/client.go:107:6: exported type ResponseContent should have comment or be unexported
pkg/llmbridge/client.go:113:6: exported type ResponseError should have comment or be unexported
pkg/llmbridge/client.go:118:6: exported type Usage should have comment or be unexported
pkg/llmbridge/config.go:5:6: exported type ClaudeAPIConfig should have comment or be unexported
pkg/llmbridge/config.go:11:6: exported type GPTAPIConfig should have comment or be unexported
pkg/llmbridge/payload.go:7:6: exported type Payload should have comment or be unexported
pkg/llmbridge/payload.go:15:6: exported type Message should have comment or be unexported
pkg/llmbridge/payload.go:20:6: exported type Content should have comment or be unexported
pkg/llmbridge/sentiment.go:157:3: var cfUrl should be cfURL
pkg/llmbridge/sentiment.go:258:9: if block ends with a return statement, so drop this else and outdent its block
pkg/masacrypto/keys.go:135:1: exported function Libp2pPubKeyToEthAddress should have comment or be unexported
pkg/network/address.go:16:1: exported function GetMultiAddressesForHost should have comment or be unexported
pkg/network/address.go:37:1: exported function GetMultiAddressesForHostQuiet should have comment or be unexported
pkg/network/address.go:45:1: exported function GetPriorityAddress should have comment or be unexported
pkg/network/address.go:156:1: exported function GetBootNodesMultiAddress should have comment or be unexported
pkg/network/events.go:7:6: exported type PeerEvent should have comment or be unexported
pkg/network/kdht.go:23:2: exported const PeerAdded should have comment (or a comment on this block) or be unexported
pkg/network/kdht.go:32:1: exported function WithDht should have comment or be unexported
pkg/network/kdht.go:33:2: func parameter protocolId should be protocolID
pkg/network/mdns.go:9:7: exported const PeerFound should have comment or be unexported
pkg/network/mdns.go:27:1: exported function WithMDNS should have comment or be unexported
pkg/pubsub/block_tracker.go:11:6: exported type Blocks should have comment or be unexported
pkg/pubsub/manager.go:22:6: exported type Manager should have comment or be unexported
pkg/pubsub/node_data.go:20:2: exported const ActivityJoined should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_data.go:24:6: exported type JSONMultiaddr should have comment or be unexported
pkg/pubsub/node_data.go:47:6: exported type NodeData should have comment or be unexported
pkg/pubsub/node_data.go:49:2: struct field PeerId should be PeerID
pkg/pubsub/node_data.go:74:44: func parameter peerId should be peerID
pkg/pubsub/node_data.go:233:6: func GetSelfNodeDataJson should be GetSelfNodeDataJSON
pkg/pubsub/node_event_tracker.go:21:6: exported type NodeEventTracker should have comment or be unexported
pkg/pubsub/node_event_tracker.go:28:6: exported type ConnectBufferEntry should have comment or be unexported
pkg/pubsub/node_event_tracker.go:86:9: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:183:10: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/public_key_topic.go:23:6: exported type PublicKeyPublisher should have comment or be unexported
pkg/pubsub/public_key_topic.go:185:1: comment on exported method PublicKeyPublisher.GetPublishedMessages should be of the form "GetPublishedMessages ..."
pkg/pubsub/response_channel_map.go:5:6: exported type ResponseChannelMap should have comment or be unexported
pkg/pubsub/response_channel_map.go:60:1: exported method ResponseChannelMap.CreateChannel should have comment or be unexported
pkg/pubsub/safe_map.go:12:6: exported type SafeMap should have comment or be unexported
pkg/pubsub/worker_tracker.go:11:6: exported type Workers should have comment or be unexported
pkg/scrapers/discord/discordprofile.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/exchangetoken.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getchannelmessages.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getguildchannels.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getuserguilds.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/reddit/reddit.go:5:1: exported function TestReddit should have comment or be unexported
pkg/scrapers/twitter/auth.go:41:1: exported function IsLoggedIn should have comment or be unexported
pkg/scrapers/twitter/auth.go:45:1: exported function Logout should have comment or be unexported
pkg/scrapers/twitter/cookies.go:12:1: exported function SaveCookies should have comment or be unexported
pkg/scrapers/twitter/cookies.go:25:1: exported function LoadCookies should have comment or be unexported
pkg/scrapers/twitter/followers.go:7:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:8:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/staking/abi.go:13:2: exported const MasaTokenABIPath should have comment (or a comment on this block) or be unexported
pkg/staking/abi.go:18:6: exported type ContractAddresses should have comment or be unexported
pkg/staking/contracts.go:13:5: exported var MasaTokenAddress should have comment or be unexported
pkg/staking/contracts.go:14:5: exported var ProtocolStakingContractAddress should have comment or be unexported
pkg/staking/contracts.go:16:6: exported type Client should have comment or be unexported
pkg/staking/faucet.go:10:1: exported method Client.RunFaucet should have comment or be unexported
pkg/workers/client.go:16:2: exported const GET should have comment (or a comment on this block) or be unexported
pkg/workers/client.go:38:1: exported function Get should have comment or be unexported
pkg/workers/client.go:42:1: exported function Post should have comment or be unexported
pkg/workers/client.go:46:1: exported function Put should have comment or be unexported
pkg/workers/client.go:50:1: exported function Patch should have comment or be unexported
pkg/workers/client.go:88:10: if block ends with a return statement, so drop this else and outdent its block
pkg/workers/handler.go:19:6: exported type LLMChatBody should have comment or be unexported
pkg/workers/workers.go:30:6: exported type WorkerType should have comment or be unexported
pkg/workers/workers.go:33:2: exported const Discord should have comment (or a comment on this block) or be unexported
pkg/workers/workers.go:50:5: exported var WORKER should have comment or be unexported
pkg/workers/workers.go:76:6: exported type CID should have comment or be unexported
pkg/workers/workers.go:78:2: struct field RecordId should be RecordID
pkg/workers/workers.go:82:6: exported type Record should have comment or be unexported
pkg/workers/workers.go:83:2: struct field PeerId should be PeerID
pkg/workers/workers.go:87:6: exported type ChanResponse should have comment or be unexported
pkg/workers/workers.go:89:2: struct field ChannelId should be ChannelID
pkg/workers/workers.go:92:6: exported type Worker should have comment or be unexported
tests/node_listener.go:29:6: exported type NodeListener should have comment or be unexported
tests/node_listener.go:32:2: struct field ServerId should be ServerID
tests/node_listener.go:37:1: exported function NewNodeListener should have comment or be unexported
tests/node_listener.go:55:1: exported method NodeListener.Start should have comment or be unexported
tools/abigen_helper.go:14:6: exported type Contract should have comment or be unexported
tools/abigen_helper.go:19:1: exported function AbiGen should have comment or be unexported
tools/abigen_helper.go:56:1: exported function AbiGenBindings should have comment or be unexported

Copy link

⚠ shadow failed (.)

malformed import path "{sec:": invalid char '{'
malformed import path "-exclude=G104}": leading dash

Copy link

⚠ staticcheck failed (.)

-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping. (compile)
-: malformed import path "-exclude=G104}": leading dash (compile)
-: malformed import path "{sec:": invalid char '{' (compile)
pkg/scrapers/web/web.go:189:4: empty branch (SA9003)
pkg/staking/abi.go:6:2: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)
tests/node_listener.go:137:2: this value of err is never used (SA4006)

Checks Document

Copy link

⚠ gosec failed (.)

2024/07/12 08:17:28 internal error: package "encoding/json" without types was imported from "command-line-arguments"
Show Detail
2024/07/12 08:17:28 internal error: package "encoding/json" without types was imported from "command-line-arguments"

Code Reference

Copy link

  • imports: fail\n- [ ] errcheck: fail\n- [ ] lint: fail\n- [ ] shadow: fail\n- [ ] staticcheck: fail\n- [ ] sec: fail\n

@mudler
Copy link
Contributor Author

mudler commented Jul 12, 2024

Closing in favor of #417

@mudler mudler closed this Jul 12, 2024
@teslashibe teslashibe deleted the static-checker branch August 22, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant