XYOracleNetwork/sdk-diviner-nodejs

View on GitHub

Showing 64 of 64 total issues

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

export const createTimeSelector = (
  getter: IXyoBlocksByTime
): IXyoSelecterCreator => {
  return {
    name: 'SELECTOR_TIME',
Severity: Major
Found in src/query/selectors/xyo-time-selector.ts and 4 other locations - About 1 hr to fix
src/query/selectors/xyo-geohash-selector.ts on lines 37..46
src/query/selectors/xyo-hash-selector.ts on lines 41..50
src/query/selectors/xyo-index-selector.ts on lines 41..50
src/query/selectors/xyo-page-selector.ts on lines 38..47

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

export const createHashSelector = (
  getter: IXyoOriginBlockGetter
): IXyoSelecterCreator => {
  return {
    name: 'SELECTOR_HASH',
Severity: Major
Found in src/query/selectors/xyo-hash-selector.ts and 4 other locations - About 1 hr to fix
src/query/selectors/xyo-geohash-selector.ts on lines 37..46
src/query/selectors/xyo-index-selector.ts on lines 41..50
src/query/selectors/xyo-page-selector.ts on lines 38..47
src/query/selectors/xyo-time-selector.ts on lines 37..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 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 5 locations. Consider refactoring.
Open

export const createPageSelector = (
  getter: IXyoOriginBlockGetter
): IXyoSelecterCreator => {
  return {
    name: 'SELECTOR_PAGE',
Severity: Major
Found in src/query/selectors/xyo-page-selector.ts and 4 other locations - About 1 hr to fix
src/query/selectors/xyo-geohash-selector.ts on lines 37..46
src/query/selectors/xyo-hash-selector.ts on lines 41..50
src/query/selectors/xyo-index-selector.ts on lines 41..50
src/query/selectors/xyo-time-selector.ts on lines 37..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 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 5 locations. Consider refactoring.
Open

export const createGeohashSelectorCreator = (
  tracer: IXyoBlocksByGeohashRepository
): IXyoSelecterCreator => {
  return {
    name: 'SELECTOR_GEOHASH',
Severity: Major
Found in src/query/selectors/xyo-geohash-selector.ts and 4 other locations - About 1 hr to fix
src/query/selectors/xyo-hash-selector.ts on lines 41..50
src/query/selectors/xyo-index-selector.ts on lines 41..50
src/query/selectors/xyo-page-selector.ts on lines 38..47
src/query/selectors/xyo-time-selector.ts on lines 37..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 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 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

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

          export const humanMutator: IXyoMutatorCreater = {
            name: 'MUTATOR_HUMAN',
            create: (config: any, creators: Map<string, IXyoMutatorCreater>) => {
              addAllDefaults()
              return new HumanMutator()
          Severity: Major
          Found in src/query/mutators/human.ts and 1 other location - About 1 hr to fix
          src/query/mutators/location.ts on lines 33..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 63.

          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 locationMutator: IXyoMutatorCreater = {
            name: 'MUTATOR_LOCATION',
            create: (config: any, creators: Map<string, IXyoMutatorCreater>) => {
              addAllDefaults()
              return new LocationMutator()
          Severity: Major
          Found in src/query/mutators/location.ts and 1 other location - About 1 hr to fix
          src/query/mutators/human.ts on lines 33..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 63.

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

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

                    this.dynamodb.putItem(
                      params,
                      (err: any, data: DynamoDB.Types.PutItemOutput) => {
                        if (err) {
                          reject(err)
            Severity: Major
            Found in src/reports/dynanmo/report-repository.ts and 2 other locations - About 1 hr to fix
            src/payment/repository/dynammodb/credit-table.ts on lines 45..53
            src/payment/repository/dynammodb/spend-table.ts on lines 42..50

            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

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

                    this.dynamodb.putItem(
                      params,
                      (err: any, data: DynamoDB.Types.PutItemOutput) => {
                        if (err) {
                          reject(err)
            Severity: Major
            Found in src/payment/repository/dynammodb/credit-table.ts and 2 other locations - About 1 hr to fix
            src/payment/repository/dynammodb/spend-table.ts on lines 42..50
            src/reports/dynanmo/report-repository.ts on lines 69..77

            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

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

                    this.dynamodb.putItem(
                      params,
                      (err: any, data: DynamoDB.Types.PutItemOutput) => {
                        if (err) {
                          reject(err)
            Severity: Major
            Found in src/payment/repository/dynammodb/spend-table.ts and 2 other locations - About 1 hr to fix
            src/payment/repository/dynammodb/credit-table.ts on lines 45..53
            src/reports/dynanmo/report-repository.ts on lines 69..77

            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

            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
                  Severity
                  Category
                  Status
                  Source
                  Language