Showing 1,971 of 13,422 total issues
Function sortInfoList
has 5 return statements (exceeds 4 allowed). Open
Open
func sortInfoList(rpcInfoList []rpcinfo.Result) []rpcinfo.Result {
sort.Slice(rpcInfoList, func(i, j int) bool {
// ignore latencies with an error
if rpcInfoList[i].HasError {
return false
Function getLatency
has 5 return statements (exceeds 4 allowed). Open
Open
func getLatency(ctx context.Context, rpcURL string, handler metrics.Handler) (l Result) {
l = Result{URL: rpcURL, HasError: true}
parsedURL, err := url.Parse(rpcURL)
if err != nil {
Method Config.GetMinQuoteAmount
has 5 return statements (exceeds 4 allowed). Open
Open
func (c Config) GetMinQuoteAmount(chainID int, addr common.Address) *big.Int {
chainCfg, ok := c.Chains[chainID]
if !ok {
return big.NewInt(defaultMinQuoteAmount)
}
Method Config.GetScrollMessageFee
has 5 return statements (exceeds 4 allowed). Open
Open
func (c Config) GetScrollMessageFee(chainID int) (value *big.Int, err error) {
chainCfg, ok := c.Chains[chainID]
if !ok {
return value, fmt.Errorf("no chain config for chain %d", chainID)
}
Method clientImpl.processWebsocket
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *clientImpl) processWebsocket(ctx context.Context, conn *websocket.Conn, reqChan, respChan chan *model.ActiveRFQMessage) (err error) {
defer func() {
close(respChan)
err := conn.Close()
if err != nil {
Method Chain.SubmitRelay
has 5 return statements (exceeds 4 allowed). Open
Open
func (c Chain) SubmitRelay(ctx context.Context, request reldb.QuoteRequest) (uint64, *big.Int, error) {
gasAmount := big.NewInt(0)
var err error
// Check to see if ETH should be sent to destination
Method receiptsProxyImpl.processRequest
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *receiptsProxyImpl) processRequest(ctx context.Context, rpcRequest rpc.Request, requestID []byte) (resp omniHTTP.Response, err error) {
ctx, span := r.handler.Tracer().Start(ctx, "proxyrequest")
defer func() {
metrics.EndSpanWithErr(span, err)
}()
Method Relayer.handleRelayLog
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *Relayer) handleRelayLog(parentCtx context.Context, req *fastbridge.FastBridgeBridgeRelayed) (err error) {
ctx, span := r.metrics.Tracer().Start(parentCtx, "handleRelayLog",
trace.WithAttributes(attribute.String("transaction_id", hexutil.Encode(req.TransactionId[:]))),
)
defer func() {
Method rebalanceManagerCircleCCTP.handleMessageReceived
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerCircleCCTP) handleMessageReceived(ctx context.Context, log types.Log, chainID int, ethClient client.EVM) (err error) {
ctx, span := c.handler.Tracer().Start(ctx, "rebalance.handleMessageReceived")
defer func(err error) {
metrics.EndSpanWithErr(span, err)
}(err)
Method Config.validateTokenDecimals
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c Config) validateTokenDecimals(ctx context.Context, omniClient omniClient.RPCClient) (err error) {
for chainID, chainCfg := range c.Chains {
for tokenName, tokenCFG := range chainCfg.Tokens {
chainClient, err := omniClient.GetChainClient(ctx, chainID)
if err != nil {
- 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 rebalanceManagerSynapseCCTP.initListeners
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerSynapseCCTP) initListeners(ctx context.Context) (err error) {
for chainID := range c.cfg.GetChains() {
cctpAddr, err := c.cfg.GetSynapseCCTPAddress(chainID)
if err != nil {
return fmt.Errorf("could not get cctp address: %w", err)
Function NewInventoryManager
has 5 return statements (exceeds 4 allowed). Open
Open
func NewInventoryManager(ctx context.Context, clientFetcher submitter.ClientFetcher, handler metrics.Handler, cfg relconfig.Config, relayer common.Address, txSubmitter submitter.TransactionSubmitter, db reldb.Service) (Manager, error) {
rebalanceMethods, err := cfg.GetAllRebalanceMethods()
if err != nil {
return nil, fmt.Errorf("could not get rebalance methods: %w", err)
}
Method Handler.ModifyQuote
has 5 return statements (exceeds 4 allowed). Open
Open
func (h *Handler) ModifyQuote(c *gin.Context) {
// Retrieve the request from context
req, exists := c.Get("putRequest")
if !exists {
c.JSON(http.StatusBadRequest, gin.H{"error": "Request not found"})
Method inventoryManagerImpl.tryExecuteRebalance
has 5 return statements (exceeds 4 allowed). Open
Open
func (i *inventoryManagerImpl) tryExecuteRebalance(ctx context.Context, rebalance *RebalanceData) (err error) {
ctx, span := i.handler.Tracer().Start(ctx, "tryExecuteRebalance", trace.WithAttributes(
attribute.Int("origin", rebalance.OriginMetadata.ChainID),
attribute.Int("dest", rebalance.DestMetadata.ChainID),
attribute.String("origin_token", rebalance.OriginMetadata.Addr.Hex()),
Method executionContext._BlockHeight_blockNumber
has 5 return statements (exceeds 4 allowed). Open
Open
func (ec *executionContext) _BlockHeight_blockNumber(ctx context.Context, field graphql.CollectedField, obj *model.BlockHeight) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_BlockHeight_blockNumber(ctx, field)
if err != nil {
return graphql.Null
}
Method executionContext._DateResultByChain_canto
has 5 return statements (exceeds 4 allowed). Open
Open
func (ec *executionContext) _DateResultByChain_canto(ctx context.Context, field graphql.CollectedField, obj *model.DateResultByChain) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_DateResultByChain_canto(ctx, field)
if err != nil {
return graphql.Null
}
Method executionContext._HeroType_heroID
has 5 return statements (exceeds 4 allowed). Open
Open
func (ec *executionContext) _HeroType_heroID(ctx context.Context, field graphql.CollectedField, obj *model.HeroType) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_HeroType_heroID(ctx, field)
if err != nil {
return graphql.Null
}
Method executionContext._Leaderboard_volumeUSD
has 5 return statements (exceeds 4 allowed). Open
Open
func (ec *executionContext) _Leaderboard_volumeUSD(ctx context.Context, field graphql.CollectedField, obj *model.Leaderboard) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Leaderboard_volumeUSD(ctx, field)
if err != nil {
return graphql.Null
}
Method executionContext._PartialInfo_address
has 5 return statements (exceeds 4 allowed). Open
Open
func (ec *executionContext) _PartialInfo_address(ctx context.Context, field graphql.CollectedField, obj *model.PartialInfo) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_PartialInfo_address(ctx, field)
if err != nil {
return graphql.Null
}
Method executionContext._Query_leaderboard
has 5 return statements (exceeds 4 allowed). Open
Open
func (ec *executionContext) _Query_leaderboard(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Query_leaderboard(ctx, field)
if err != nil {
return graphql.Null
}