XYOracleNetwork/sdk-archivist-nodejs

View on GitHub

Showing 51 of 51 total issues

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

  public getMeanCollectedBoundWitnessPerMinuteRuntime(): number {
    const timeNow = new Date().getTime()
    const timeDelta = timeNow - this.since
    const mins = timeDelta / (1000 * 60)
    return this.runTimeCollectedBoundWitnesses / mins
Severity: Major
Found in src/collector-stats/xyo-collecter-stats.ts and 1 other location - About 1 hr to fix
src/collector-stats/xyo-collecter-stats.ts on lines 38..43

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

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 getMeanBoundWitnessPerMinuteRuntime(): number {
    const timeNow = new Date().getTime()
    const timeDelta = timeNow - this.since
    const mins = timeDelta / (1000 * 60)
    return this.runTimeBoundWitnesses / mins
Severity: Major
Found in src/collector-stats/xyo-collecter-stats.ts and 1 other location - About 1 hr to fix
src/collector-stats/xyo-collecter-stats.ts on lines 45..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 70.

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 async getOriginBlocks(
    _limit: number,
    _offsetHash?: Buffer | undefined
  ): Promise<{ items: Buffer[]; total: number }> {
    return { items: [], total: 0 }
Severity: Major
Found in src/repository/neo4j/xyo-neo4j-archivist-repository.ts and 1 other location - About 1 hr to fix
src/repository/neo4j/xyo-neo4j-archivist-repository.ts on lines 37..42

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

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 async getEntities(
    _limit: number,
    _offsetCursor?: Buffer | undefined
  ): Promise<{ items: Buffer[]; total: number }> {
    return { items: [], total: 0 }
Severity: Major
Found in src/repository/neo4j/xyo-neo4j-archivist-repository.ts and 1 other location - About 1 hr to fix
src/repository/neo4j/xyo-neo4j-archivist-repository.ts on lines 89..94

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

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 getByGeohash has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public async getByGeohash(geohash: string, limit: number): Promise<Buffer[]> {
    return new Promise<Buffer[]>((resolve: any, reject: any) => {
      try {
        const params: DynamoDB.Types.QueryInput = {
          ExpressionAttributeValues: {
Severity: Minor
Found in src/repository/dynamodb/table/geo.ts - About 1 hr to fix

    Function bufferToGraphQlBlock has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function bufferToGraphQlBlock(buffer: Buffer): any {
      const boundWitness = new XyoBoundWitness(buffer)
      return {
        bytes: buffer.toString('base64'),
    
    
    Severity: Minor
    Found in src/endpoints/buffer-to-graphql-block.ts - About 1 hr to fix

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

        public async getItem(hash: Buffer): Promise<any> {
          return new Promise<boolean>((resolve: any, reject: any) => {
            try {
              const value = this.cache.get(hash.toString())
              if (value) {
      Severity: Minor
      Found in src/repository/dynamodb/table/boundwitness.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/repository/dynamodb/table/geo.ts and 2 other locations - About 1 hr to fix
        src/repository/dynamodb/table/publickey.ts on lines 73..81
        src/repository/dynamodb/table/time.ts on lines 60..68

        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/repository/dynamodb/table/publickey.ts and 2 other locations - About 1 hr to fix
        src/repository/dynamodb/table/geo.ts on lines 85..93
        src/repository/dynamodb/table/time.ts on lines 60..68

        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/repository/dynamodb/table/time.ts and 2 other locations - About 1 hr to fix
        src/repository/dynamodb/table/geo.ts on lines 85..93
        src/repository/dynamodb/table/publickey.ts on lines 73..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 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 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/elastic-search/xyo-geohash-elastic-search.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/notify/xyo-websocket-notify.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/collector-stats/index.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 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public async putItem(
            key: Buffer,
            hash: Buffer,
            index: number
          ): Promise<void> {
        Severity: Minor
        Found in src/repository/dynamodb/table/publickey.ts - About 1 hr to fix

          Function putItem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public async putItem(bytes: Buffer): Promise<void> {
              const currentTime = new Date().getTime()
          
              return new Promise<void>((resolve: any, reject: any) => {
                try {
          Severity: Minor
          Found in src/repository/dynamodb/table/time.ts - About 1 hr to fix

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

              public async putItem(geohash: string, hash: Buffer): Promise<void> {
                return new Promise<void>((resolve: any, reject: any) => {
                  try {
                    const params: DynamoDB.Types.PutItemInput = {
                      Item: {
            Severity: Minor
            Found in src/repository/dynamodb/table/geo.ts - About 1 hr to fix

              Function putItem has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public async putItem(hash: Buffer, originBlock: Buffer): Promise<void> {
                  return new Promise<void>((resolve: any, reject: any) => {
                    try {
                      const params: DynamoDB.Types.PutItemInput = {
                        Item: {
              Severity: Minor
              Found in src/repository/dynamodb/table/boundwitness.ts - About 1 hr to fix

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

                  public async resolve(obj: any, args: any): Promise<any> {
                    const cursor = args.cursor as string | undefined
                    const cursorBuffer = cursor ? bs58.decode(cursor) : undefined
                    const result = await this.originBlockRepository.getOriginBlocks(
                      args.limit as number,
                Severity: Minor
                Found in src/endpoints/block-list.ts - About 1 hr to fix

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

                    public async initialize(delegate: IXyoPluginDelegate): Promise<boolean> {
                      const inserter = delegate.deps
                        .BOUND_WITNESS_INSERTER as XyoBoundWitnessInserter
                      const stats = new XyoCollectorStats()
                      const resolver = new XyoCollecterStatsResolver(stats)
                  Severity: Minor
                  Found in src/collector-stats/index.ts - About 1 hr to fix

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

                      constructor(tableName = 'xyo-archivist-chains', region = 'us-east-1') {
                        super(tableName, region)
                        this.createTableInput = {
                          AttributeDefinitions: [
                            {
                    Severity: Minor
                    Found in src/repository/dynamodb/table/publickey.ts - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language