synapsecns/sanguine

View on GitHub

Showing 1,971 of 13,422 total issues

Method ChainIndexer.livefill has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
Open

func (c *ChainIndexer) livefill(parentContext context.Context) error {
    timeout := time.Duration(0)
    b := createBackoff()
    livefillBlockMeter, err := c.handler.Metrics().NewHistogram(fmt.Sprintf("scribe_block_meter_%d_livefill", c.chainConfig.ChainID), "block_histogram", "a block height meter", "blocks")
    if err != nil {
Severity: Minor
Found in services/scribe/service/chain.go - About 45 mins to fix

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

Function RegisterScribeServiceHandlerServer has 7 return statements (exceeds 4 allowed).
Open

func RegisterScribeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ScribeServiceServer) error {

    mux.Handle("POST", pattern_ScribeService_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
        ctx, cancel := context.WithCancel(req.Context())
        defer cancel()
Severity: Major
Found in services/scribe/grpc/types/types/v1/service.pb.gw.go - About 45 mins to fix

    Method executionContext.field_Query_transactions_args has 7 return statements (exceeds 4 allowed).
    Open

    func (ec *executionContext) field_Query_transactions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
        var err error
        args := map[string]interface{}{}
        var arg0 *string
        if tmp, ok := rawArgs["tx_hash"]; ok {
    Severity: Major
    Found in services/scribe/graphql/server/graph/resolver/server.go - About 45 mins to fix

      Method EventDB.StoreEthTx has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (_m *EventDB) StoreEthTx(ctx context.Context, tx *types.Transaction, chainID uint32, blockHash common.Hash, blockNumber uint64, transactionIndex uint64) error {
      Severity: Minor
      Found in services/scribe/db/mocks/event_db.go - About 45 mins to fix

        Function getLogs has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func getLogs(ctx context.Context, contractAddress string, fromBlock uint64, toBlock uint64, apiURL string, txs *map[int64]string) (int, error) {
        Severity: Minor
        Found in services/scribe/service/scribe_test.go - About 45 mins to fix

          Method Client.GetReceiptsRange has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func (c *Client) GetReceiptsRange(ctx context.Context, chainID int, startBlock int, endBlock int, page int, httpRequestOptions ...client.HTTPRequestOption) (*GetReceiptsRange, error) {
          Severity: Minor
          Found in services/scribe/graphql/client/client.go - About 45 mins to fix

            Method Client.GetTransactionsRange has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (c *Client) GetTransactionsRange(ctx context.Context, chainID int, startBlock int, endBlock int, page int, httpRequestOptions ...client.HTTPRequestOption) (*GetTransactionsRange, error) {
            Severity: Minor
            Found in services/scribe/graphql/client/client.go - About 45 mins to fix

              Function DumpWithOptions has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func DumpWithOptions(showReq bool, showResp bool, showBody bool, showHeaders bool, showCookies bool, cb func(dumpStr string)) gin.HandlerFunc {
              Severity: Minor
              Found in core/ginhelper/gindump.go - About 45 mins to fix

                Function StartLogs has 7 return statements (exceeds 4 allowed).
                Open

                func StartLogs(opts ...StdStreamLogArgsOption) (_ LogMetadata, err error) {
                    input, err := makeArgs(opts)
                    if err != nil {
                        return nil, err
                    }
                Severity: Major
                Found in core/processlog/logs.go - About 45 mins to fix

                  Method TestHelperSuite.TestEmbeddedScribe has 7 return statements (exceeds 4 allowed).
                  Open

                  func (s *TestHelperSuite) TestEmbeddedScribe() {
                      testScribe := testhelper.NewTestScribe(s.GetTestContext(), s.T(), s.deployManager.GetDeployedContracts(), s.testBackends...)
                  
                      // let's send some messages on each domain
                      g, gctx := errgroup.WithContext(s.GetTestContext())
                  Severity: Major
                  Found in services/scribe/testhelper/scribe_test.go - About 45 mins to fix

                    Function BuildReceiptFilter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func BuildReceiptFilter(txHash *string, contractAddress *string, blockHash *string, blockNumber *int, transactionIndex *int, confirmed *bool) ReceiptFilter {
                    Severity: Minor
                    Found in services/scribe/db/filter.go - About 45 mins to fix

                      Function PopulateChainsWithLogs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func PopulateChainsWithLogs(ctx context.Context, t *testing.T, chainBackends map[uint32]geth.Backend, desiredBlockHeight uint64, managers []*DeployManager, handler metrics.Handler) (map[uint32]*TestChainHandler, map[uint32][]backend.ScribeBackend, error) {
                      Severity: Minor
                      Found in services/scribe/testutil/utils.go - About 45 mins to fix

                        Method Client.GetLogsAtHeadRange has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func (c *Client) GetLogsAtHeadRange(ctx context.Context, chainID int, startBlock int, endBlock int, page int, httpRequestOptions ...client.HTTPRequestOption) (*GetLogsAtHeadRange, error) {
                        Severity: Minor
                        Found in services/scribe/graphql/client/client.go - About 45 mins to fix

                          Method EventDB.RetrieveUnconfirmedEthTxsFromHeadRangeQuery has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          func (_m *EventDB) RetrieveUnconfirmedEthTxsFromHeadRangeQuery(ctx context.Context, receiptFilter db.EthTxFilter, startBlock uint64, endBlock uint64, lastIndexed uint64, page int) ([]db.TxWithBlockNumber, error) {
                          Severity: Minor
                          Found in services/scribe/db/mocks/event_db.go - About 45 mins to fix

                            Method Store.RetrieveReceiptsFromHeadRangeQuery has 7 return statements (exceeds 4 allowed).
                            Open

                            func (s Store) RetrieveReceiptsFromHeadRangeQuery(ctx context.Context, receiptFilter db.ReceiptFilter, startBlock uint64, endBlock uint64, page int) ([]types.Receipt, error) {
                                if receiptFilter.ContractAddress == "" || receiptFilter.ChainID == 0 {
                                    return nil, fmt.Errorf("contract address and chain ID must be passed")
                                }
                                if page < 1 {
                            Severity: Major
                            Found in services/scribe/db/datastore/sql/base/athead.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      goto DumpRes
                              Severity: Major
                              Found in core/ginhelper/gindump.go - About 45 mins to fix

                                Method ChainIndexer.livefillAtHead has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func (c *ChainIndexer) livefillAtHead(parentContext context.Context) error {
                                    timeout := time.Duration(0)
                                    b := createBackoff()
                                    addresses := getAddressesFromConfig(c.chainConfig.Contracts)
                                    tipLivefillBlockMeter, err := c.handler.Metrics().NewHistogram(fmt.Sprintf("scribe_block_meter_%d_tip_livefill", c.chainConfig.ChainID), "block_histogram", "a block height meter", "blocks")
                                Severity: Minor
                                Found in services/scribe/service/chain.go - About 45 mins to fix

                                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

                                Avoid deeply nested control flow statements.
                                Open

                                                        goto DumpRes
                                Severity: Major
                                Found in core/ginhelper/gindump.go - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if err != nil {
                                                              logger.ReportIndexerError(err, x.indexerConfig, logger.StoreError)
                                                              return fmt.Errorf("could not store last indexed: %w", err)
                                                          }
                                  Severity: Major
                                  Found in services/scribe/service/indexer/indexer.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            goto DumpRes
                                    Severity: Major
                                    Found in core/ginhelper/gindump.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language