NeuraLegion/cypress-har-generator

View on GitHub

Showing 27 of 33 total issues

File NetworkRequest.ts has 606 lines of code (exceeds 500 allowed). Consider refactoring.
Open

import { CookieParser } from './CookieParser';
import { NetworkCookie } from './NetworkCookie';
import { StringUtils } from '../utils/StringUtils';
import type { RequestExtraInfo, ResponseExtraInfo } from './ExtraInfoBuilder';
import type { Header, Param, QueryString } from 'har-format';
Severity: Major
Found in src/network/NetworkRequest.ts - About 4 hrs to fix

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

      public webSocketFrameReceived({
        requestId,
        timestamp,
        response
      }: Protocol.Network.WebSocketFrameReceivedEvent): void {
    Severity: Major
    Found in src/network/NetworkObserver.ts and 1 other location - About 3 hrs to fix
    src/network/NetworkObserver.ts on lines 277..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 105.

    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 webSocketFrameSent({
        requestId,
        timestamp,
        response
      }: Protocol.Network.WebSocketFrameSentEvent): void {
    Severity: Major
    Found in src/network/NetworkObserver.ts and 1 other location - About 3 hrs to fix
    src/network/NetworkObserver.ts on lines 292..305

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

    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 buildTimings has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      private buildTimings(): Timings {
        const timing = this.request.timing;
        const issueTime: number = this.request.issueTime;
        const startTime: number = this.request.startTime;
    
    
    Severity: Minor
    Found in src/network/EntryBuilder.ts - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

      private requestHeaderValue(headerName: string): string | undefined {
        if (!this._requestHeaderValues.has(headerName)) {
          const headerValue = this.computeHeaderValue(
            this.requestHeaders,
            headerName
    Severity: Major
    Found in src/network/NetworkRequest.ts and 1 other location - About 3 hrs to fix
    src/network/NetworkRequest.ts on lines 657..667

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

    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 responseHeaderValue(headerName: string): string | undefined {
        if (!this._responseHeaderValues.has(headerName)) {
          const headerValue = this.computeHeaderValue(
            this.responseHeaders,
            headerName
    Severity: Major
    Found in src/network/NetworkRequest.ts and 1 other location - About 3 hrs to fix
    src/network/NetworkRequest.ts on lines 743..753

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

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

      private buildTimings(): Timings {
        const timing = this.request.timing;
        const issueTime: number = this.request.issueTime;
        const startTime: number = this.request.startTime;
    
    
    Severity: Major
    Found in src/network/EntryBuilder.ts - About 2 hrs to fix

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

        get requestCookies(): NetworkCookie[] | undefined {
          if (!this._requestCookies) {
            const cookie = this.requestHeaderValue('Cookie');
            this._requestCookies = cookie
              ? new CookieParser().parseCookie(cookie)
      Severity: Major
      Found in src/network/NetworkRequest.ts and 1 other location - About 2 hrs to fix
      src/network/NetworkRequest.ts on lines 357..366

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

      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

        get responseCookies(): NetworkCookie[] | undefined {
          if (!this._responseCookies) {
            const cookie = this.responseHeaderValue('Set-Cookie');
            this._responseCookies = cookie
              ? new CookieParser().parseSetCookie(cookie)
      Severity: Major
      Found in src/network/NetworkRequest.ts and 1 other location - About 2 hrs to fix
      src/network/NetworkRequest.ts on lines 293..302

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

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

          setupNodeEvents(
            on: Cypress.PluginEvents,
            _: Cypress.PluginConfigOptions
          ): void {
            install(on);
      Severity: Minor
      Found in cypress.config.ts - About 1 hr to fix

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

          private updateNetworkRequestWithResponse(
            networkRequest: NetworkRequest,
            response: Protocol.Network.Response
          ): void {
            if (response.url && networkRequest.url !== response.url) {
        Severity: Minor
        Found in src/network/NetworkObserver.ts - About 1 hr to fix

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

            public requestWillBeSent({
              type,
              loaderId,
              initiator,
              redirectResponse,
          Severity: Minor
          Found in src/network/NetworkObserver.ts - About 1 hr to fix

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

              public async build(): Promise<Entry> {
                let serverIPAddress: string = this.request.remoteAddress;
            
                const portPositionInString: number = serverIPAddress.lastIndexOf(':');
            
            
            Severity: Minor
            Found in src/network/EntryBuilder.ts - About 1 hr to fix

              Function updateNetworkRequestWithResponse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                private updateNetworkRequestWithResponse(
                  networkRequest: NetworkRequest,
                  response: Protocol.Network.Response
                ): void {
                  if (response.url && networkRequest.url !== response.url) {
              Severity: Minor
              Found in src/network/NetworkObserver.ts - About 55 mins 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 addExtraResponseInfo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                public addExtraResponseInfo(extraResponseInfo: ResponseExtraInfo): void {
                  this.responseHeaders = extraResponseInfo.responseHeaders;
              
                  if (extraResponseInfo.responseHeadersText) {
                    this.responseHeadersText = extraResponseInfo.responseHeadersText;
              Severity: Minor
              Found in src/network/NetworkRequest.ts - About 55 mins 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

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

                public wouldApply(options: RequestFilterOptions): boolean {
                  return (
                    Array.isArray(options.excludePaths) && options.excludePaths.length > 0
                  );
                }
              Severity: Major
              Found in src/network/filters/PathFilter.ts and 3 other locations - About 45 mins to fix
              src/network/filters/HostFilter.ts on lines 17..21
              src/network/filters/MimeFilter.ts on lines 12..16
              src/network/filters/StatusCodeFilter.ts on lines 12..17

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

              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

                public wouldApply(options: RequestFilterOptions): boolean {
                  return (
                    Array.isArray(options.excludeStatusCodes) &&
                    options.excludeStatusCodes.length > 0
                  );
              Severity: Major
              Found in src/network/filters/StatusCodeFilter.ts and 3 other locations - About 45 mins to fix
              src/network/filters/HostFilter.ts on lines 17..21
              src/network/filters/MimeFilter.ts on lines 12..16
              src/network/filters/PathFilter.ts on lines 17..21

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

              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

                public wouldApply(options: RequestFilterOptions): boolean {
                  return (
                    Array.isArray(options.includeHosts) && options.includeHosts.length > 0
                  );
                }
              Severity: Major
              Found in src/network/filters/HostFilter.ts and 3 other locations - About 45 mins to fix
              src/network/filters/MimeFilter.ts on lines 12..16
              src/network/filters/PathFilter.ts on lines 17..21
              src/network/filters/StatusCodeFilter.ts on lines 12..17

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

              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

                public wouldApply(options: RequestFilterOptions): boolean {
                  return (
                    Array.isArray(options.includeMimes) && options.includeMimes.length > 0
                  );
                }
              Severity: Major
              Found in src/network/filters/MimeFilter.ts and 3 other locations - About 45 mins to fix
              src/network/filters/HostFilter.ts on lines 17..21
              src/network/filters/PathFilter.ts on lines 17..21
              src/network/filters/StatusCodeFilter.ts on lines 12..17

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

              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 escapeCharacters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                public static escapeCharacters(
                  str: string,
                  chars: string = '^[]{}()\\\\.$*+?|'
                ): string {
                  let foundChar = false;
              Severity: Minor
              Found in src/utils/StringUtils.ts - About 35 mins 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

              Severity
              Category
              Status
              Source
              Language