XYOracleNetwork/sdk-core-nodejs

View on GitHub

Showing 47 of 49 total issues

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

  public getSignatures(): XyoStructure[][] {
    const signatureSets: XyoStructure[][] = []
    const witnesses = this.getId(
      XyoObjectSchema.WITNESS.id
    ) as XyoIterableStructure[]
Severity: Major
Found in src/bound-witness/xyo-bound-witness.ts and 1 other location - About 1 day to fix
src/bound-witness/xyo-bound-witness.ts on lines 34..56

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

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

  public getPublicKeys(): XyoStructure[][] {
    const keysets: XyoStructure[][] = []
    const fetters = this.getId(
      XyoObjectSchema.FETTER.id
    ) as XyoIterableStructure[]
Severity: Major
Found in src/bound-witness/xyo-bound-witness.ts and 1 other location - About 1 day to fix
src/bound-witness/xyo-bound-witness.ts on lines 59..81

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

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

      if (heuristic.getSchema().id === XyoObjectSchema.NEXT_PUBLIC_KEY.id) {
        const nextPublicKeyArray = heuristic as XyoIterableStructure

        if (nextPublicKeyArray.getCount() !== 1) {
          throw new Error('1 next public key expected')
Severity: Major
Found in src/heuristics/xyo-bound-witness-origin.ts and 1 other location - About 3 hrs to fix
src/heuristics/xyo-bound-witness-origin.ts on lines 48..56

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

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

      if (heuristic.getSchema().id === XyoObjectSchema.PREVIOUS_HASH.id) {
        const previousHashArray = heuristic as XyoIterableStructure

        if (previousHashArray.getCount() !== 1) {
          throw new Error('1 hash expected in previous hash')
Severity: Major
Found in src/heuristics/xyo-bound-witness-origin.ts and 1 other location - About 3 hrs to fix
src/heuristics/xyo-bound-witness-origin.ts on lines 38..46

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

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

export const lngResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    const value = new XyoStructure(heuristic).getValue().getContentsCopy()
    return {
      name: 'lng',
Severity: Major
Found in src/heuristics/common/resolvers.ts and 1 other location - About 2 hrs to fix
src/heuristics/common/resolvers.ts on lines 164..172

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

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

export const latResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    const value = new XyoStructure(heuristic).getValue().getContentsCopy()
    return {
      name: 'lat',
Severity: Major
Found in src/heuristics/common/resolvers.ts and 1 other location - About 2 hrs to fix
src/heuristics/common/resolvers.ts on lines 174..182

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

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

export const boundWitnessResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    return {
      name: 'boundWitness',
      value: iterableObjectToArray(new XyoIterableStructure(heuristic)).map(
Severity: Major
Found in src/heuristics/common/resolvers.ts and 1 other location - About 2 hrs to fix
src/heuristics/common/resolvers.ts on lines 271..282

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

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

export const bridgeHashSetResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    return {
      name: 'bridgeHashSet',
      value: iterableObjectToArray(new XyoIterableStructure(heuristic)).map(
Severity: Major
Found in src/heuristics/common/resolvers.ts and 1 other location - About 2 hrs to fix
src/heuristics/common/resolvers.ts on lines 258..269

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

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

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

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

export const rssiResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    return {
      name: 'rssi',
      value: readSignedNumber(
Severity: Major
Found in src/heuristics/common/resolvers.ts and 2 other locations - About 1 hr to fix
src/heuristics/common/resolvers.ts on lines 77..86
src/heuristics/common/resolvers.ts on lines 99..108

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

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

export const rssiAt1MResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    return {
      name: 'rssiAt1m',
      value: readSignedNumber(
Severity: Major
Found in src/heuristics/common/resolvers.ts and 2 other locations - About 1 hr to fix
src/heuristics/common/resolvers.ts on lines 77..86
src/heuristics/common/resolvers.ts on lines 88..97

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

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

export const indexResolver: IXyoHeuristicResolver = {
  resolve(heuristic: Buffer): IXyoHumanHeuristic {
    return {
      name: 'index',
      value: readUnsignedNumber(
Severity: Major
Found in src/heuristics/common/resolvers.ts and 2 other locations - About 1 hr to fix
src/heuristics/common/resolvers.ts on lines 88..97
src/heuristics/common/resolvers.ts on lines 99..108

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

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

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

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

              export const secp256K1PublicKeyResolver: IXyoHeuristicResolver = {
                resolve(heuristic: Buffer): IXyoHumanHeuristic {
                  return {
                    name: 'secp566k1PublicKey',
                    value: bs58.encode(heuristic),
              Severity: Major
              Found in src/heuristics/common/resolvers.ts and 5 other locations - About 1 hr to fix
              src/heuristics/common/resolvers.ts on lines 119..126
              src/heuristics/common/resolvers.ts on lines 128..135
              src/heuristics/common/resolvers.ts on lines 137..144
              src/heuristics/common/resolvers.ts on lines 146..153
              src/heuristics/common/resolvers.ts on lines 155..162

              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

              Severity
              Category
              Status
              Source
              Language