Showing 1,971 of 13,422 total issues
Function Run
has 5 return statements (exceeds 4 allowed). Open
Open
func Run(args []string, buildInfo config.BuildInfo) {
app := cli.NewApp()
app.Name = buildInfo.Name()
app.Version = buildInfo.Version()
app.Description = buildInfo.VersionString() + "This is used for copying files out of modules in order to export unused fields. This should only be used for unit testing"
Method Notary.Start
has 5 return statements (exceeds 4 allowed). Open
Open
func (n *Notary) Start(parentCtx context.Context) error {
g, ctx := errgroup.WithContext(parentCtx)
logger.Info("Starting the notary")
Method Executor.checkIfExecuted
has 5 return statements (exceeds 4 allowed). Open
Open
func (e Executor) checkIfExecuted(parentCtx context.Context, message types.Message) (_ bool, err error) {
ctx, span := e.handler.Tracer().Start(parentCtx, "checkIfExecuted", trace.WithAttributes(
attribute.Int(metrics.Origin, int(message.OriginDomain())),
attribute.Int(metrics.Destination, int(message.DestinationDomain())),
attribute.Int(metrics.Nonce, int(message.Nonce())),
Method Executor.verifyStateMerkleProof
has 5 return statements (exceeds 4 allowed). Open
Open
func (e Executor) verifyStateMerkleProof(parentCtx context.Context, state types.State) (_ bool, err error) {
stateRoot := state.Root()
root := common.BytesToHash(stateRoot[:]).String()
chainID := state.Origin()
Function NewNotary
has 5 return statements (exceeds 4 allowed). Open
Open
func NewNotary(ctx context.Context, cfg config.AgentConfig, omniRPCClient omnirpcClient.RPCClient, txDB db.NotaryDB, handler metrics.Handler) (_ Notary, err error) {
notary := Notary{
refreshInterval: time.Second * time.Duration(cfg.RefreshIntervalSeconds),
}
notary.domains = []domains.DomainClient{}
Method AgentsIntegrationSuite.TestAgentsE2E
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (u *AgentsIntegrationSuite) TestAgentsE2E() {
testDone := false
defer func() {
testDone = true
}()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method DeployManager.InitializeRemoteDeployedHarnessContracts
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *DeployManager) InitializeRemoteDeployedHarnessContracts(
ctx context.Context,
backend backends.SimulatedTestBackend,
bondingManagerHarnessAgentRoot [32]byte) error {
d.T().Helper()
Function main
has 5 return statements (exceeds 4 allowed). Open
Open
func main() {
fmt.Println("Enter Sending Chain URL (eg https://polygon-rpc.com, https://api.avax.network/ext/bc/C/rpc, https://optimism-mainnet.public.blastapi.io): ")
var sendingChainURL string
fmt.Scanln(&sendingChainURL)
Method Guard.handleSnapshot
has 5 return statements (exceeds 4 allowed). Open
Open
func (g Guard) handleSnapshot(ctx context.Context, snapshot types.Snapshot, data types.StateValidationData) error {
// Process each state in the snapshot.
for si, s := range snapshot.States() {
stateIndex, state := si, s
isSlashable, err := g.isStateSlashable(ctx, state)
Function NewMysqlStore
has 5 return statements (exceeds 4 allowed). Open
Open
func NewMysqlStore(parentCtx context.Context, dbURL string, handler metrics.Handler, skipMigrations bool) (_ *Store, err error) {
logger.Debug("creating mysql store")
ctx, span := handler.Tracer().Start(parentCtx, "start-mysql")
defer func() {
Method ExecutorSuite.TestSendManagerMessage
has 5 return statements (exceeds 4 allowed). Open
Open
func (e *ExecutorSuite) TestSendManagerMessage() {
// This test requires a call to anvil's evm.IncreaseTime() cheat code, so we should
// set up the backends with anvil.
testDone := false
Function DecodeTokenID
has 5 return statements (exceeds 4 allowed). Open
Open
func DecodeTokenID(id string) (chainID int, addr common.Address, err error) {
// defensive coding, first check if the token ID is valid
_, err = SanitizeTokenID(id)
if err != nil {
return chainID, addr, err
Method Config.GetMaxRelayAmount
has 5 return statements (exceeds 4 allowed). Open
Open
func (c Config) GetMaxRelayAmount(chainID int, addr common.Address) *big.Int {
chainCfg, ok := c.Chains[chainID]
if !ok {
return defaultMaxRelayAmount
}
Method rebalanceManagerSynapseCCTP.Start
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerSynapseCCTP) Start(ctx context.Context) (err error) {
err = c.initContracts(ctx)
if err != nil {
return fmt.Errorf("could not initialize contracts: %w", err)
}
Method Manager.generateQuotes
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *Manager) generateQuotes(parentCtx context.Context, chainID int, address common.Address, balance *big.Int, inv map[int]map[common.Address]*big.Int) (quotes []model.PutRelayerQuoteRequest, err error) {
ctx, span := m.metricsHandler.Tracer().Start(parentCtx, "generateQuotes", trace.WithAttributes(
attribute.Int(metrics.Origin, chainID),
attribute.String("address", address.String()),
attribute.String("balance", balance.String()),
Method Manager.recordQuoteAmounts
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *Manager) recordQuoteAmounts(_ context.Context, observer metric.Observer) (err error) {
if m.meter == nil || m.quoteAmountGauge == nil || m.currentQuotes == nil {
return nil
}
Method DeployManager.LoadContractsOnChains
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *DeployManager) LoadContractsOnChains(
ctx context.Context,
synChainBackend backends.SimulatedTestBackend,
backends []backends.SimulatedTestBackend,
agents []common.Address,
Method rpcClient.GetChainIDs
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *rpcClient) GetChainIDs(ctx context.Context) (chainIDs []int, err error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/chain-ids", c.endpoint), nil)
if err != nil {
return nil, fmt.Errorf("could not create request: %w", err)
}
Method Config.GetMaxBalance
has 5 return statements (exceeds 4 allowed). Open
Open
func (c Config) GetMaxBalance(chainID int, addr common.Address) *big.Int {
chainCfg, ok := c.Chains[chainID]
if !ok {
return defaultMaxBalance
}
Method Manager.IsProfitable
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *Manager) IsProfitable(parentCtx context.Context, quote reldb.QuoteRequest) (isProfitable bool, err error) {
ctx, span := m.metricsHandler.Tracer().Start(parentCtx, "IsProfitable")
defer func() {
span.AddEvent("result", trace.WithAttributes(attribute.Bool("result", isProfitable)))