synapsecns/sanguine

View on GitHub
services/scribe/db/datastore/sql/base/athead.go

Summary

Maintainability
D
1 day
Test Coverage

Method Store.StoreLogsAtHead has 53 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s Store) StoreLogsAtHead(ctx context.Context, chainID uint32, logs ...types.Log) error {
    var storeLogs []LogAtHead
    for _, log := range logs {
        var topics []sql.NullString

Severity: Minor
Found in services/scribe/db/datastore/sql/base/athead.go - About 1 hr 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

      Method Store.StoreEthTxAtHead has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (s Store) StoreEthTxAtHead(ctx context.Context, tx *types.Transaction, chainID uint32, blockHash common.Hash, blockNumber uint64, transactionIndex uint64) error {
      Severity: Minor
      Found in services/scribe/db/datastore/sql/base/athead.go - About 45 mins to fix

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

        func (s Store) RetrieveUnconfirmedEthTxsFromHeadRangeQuery(ctx context.Context, ethTxFilter db.EthTxFilter, startBlock uint64, endBlock uint64, lastIndexed uint64, page int) ([]db.TxWithBlockNumber, error) {
        Severity: Minor
        Found in services/scribe/db/datastore/sql/base/athead.go - About 45 mins to fix

          Method Store.RetrieveLogsFromHeadRangeQuery has 6 return statements (exceeds 4 allowed).
          Open

          func (s Store) RetrieveLogsFromHeadRangeQuery(ctx context.Context, logFilter db.LogFilter, startBlock uint64, endBlock uint64, page int) ([]*types.Log, error) {
              if logFilter.ContractAddress == "" || logFilter.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 40 mins to fix

            Method Store.RetrieveUnconfirmedEthTxsFromHeadRangeQuery has 6 return statements (exceeds 4 allowed).
            Open

            func (s Store) RetrieveUnconfirmedEthTxsFromHeadRangeQuery(ctx context.Context, ethTxFilter db.EthTxFilter, startBlock uint64, endBlock uint64, lastIndexed uint64, page int) ([]db.TxWithBlockNumber, error) {
                if ethTxFilter.ChainID == 0 {
                    return nil, fmt.Errorf("chain ID must be passed")
                }
                if page < 1 {
            Severity: Major
            Found in services/scribe/db/datastore/sql/base/athead.go - About 40 mins to fix

              Method Store.RetrieveReceiptsFromHeadRangeQuery has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (s Store) RetrieveReceiptsFromHeadRangeQuery(ctx context.Context, receiptFilter db.ReceiptFilter, startBlock uint64, endBlock uint64, page int) ([]types.Receipt, error) {
              Severity: Minor
              Found in services/scribe/db/datastore/sql/base/athead.go - About 35 mins to fix

                Method Store.RetrieveLogsFromHeadRangeQuery has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func (s Store) RetrieveLogsFromHeadRangeQuery(ctx context.Context, logFilter db.LogFilter, startBlock uint64, endBlock uint64, page int) ([]*types.Log, error) {
                Severity: Minor
                Found in services/scribe/db/datastore/sql/base/athead.go - About 35 mins to fix

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      if s.db.Dialector.Name() == dbcommon.Sqlite.String() {
                          dbTx = dbTx.Clauses(clause.OnConflict{
                              Columns: []clause.Column{
                                  {Name: ContractAddressFieldName}, {Name: ChainIDFieldName}, {Name: TxHashFieldName}, {Name: BlockIndexFieldName},
                              },
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 1 other location - About 1 hr to fix
                  services/scribe/db/datastore/sql/base/log.go on lines 63..74

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 150.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 4 locations. Consider refactoring.
                  Open

                      if s.DB().Dialector.Name() == dbcommon.Sqlite.String() {
                          dbTx = dbTx.Clauses(clause.OnConflict{
                              Columns:   []clause.Column{{Name: TxHashFieldName}, {Name: ChainIDFieldName}},
                              DoNothing: true,
                          })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 3 other locations - About 45 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 129..138
                  services/scribe/db/datastore/sql/base/receipt.go on lines 20..29
                  services/scribe/db/datastore/sql/base/transaction.go on lines 22..31

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 117.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 4 locations. Consider refactoring.
                  Open

                      if s.DB().Dialector.Name() == dbcommon.Sqlite.String() {
                          dbTx = dbTx.Clauses(clause.OnConflict{
                              Columns:   []clause.Column{{Name: TxHashFieldName}, {Name: ChainIDFieldName}},
                              DoNothing: true,
                          })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 3 other locations - About 45 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 88..97
                  services/scribe/db/datastore/sql/base/receipt.go on lines 20..29
                  services/scribe/db/datastore/sql/base/transaction.go on lines 22..31

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 117.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      subQuery2 := s.DB().WithContext(ctx).ToSQL(func(tx *gorm.DB) *gorm.DB {
                          return tx.Model(ReceiptAtHead{}).Select(ReceiptColumns).Where("block_number BETWEEN ? AND ?", lastIndexed+1, endBlock).Where(queryFilter).Find(&[]Receipt{})
                      })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 2 other locations - About 45 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 178..180
                  services/scribe/db/datastore/sql/base/athead.go on lines 243..245

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 115.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      subQuery2 := s.DB().WithContext(ctx).ToSQL(func(tx *gorm.DB) *gorm.DB {
                          return tx.Model(EthTxAtHead{}).Select(EthTxColumns).Where("block_number BETWEEN ? AND ?", lastIndexed+1, endBlock).Where(queryFilter).Find(&[]EthTx{})
                      })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 2 other locations - About 45 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 178..180
                  services/scribe/db/datastore/sql/base/athead.go on lines 209..211

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 115.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      subQuery2 := s.DB().WithContext(ctx).ToSQL(func(tx *gorm.DB) *gorm.DB {
                          return tx.Model(LogAtHead{}).Select(LogColumns).Where("block_number BETWEEN ? AND ?", lastIndexed+1, endBlock).Where(queryFilter).Find(&[]Log{})
                      })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 2 other locations - About 45 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 209..211
                  services/scribe/db/datastore/sql/base/athead.go on lines 243..245

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 115.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      subQuery1 := s.DB().WithContext(ctx).ToSQL(func(tx *gorm.DB) *gorm.DB {
                          return tx.Model(EthTx{}).Select("*").Where("block_number BETWEEN ? AND ?", startBlock, lastIndexed).Where(queryFilter).Find(&[]EthTx{})
                      })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 2 other locations - About 40 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 175..177
                  services/scribe/db/datastore/sql/base/athead.go on lines 206..208

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 111.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      subQuery1 := s.DB().WithContext(ctx).ToSQL(func(tx *gorm.DB) *gorm.DB {
                          return tx.Model(Receipt{}).Select("*").Where("block_number BETWEEN ? AND ?", startBlock, lastIndexed).Where(queryFilter).Find(&[]Receipt{})
                      })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 2 other locations - About 40 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 175..177
                  services/scribe/db/datastore/sql/base/athead.go on lines 240..242

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 111.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      subQuery1 := s.DB().WithContext(ctx).ToSQL(func(tx *gorm.DB) *gorm.DB {
                          return tx.Model(Log{}).Select("*").Where("block_number BETWEEN ? AND ?", startBlock, lastIndexed).Where(queryFilter).Find(&[]Log{})
                      })
                  Severity: Major
                  Found in services/scribe/db/datastore/sql/base/athead.go and 2 other locations - About 40 mins to fix
                  services/scribe/db/datastore/sql/base/athead.go on lines 206..208
                  services/scribe/db/datastore/sql/base/athead.go on lines 240..242

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 111.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                          for index := 0; index <= indexedTopics+1; index++ {
                              if index < topicsLength {
                                  topics = append(topics, sql.NullString{
                                      String: log.Topics[index].String(),
                                      Valid:  true,
                  Severity: Minor
                  Found in services/scribe/db/datastore/sql/base/athead.go and 1 other location - About 30 mins to fix
                  services/scribe/db/datastore/sql/base/log.go on lines 29..40

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 100.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  There are no issues that match your filters.

                  Category
                  Status