XYOracleNetwork/sdk-diviner-nodejs

View on GitHub

Showing 28 of 64 total issues

Function createTableIfNeeded has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async createTableIfNeeded() {
    return new Promise((resolve, reject) => {
      try {
        this.dynamodb.listTables(async (listErr, listData) => {
          if (listErr) {
Severity: Minor
Found in src/payment/repository/dynammodb/table.ts - About 1 hr to fix

    Function getBlocksDown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      public async getBlocksDown(
        hash: Buffer,
        n: number,
        publicKey: Buffer
      ): Promise<Buffer[]> {
    Severity: Minor
    Found in src/chain/xyo-hash-tracer.ts - About 55 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 checkIfExceedFreeLimit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private checkIfExceedFreeLimit(config: any) {
        if (config.select) {
          if (config.select.config) {
            if (
              config.select.config.limit &&
    Severity: Minor
    Found in src/query/auth/xyo-query-auth.ts - About 55 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 getLastIntersection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      public async getLastIntersection(
        on: Buffer,
        withKeys: Buffer[],
        startingIndex: number
      ): Promise<Buffer | undefined> {
    Severity: Minor
    Found in src/chain/xyo-chain-intersection.ts - 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

                if (publicKeyLooking.equals(publicKey.getAll().getContentsCopy())) {
                  return origin.nextPublicKey
                }
    Severity: Major
    Found in src/chain/xyo-public-key-tracer.ts - About 45 mins to fix

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

        private async getLastIndex(publicKey: Buffer) {
          const latestBlocks = await this.tracer.traceChain(publicKey, 1, -1, false)
      
          if (latestBlocks.length !== 1) {
            return 100
      Severity: Minor
      Found in src/chain/xyo-chain-intersection.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
      Severity: Major
      Found in src/payment/eth/xyo-eth-payment.ts - About 30 mins to fix

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

          private getLocation(boundWitness: Buffer): any {
            const block = new XyoBoundWitness(boundWitness)
        
            for (const set of block.getHeuristics()) {
              for (const h of set) {
        Severity: Minor
        Found in src/query/mutators/location.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

        Severity
        Category
        Status
        Source
        Language