XYOracleNetwork/sdk-core-nodejs

View on GitHub

Showing 20 of 49 total issues

Function validate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  public validate(
    boundWitness: XyoBoundWitness,
    allowUnknownSignatures: boolean
  ): boolean {
    const signingData = boundWitness.getSigningData()
Severity: Minor
Found in src/bound-witness/xyo-bound-witness-validator.ts - About 2 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 waitForMessage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private waitForMessage(): Promise<Buffer> {
    return new Promise((resolve, reject) => {
      let hasResumed = false
      let waitSize: number
      let currentSize = 0
Severity: Minor
Found in src/network/tcp/xyo-tcp-pipe.ts - About 1 hr to fix

    Function connectionListener has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private connectionListener(socket: net.Socket) {
        this.logInfo(
          `New connection made with ${socket.remoteAddress}:${socket.remotePort}`
        )
    
    
    Severity: Minor
    Found in src/network/tcp/xyo-tcp-server-network.ts - About 1 hr to fix

      Function getOriginInformationFromFetter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        private static getOriginInformationFromFetter(
          fetterHeuristics: XyoStructure[]
        ): IXyoBoundWitnessOrigin {
          let nextPublicKey: Buffer | undefined
          let previousHash: Buffer | undefined
      Severity: Minor
      Found in src/heuristics/xyo-bound-witness-origin.ts - About 1 hr 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 boundWitness has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public async boundWitness(
          handler: XyoNetworkHandler,
          catalogue: XyoProcedureCatalog,
          signers: XyoSigner[]
        ): Promise<XyoBoundWitness | undefined> {
      Severity: Minor
      Found in src/bound-witness/xyo-zig-zag-bound-witness-handler.ts - About 1 hr to fix

        Function validate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public validate(
            boundWitness: XyoBoundWitness,
            allowUnknownSignatures: boolean
          ): boolean {
            const signingData = boundWitness.getSigningData()
        Severity: Minor
        Found in src/bound-witness/xyo-bound-witness-validator.ts - About 1 hr to fix

          Function createBlockfromJson has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public createBlockfromJson(boundWitness: {
              [key: string]: any
            }): XyoZigZagBoundWitness | undefined {
              const allKeys = Object.keys(boundWitness)
              if (allKeys.length > 2 || allKeys.length === 0) {
          Severity: Minor
          Found in src/simulation/index.ts - About 1 hr to fix

            Function insert has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public async insert(boundWitness: XyoBoundWitness) {
                const bridgeBlocks = this.getNestedObjectType(
                  boundWitness,
                  XyoObjectSchema.WITNESS,
                  XyoObjectSchema.BRIDGE_BLOCK_SET
            Severity: Minor
            Found in src/origin/xyo-bound-witness-inserter.ts - About 1 hr to fix

              Function removeBridgeBlocks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                private removeBridgeBlocks(
                  boundWitness: XyoBoundWitness
                ): XyoIterableStructure {
                  const newLedgerItems: XyoStructure[] = []
                  const it = boundWitness.newIterator()
              Severity: Minor
              Found in src/origin/xyo-bound-witness-inserter.ts - About 1 hr 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 getNestedObjectType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                private getNestedObjectType(
                  boundWitness: XyoBoundWitness,
                  rootSchema: XyoSchema,
                  subSchema: XyoSchema
                ): XyoStructure | undefined {
              Severity: Minor
              Found in src/origin/xyo-bound-witness-inserter.ts - About 1 hr 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 removeBridgeBlocks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private removeBridgeBlocks(
                  boundWitness: XyoBoundWitness
                ): XyoIterableStructure {
                  const newLedgerItems: XyoStructure[] = []
                  const it = boundWitness.newIterator()
              Severity: Minor
              Found in src/origin/xyo-bound-witness-inserter.ts - About 1 hr to fix

                Function getOriginInformationFromFetter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private static getOriginInformationFromFetter(
                    fetterHeuristics: XyoStructure[]
                  ): IXyoBoundWitnessOrigin {
                    let nextPublicKey: Buffer | undefined
                    let previousHash: Buffer | undefined
                Severity: Minor
                Found in src/heuristics/xyo-bound-witness-origin.ts - About 1 hr to fix

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

                    public static encode(schema: XyoSchema, value: XyoBuffer): XyoBuffer {
                      const bestSize = XyoSizeUtil.getBestSize(value.getSize())
                      const header = Buffer.alloc(2 + bestSize.valueOf())
                      const size = value.getSize() + bestSize.valueOf()
                      const optimizedSchema = XyoSchema.create(
                  Severity: Minor
                  Found in src/object-model/xyo-structure.ts - About 1 hr to fix

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

                      private getCurrentFileState(): IXyoFileOriginState {
                        const signersString: string[] = []
                        let previousHashString: string | undefined
                        let indexString: string | undefined
                    
                    
                    Severity: Minor
                    Found in src/persist/xyo-file-origin-state-repository.ts - About 1 hr to fix

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

                        public static validate(structure: XyoIterableStructure) {
                          const it = structure.newIterator()
                      
                          try {
                            while (it.hasNext()) {
                      Severity: Minor
                      Found in src/object-model/xyo-iterable-structure.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 true
                      Severity: Major
                      Found in src/bound-witness/xyo-bound-witness-validator.ts - About 30 mins to fix

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

                          private async sendAndReceive(
                            didHaveData: boolean,
                            transfer: XyoIterableStructure | undefined
                          ) {
                            let response: Buffer | undefined
                        Severity: Minor
                        Found in src/bound-witness/xyo-zig-zag-bound-witness-session.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

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

                          public async doBoundWitness(
                            transfer: XyoIterableStructure | undefined
                          ): Promise<void> {
                            if (!this.getIsCompleted()) {
                              const response = await this.sendAndReceive(
                        Severity: Minor
                        Found in src/bound-witness/xyo-zig-zag-bound-witness-session.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

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

                          public getSignatures(): XyoStructure[][] {
                            const signatureSets: XyoStructure[][] = []
                            const witnesses = this.getId(
                              XyoObjectSchema.WITNESS.id
                            ) as XyoIterableStructure[]
                        Severity: Minor
                        Found in src/bound-witness/xyo-bound-witness.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

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

                          public getPublicKeys(): XyoStructure[][] {
                            const keysets: XyoStructure[][] = []
                            const fetters = this.getId(
                              XyoObjectSchema.FETTER.id
                            ) as XyoIterableStructure[]
                        Severity: Minor
                        Found in src/bound-witness/xyo-bound-witness.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