dataplug-io/dataplug-http

View on GitHub
src/httpGetReader.ts

Summary

Maintainability
F
3 days
Test Coverage

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

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

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

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

        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

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

          _destroy(err: any, callback: (err: any) => void): void {
            // Detach from current stream
            if (this.request) {
              const capturedRequest = this.request
              this.detachFromStreams()
        Severity: Major
        Found in src/httpGetReader.ts and 1 other location - About 1 hr to fix
        src/pagedHttpGetReader.ts on lines 102..111

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

        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

            options = Object.assign(
              {},
              {
                transform: undefined,
                query: undefined,
        Severity: Minor
        Found in src/httpGetReader.ts and 1 other location - About 40 mins to fix
        src/pagedHttpGetReader.ts on lines 43..53

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

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

              this.request
                .on('data', this.onRequestDataHandler)
                .on('close', this.onRequestCloseHandler)
                .on('end', this.onRequestEndHandler)
        Severity: Major
        Found in src/httpGetReader.ts and 3 other locations - About 35 mins to fix
        src/httpGetReader.ts on lines 111..114
        src/pagedHttpGetReader.ts on lines 129..132
        src/pagedHttpGetReader.ts on lines 248..251

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

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

            this.request
              .on('error', this.onRequestErrorHandler)
              .on('close', this.onRequestCloseHandler)
              .on('response', this.onRequestResponseHandler)
        Severity: Major
        Found in src/httpGetReader.ts and 3 other locations - About 35 mins to fix
        src/httpGetReader.ts on lines 234..237
        src/pagedHttpGetReader.ts on lines 129..132
        src/pagedHttpGetReader.ts on lines 248..251

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

        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

        There are no issues that match your filters.

        Category
        Status