jameswlane/jest-express

View on GitHub

Showing 12 of 222 total issues

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

  constructor() {
    // Properties
    this.headers = {};
    this.headersSent = false;
    this.locals = {};
Severity: Major
Found in src/response.ts - About 2 hrs to fix

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

      constructor() {
        this.request = new Request(null, { app: this });
        this.response = new Response();
        this.next = next;
        // Properties
    Severity: Major
    Found in src/express.ts - About 2 hrs to fix

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

      export class Request {
        // Properties
        public baseUrl: string;
        public body: any;
        public cookies: any;
      Severity: Minor
      Found in src/request.ts - About 2 hrs to fix

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

          constructor() {
            const handler = (path: any, ...callbacks: any): void => {
              const flattened = [].concat(...callbacks); // flatten array
              if (typeof path === 'string' && flattened.every((cb: any) => typeof cb === 'function')) {
                flattened.forEach((cb: any) => cb(this.request, this.response, this.next));
        Severity: Minor
        Found in src/router.ts - About 1 hr to fix

          Function constructor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor() {
              this.request = new Request(null, { app: this });
              this.response = new Response();
              this.next = next;
              // Properties
          Severity: Minor
          Found in src/express.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 constructor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(url?: string | null, options?: IRequestOptions) {
              // Properties
              this.baseUrl = '';
              this.body = '';
              this.cookies = {};
          Severity: Minor
          Found in src/request.ts - About 1 hr to fix

            Function constructor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              constructor() {
                // Properties
                this.headers = {};
                this.headersSent = false;
                this.locals = {};
            Severity: Minor
            Found in src/response.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 setUrl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              public setUrl(url: string, options?: IRequestOptions) {
                const parsedUrl = parse(url, true);
            
                this.path = parsedUrl.pathname || '/';
                this.hostname = parsedUrl.hostname || '';
            Severity: Minor
            Found in src/request.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 resetMocked has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public resetMocked() {
                // Properties
                this.baseUrl = '';
                this.body = '';
                this.cookies = {};
            Severity: Minor
            Found in src/request.ts - About 1 hr to fix

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

                public resetMocked() {
                  // Properties
                  this.locals = {};
                  this.error = {};
                  this.mountpath = '';
              Severity: Minor
              Found in src/express.ts - About 1 hr to fix

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

                  public resetMocked() {
                    // Properties
                    this.headers = {};
                    this.headersSent = false;
                    this.locals = {};
                Severity: Minor
                Found in src/response.ts - About 1 hr to fix

                  Function setUrl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public setUrl(url: string, options?: IRequestOptions) {
                      const parsedUrl = parse(url, true);
                  
                      this.path = parsedUrl.pathname || '/';
                      this.hostname = parsedUrl.hostname || '';
                  Severity: Minor
                  Found in src/request.ts - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language