drdgvhbh/node-XMLHttpRequest

View on GitHub

Showing 7 of 65 total issues

File XMLHttpRequest.ts has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import http from 'http';
import {
  InvalidStateDOMException,
  SyntaxErrDOMException,
  SecurityErrDOMException,
Severity: Minor
Found in src/XMLHttpRequest.ts - About 4 hrs to fix

    Function send has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public send(data?: Document | BodyInit | null) {
        if (this.readyState !== this.OPENED) {
          throw new InvalidStateDOMException('state is not opened');
        }
        if (this.sendFlag) {
    Severity: Major
    Found in src/XMLHttpRequest.ts - About 3 hrs to fix

      XMLHttpRequest has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class XMLHttpRequest {
        private request: http.ClientRequest | undefined | null;
      
        private response: request.Response | undefined;
      
      
      Severity: Minor
      Found in src/XMLHttpRequest.ts - About 2 hrs to fix

        Function send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          public send(data?: Document | BodyInit | null) {
            if (this.readyState !== this.OPENED) {
              throw new InvalidStateDOMException('state is not opened');
            }
            if (this.sendFlag) {
        Severity: Minor
        Found in src/XMLHttpRequest.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

        Consider simplifying this complex logical expression.
        Open

            if (
              typeof header === 'string' &&
              this.readyState > this.OPENED &&
              this.response &&
              this.response.headers &&
        Severity: Major
        Found in src/XMLHttpRequest.ts - About 40 mins to fix

          Function getAllResponseHeaders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            public getAllResponseHeaders() {
              if (this.readyState < this.HEADERS_RECEIVED || this.errorFlag) {
                return '';
              }
              let result = '';
          Severity: Minor
          Found in src/XMLHttpRequest.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

          Function setState has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private setState(state: number): void {
              if (state == this.LOADING || this.readyState !== state) {
                this._readyState = state;
                if (
                  this.settings.async ||
          Severity: Minor
          Found in src/XMLHttpRequest.ts - About 25 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