XYOracleNetwork/sdk-diviner-nodejs

View on GitHub

Showing 28 of 64 total issues

Function traceChain has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  public async traceChain(
    publicKey: Buffer,
    limit: number | undefined = 100,
    index: number | undefined = 0,
    up: boolean
Severity: Minor
Found in src/chain/xyo-public-key-tracer.ts - About 3 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 traceChain has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public async traceChain(
    publicKey: Buffer,
    limit: number | undefined = 100,
    index: number | undefined = 0,
    up: boolean
Severity: Major
Found in src/chain/xyo-public-key-tracer.ts - About 2 hrs to fix

    Function getBlockPreviousHash has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      private getBlockPreviousHash(
        publicKeysOfParent: Buffer[],
        boundWitnessBytes: Buffer
      ): { origin: IXyoBoundWitnessOrigin; publicKeys: Buffer[] } | undefined {
        const boundWitness = new XyoBoundWitness(boundWitnessBytes)
    Severity: Minor
    Found in src/chain/xyo-hash-tracer.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 getPublicKeyOfNextSegment has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      private getPublicKeyOfNextSegment(
        boundWitnessBytes: Buffer,
        publicKeysOfParty: Buffer[]
      ): Buffer | undefined {
        const boundWitness = new XyoBoundWitness(boundWitnessBytes)
    Severity: Minor
    Found in src/chain/xyo-public-key-tracer.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 bufferToGraphQlBlock has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function bufferToGraphQlBlock(buffer: Buffer): any {
      const boundWitness = new XyoBoundWitness(buffer)
      return {
        // todo get human readable
        humanReadable: XyoHumanHeuristicResolver.resolve(buffer).value,
    Severity: Minor
    Found in src/chain/endpoints/xyo-buffer-to-graphql-block.ts - About 1 hr to fix

      Function getQueryInfo has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public getQueryInfo(
          day: number,
          time: number,
          limit: number
        ): Promise<IXyoQueryInfo[]> {
      Severity: Minor
      Found in src/reports/dynanmo/report-repository.ts - About 1 hr to fix

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

          public didIntersect(boundWitness: Buffer): boolean {
            const founds: boolean[] = new Array(this.config.with.length)
            const publicKeys = new XyoBoundWitness(boundWitness).getPublicKeys()
        
            for (let i = 0; i < this.config.with.length; i++) {
        Severity: Minor
        Found in src/query/filters/intersection.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 putQueryInfo has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public putQueryInfo(info: IXyoQueryInfo): Promise<void> {
            const day = Math.floor(info.time.getTime() / (1000 * 60 * 60 * 24))
        
            return new Promise<void>((resolve: any, reject: any) => {
              try {
        Severity: Minor
        Found in src/reports/dynanmo/report-repository.ts - About 1 hr to fix

          Function initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public async initialize(delegate: IXyoPluginDelegate): Promise<boolean> {
              const repository = delegate.deps
                .REPORT_REPOSITORY as IXyoQueryReportRepository
              const query = delegate.deps.QUERY as XyoQuery
              const hasher = new XyoSha256()
          Severity: Minor
          Found in src/reports/xyo-query-report-plugin.ts - About 1 hr to fix

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

              public async getAmountInTransaction(
                txHash: string,
                fromEth: string,
                toEth: string
              ): Promise<number | undefined> {
            Severity: Minor
            Found in src/payment/eth/xyo-eth-payment.ts - About 1 hr to fix

              Function getBlockPreviousHash has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private getBlockPreviousHash(
                  publicKeysOfParent: Buffer[],
                  boundWitnessBytes: Buffer
                ): { origin: IXyoBoundWitnessOrigin; publicKeys: Buffer[] } | undefined {
                  const boundWitness = new XyoBoundWitness(boundWitnessBytes)
              Severity: Minor
              Found in src/chain/xyo-hash-tracer.ts - About 1 hr to fix

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

                  public async getItem(key: string): Promise<any> {
                    return new Promise<boolean>((resolve: any, reject: any) => {
                      try {
                        const params: DynamoDB.Types.GetItemInput = {
                          Key: {
                Severity: Minor
                Found in src/payment/repository/dynammodb/spend-table.ts - About 1 hr to fix

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

                    constructor(tableName = 'xyo-diviner-queries', region = 'us-east-1') {
                      super(tableName, region)
                  
                      this.createTableInput = {
                        AttributeDefinitions: [
                  Severity: Minor
                  Found in src/reports/dynanmo/report-repository.ts - About 1 hr to fix

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

                      public async queryFor(query: IXyoQuery): Promise<any> {
                        if (this.auth) {
                          const auth = await this.auth.auth(query)
                    
                          query.shouldReward = auth.shouldReward
                    Severity: Minor
                    Found in src/query/xyo-query.ts - About 1 hr to fix

                      Function getLastIntersection has 28 lines of code (exceeds 25 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 1 hr to fix

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

                          public async getBalance(key: string): Promise<number | undefined> {
                            return new Promise<number | undefined>((resolve: any, reject: any) => {
                              try {
                                const params: DynamoDB.Types.GetItemInput = {
                                  Key: {
                        Severity: Minor
                        Found in src/payment/repository/dynammodb/credit-table.ts - About 1 hr to fix

                          Function queryFor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            public async queryFor(query: IXyoQuery): Promise<any> {
                              if (this.auth) {
                                const auth = await this.auth.auth(query)
                          
                                query.shouldReward = auth.shouldReward
                          Severity: Minor
                          Found in src/query/xyo-query.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 auth has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            public async auth(
                              config: any
                            ): Promise<{ auth: boolean; shouldReward: boolean }> {
                              const keys = Object.keys(config)
                          
                          
                          Severity: Minor
                          Found in src/query/auth/xyo-query-auth-multiplex.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 checkIfExceedLimit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            private checkIfExceedLimit(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 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 putItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            public async putItem(key: string, bal: number): Promise<void> {
                              return new Promise<void>((resolve: any, reject: any) => {
                                try {
                                  const params: DynamoDB.Types.PutItemInput = {
                                    Item: {
                          Severity: Minor
                          Found in src/payment/repository/dynammodb/credit-table.ts - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language