synapsecns/sanguine

View on GitHub
packages/rfq-indexer/api/src/graphql/resolvers.ts

Summary

Maintainability
F
1 wk
Test Coverage

File resolvers.ts has 492 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { sql } from 'kysely'

import { db } from '../db'

// typical fields to return for a BridgeRequest
Severity: Minor
Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 7 hrs to fix

    Function nest_results has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    const nest_results = (sqlResults: any[]) => {
      return sqlResults.map((transaction: any) => {
        const bridgeRequest: { [key: string]: any } = {}
        const bridgeRelay: { [key: string]: any } = {}
        const bridgeProof: { [key: string]: any } = {}
    Severity: Minor
    Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 4 hrs 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 nest_results has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const nest_results = (sqlResults: any[]) => {
      return sqlResults.map((transaction: any) => {
        const bridgeRequest: { [key: string]: any } = {}
        const bridgeRelay: { [key: string]: any } = {}
        const bridgeProof: { [key: string]: any } = {}
    Severity: Major
    Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 2 hrs to fix

      Function recentInvalidRelays has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          recentInvalidRelays: async () => {
            const query = db
              .selectFrom('BridgeRelayedEvents')
              .leftJoin(
                'BridgeRequestEvents',
      Severity: Minor
      Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 1 hr to fix

        Function pendingTransactionsMissingRelay has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            pendingTransactionsMissingRelay: async () => {
              const query = db
                .with('deposits', () => qDeposits())
                .with('relays', () => qRelays())
                .with('refunds', () => qRefunds())
        Severity: Minor
        Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 1 hr to fix

          Function events has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              events: async (
                _: any,
                { first = 10, after, filter }: { first?: any; after?: any; filter?: any }
              ) => {
                let query = db
          Severity: Minor
          Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 35 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 too many return statements within this function.
          Open

                  return 'BridgeDepositClaimedEvent'
          Severity: Major
          Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return null
            Severity: Major
            Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 30 mins to fix

              Function __resolveType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  __resolveType(obj: any) {
                    // Implement logic to determine the event type based on the object properties
                    // For example:
                    if ('sender' in obj) {
                      return 'BridgeRequestEvent'
              Severity: Minor
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - About 25 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

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

              const nest_results = (sqlResults: any[]) => {
                return sqlResults.map((transaction: any) => {
                  const bridgeRequest: { [key: string]: any } = {}
                  const bridgeRelay: { [key: string]: any } = {}
                  const bridgeProof: { [key: string]: any } = {}
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 4 days to fix
              packages/rfq-indexer/api/src/utils/nestResults.ts on lines 1..58

              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 734.

              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

                    const query = db
                      .with('deposits', () => qDeposits())
                      .with('relays', () => qRelays())
                      .with('refunds', () => qRefunds())
                      .with('combined', (qb) =>
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 5 hrs to fix
              packages/rfq-indexer/api/src/controllers/refundedAndRelayedController.ts on lines 12..27

              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 141.

              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 2 locations. Consider refactoring.
              Open

                    const query = db
                      .selectFrom('BridgeRelayedEvents')
                      .leftJoin(
                        'BridgeRequestEvents',
                        'BridgeRelayedEvents.transactionId',
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 3 hrs to fix
              packages/rfq-indexer/api/src/controllers/invalidRelaysController.ts on lines 10..39

              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 110.

              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

                      return Object.fromEntries(
                        Object.entries(nestedResult).filter(([_, value]) => {
                          if (value === null) {
                            return false
                          }
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 2 hrs to fix
              packages/rfq-indexer/api/src/controllers/transactionIdController.ts on lines 58..68

              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 91.

              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

                    const query = db
                      .with('deposits', () => qDeposits())
                      .with('relays', () => qRelays())
                      .with('proofs', () => qProofs())
                      .with('claims', () => qClaims())
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 2 hrs to fix
              packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts on lines 14..29

              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 79.

              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 2 locations. Consider refactoring.
              Open

                    const query = db
                      .with('deposits', () => qDeposits())
                      .with('relays', () => qRelays())
                      .with('proofs', () => qProofs())
                      .with('disputes', () => qDisputes())
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 1 hr to fix
              packages/rfq-indexer/api/src/graphql/resolvers.ts on lines 336..351

              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 66.

              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

                    const query = db
                      .with('deposits', () => qDeposits())
                      .with('relays', () => qRelays())
                      .with('proofs', () => qProofs())
                      .with('combined', (qb) =>
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 1 hr to fix
              packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts on lines 55..67

              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 61.

              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 2 locations. Consider refactoring.
              Open

              const qDeposits = () => {
                return db
                  .selectFrom('BridgeRequestEvents')
                  .select([
                    'BridgeRequestEvents.transactionId as transactionId_deposit',
              Severity: Major
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 1 hr to fix
              packages/rfq-indexer/api/src/queries/depositsQueries.ts on lines 3..27

              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 60.

              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 2 locations. Consider refactoring.
              Open

                        qb
                          .selectFrom('deposits')
                          .leftJoin('relays', 'transactionId_deposit', 'transactionId_relay')
                          .leftJoin('proofs', 'transactionId_deposit', 'transactionId_proof')
                          .leftJoin('claims', 'transactionId_deposit', 'transactionId_claim')
              Severity: Minor
              Found in packages/rfq-indexer/api/src/graphql/resolvers.ts and 1 other location - About 55 mins to fix
              packages/rfq-indexer/api/src/controllers/transactionIdController.ts on lines 33..43

              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 54.

              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