dataplug-io/dataplug-http

View on GitHub

Showing 32 of 32 total issues

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

    if (shouldProcessData) {
      logger.log(
        'debug',
        `Processing response data from paged HTTP GET request to '${this.url}'`,
        this.url,
Severity: Major
Found in src/httpGetReader.ts and 1 other location - About 7 hrs to fix
src/pagedHttpGetReader.ts on lines 243..290

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

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 (_.isBoolean(shouldProcessData) && shouldProcessData) {
      logger.log(
        'debug',
        `Processing response data from paged HTTP GET request to ${this.url}`,
      )
Severity: Major
Found in src/pagedHttpGetReader.ts and 1 other location - About 7 hrs to fix
src/httpGetReader.ts on lines 228..271

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

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

    if (this.transform) {
      this.transform.removeListener('data', this.onTransformDataHandler)
      this.transform.removeListener('error', this.onTransformErrorHandler)
      this.transform.removeListener('close', this.onTransformCloseHandler)
      this.transform.removeListener('end', this.onTransformEndHandler)
Severity: Major
Found in src/pagedHttpGetReader.ts and 2 other locations - About 4 hrs to fix
src/httpGetReader.ts on lines 331..338
src/pagedHttpGetReader.ts on lines 368..375

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

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

    if (this.request) {
      this.request.removeListener('data', this.onRequestDataHandler)
      this.request.removeListener('error', this.onRequestErrorHandler)
      this.request.removeListener('close', this.onRequestCloseHandler)
      this.request.removeListener('end', this.onRequestEndHandler)
Severity: Major
Found in src/httpGetReader.ts and 2 other locations - About 4 hrs to fix
src/pagedHttpGetReader.ts on lines 368..375
src/pagedHttpGetReader.ts on lines 377..384

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

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

    if (this.request) {
      this.request.removeListener('data', this.onRequestDataHandler)
      this.request.removeListener('error', this.onRequestErrorHandler)
      this.request.removeListener('close', this.onRequestCloseHandler)
      this.request.removeListener('end', this.onRequestEndHandler)
Severity: Major
Found in src/pagedHttpGetReader.ts and 2 other locations - About 4 hrs to fix
src/httpGetReader.ts on lines 331..338
src/pagedHttpGetReader.ts on lines 377..384

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

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

File pagedHttpGetReader.ts has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright (C) 2017-2019 Brainbean Apps OU (https://brainbeanapps.com).
// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import _ from 'lodash'
import { Readable } from 'stream'
Severity: Minor
Found in src/pagedHttpGetReader.ts - About 3 hrs to fix

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

      _safeStartRequest(): void {
        try {
          this._startRequest()
        } catch (error) {
          logger.log(
    Severity: Major
    Found in src/pagedHttpGetReader.ts and 1 other location - About 3 hrs to fix
    src/httpGetReader.ts on lines 120..134

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

    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

      _safeStartRequest(): void {
        try {
          this._startRequest()
        } catch (error) {
          logger.log(
    Severity: Major
    Found in src/httpGetReader.ts and 1 other location - About 3 hrs to fix
    src/pagedHttpGetReader.ts on lines 138..152

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

    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

        try {
          shouldProcessData = this.options.responseHandler(response, this.request)
        } catch (error) {
          logger.log(
            'error',
    Severity: Major
    Found in src/httpGetReader.ts and 1 other location - About 3 hrs to fix
    src/pagedHttpGetReader.ts on lines 228..241

    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

        try {
          shouldProcessData = this.options.responseHandler(response, this.request)
        } catch (error) {
          logger.log(
            'error',
    Severity: Major
    Found in src/pagedHttpGetReader.ts and 1 other location - About 3 hrs to fix
    src/httpGetReader.ts on lines 213..226

    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

    Function onRequestResponse has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private onRequestResponse(response: any): void {
        logger.log(
          'debug',
          `Received response while making paged HTTP GET request to ${this.url}`,
        )
    Severity: Major
    Found in src/pagedHttpGetReader.ts - About 2 hrs to fix

      Function onRequestResponse has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private onRequestResponse(response: any): void {
          logger.log(
            'debug',
            `Received response while making HTTP GET request to ${this.url}`,
          )
      Severity: Major
      Found in src/httpGetReader.ts - About 2 hrs to fix

        File httpGetReader.ts has 273 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Copyright (C) 2017-2019 Brainbean Apps OU (https://brainbeanapps.com).
        // License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
        
        import _ from 'lodash'
        import { Readable } from 'stream'
        Severity: Minor
        Found in src/httpGetReader.ts - About 2 hrs to fix

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

            private onTransformData(chunk: any): void {
              logger.log('debug', `Transformed data from HTTP GET request to ${this.url}`)
              logger.log('silly', 'Chunk', chunk)
          
              this.push(chunk)
          Severity: Major
          Found in src/httpGetReader.ts and 2 other locations - About 1 hr to fix
          src/pagedHttpGetReader.ts on lines 334..342
          src/pagedHttpGetReader.ts on lines 347..357

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

            private onTransformData(chunk: any): void {
              logger.log(
                'debug',
                `Transformed data from paged HTTP GET request to ${this.url}`,
              )
          Severity: Major
          Found in src/pagedHttpGetReader.ts and 2 other locations - About 1 hr to fix
          src/httpGetReader.ts on lines 315..320
          src/pagedHttpGetReader.ts on lines 347..357

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

            private onTransformComplete(data: any): void {
              logger.log(
                'verbose',
                `Transformation of data from paged HTTP GET request to ${
                  this.url
          Severity: Major
          Found in src/pagedHttpGetReader.ts and 2 other locations - About 1 hr to fix
          src/httpGetReader.ts on lines 315..320
          src/pagedHttpGetReader.ts on lines 334..342

          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

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

            constructor(url: string | URL, nextPage: any, options: any = undefined) {
              options = Object.assign(
                {},
                {
                  transformFactory: undefined,
          Severity: Minor
          Found in src/pagedHttpGetReader.ts - About 1 hr to fix

            Function proceedToNextPage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private proceedToNextPage(data: any): void {
                this.detachFromStreams()
            
                logger.log(
                  'verbose',
            Severity: Minor
            Found in src/pagedHttpGetReader.ts - About 1 hr to fix

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

                  } else {
                    if (!this.options.transform) {
                      this.detachFromStreams()
                      this.push(null)
                    } else {
              Severity: Major
              Found in src/httpGetReader.ts and 1 other location - About 1 hr to fix
              src/httpGetReader.ts on lines 161..168

              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

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

                private onRequestClose(): void {
                  if (!this.options.transform) {
                    this.detachFromStreams()
                    this.push(null)
                  } else {
              Severity: Major
              Found in src/httpGetReader.ts and 1 other location - About 1 hr to fix
              src/httpGetReader.ts on lines 148..155

              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

              Severity
              Category
              Status
              Source
              Language