nanoexpress/nanoexpress

View on GitHub

Showing 49 of 55 total issues

Function compileRoute has a Cognitive Complexity of 115 (exceeds 5 allowed). Consider refactoring.
Open

export default function compileRoute(fn, params) {
  const content = babelCompilerManipulationNormalize(fn.toString().trim());
  const preparedParams = convertParams(params);

  // Don't parse dummy functions
Severity: Minor
Found in src/compilers/route.js - About 2 days 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 _prepareMethod has 338 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _prepareMethod(method, { originalUrl, path }, ...middlewares) {
    const { _config, _baseUrl, _middlewares, _ajv, _console } = this;

    const fetchMethod = method === 'ANY';
    const isWebSocket = method === 'WS';
Severity: Major
Found in src/Route.js - About 1 day to fix

    Function swaggerDocsGenerator has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function swaggerDocsGenerator(
      swaggerDef,
      path,
      method,
      { schema, contentType = '*', ...routeConfigs } = {}
    Severity: Minor
    Found in src/helpers/prepare-swagger-docs.js - About 1 day 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 _prepareMethod has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

      _prepareMethod(method, { originalUrl, path }, ...middlewares) {
        const { _config, _baseUrl, _middlewares, _ajv, _console } = this;
    
        const fetchMethod = method === 'ANY';
        const isWebSocket = method === 'WS';
    Severity: Minor
    Found in src/Route.js - About 1 day 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

    File Route.js has 535 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Events from '@dalisoft/events';
    import fastQueryParse from 'fast-query-parse';
    import { Route as RouteCompiler } from './compilers/index.js';
    import {
      httpMethods,
    Severity: Major
    Found in src/Route.js - About 1 day to fix

      Function compileRoute has 183 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function compileRoute(fn, params) {
        const content = babelCompilerManipulationNormalize(fn.toString().trim());
        const preparedParams = convertParams(params);
      
        // Don't parse dummy functions
      Severity: Major
      Found in src/compilers/route.js - About 7 hrs to fix

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

        export default function send(result) {
          if (!result) {
            result = '';
          } else if (typeof result === 'object') {
            this.setHeader('Content-Type', 'application/json; charset=utf-8');
        Severity: Minor
        Found in src/response-proto/http/response-chunks/send.js - About 6 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

        Function wsExpose has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        Route.prototype.ws = function wsExpose(path, handler, options = {}) {
          const { _baseUrl, _module, _ajv, _app } = this;
          const { isRaw, isStrictRaw, schema } = options;
        
          if (typeof handler === 'object') {
        Severity: Minor
        Found in src/Route.js - About 4 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

        Function use has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

          use(path, ...middlewares) {
            let { _middlewares } = this;
        
            if (!_middlewares) {
              _middlewares = [];
        Severity: Minor
        Found in src/Route.js - About 4 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

        Function webRTCServer has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          app.webRTCServer = (path = '/webrtc', options = {}, ajv = null) => {
            const connections = {};
        
            app.ws(
              path,
        Severity: Major
        Found in src/packed/defines/webrtc-server.js - About 3 hrs to fix

          Function wsExpose has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Route.prototype.ws = function wsExpose(path, handler, options = {}) {
            const { _baseUrl, _module, _ajv, _app } = this;
            const { isRaw, isStrictRaw, schema } = options;
          
            if (typeof handler === 'object') {
          Severity: Major
          Found in src/Route.js - About 3 hrs to fix

            Function pipe has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function pipe(stream, size, compressed = false) {
              const { __request: req } = this;
              const { onAborted, headers, responseHeaders } = req;
              let isAborted = false;
            
            
            Severity: Major
            Found in src/response-proto/http/response-chunks/pipe.js - About 3 hrs to fix

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

                listen(port, host) {
                  const {
                    _config: config,
                    _app: app,
                    _routeCalled,
              Severity: Major
              Found in src/App.js - About 3 hrs to fix

                Function prepareProxy has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                const prepareProxy = (
                  path,
                  {
                    url,
                    method,
                Severity: Minor
                Found in src/packed/defines/proxy.js - About 2 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

                Function modifyEnd has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function modifyEnd() {
                  if (!this._modifiedEnd) {
                    const _oldEnd = this.end;
                
                    this.end = function modifiedEnd(chunk, encoding) {
                Severity: Minor
                Found in src/response-proto/http/response-chunks/modify-end.js - About 2 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

                Function use has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  use(path, ...middlewares) {
                    let { _middlewares } = this;
                
                    if (!_middlewares) {
                      _middlewares = [];
                Severity: Major
                Found in src/Route.js - About 2 hrs to fix

                  Function normalizeLocation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const normalizeLocation = (path, config, host) => {
                    if (path.indexOf('http') === -1) {
                      if (path.indexOf('/') === -1) {
                        path = `/${path}`;
                      }
                  Severity: Minor
                  Found in src/response-proto/http/polyfill-chunks/redirect.js - About 2 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

                  Function sendFile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function sendFile(
                    path,
                    lastModified = true,
                    compressed = false
                  ) {
                  Severity: Minor
                  Found in src/helpers/send-file.js - 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 sendFile has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function sendFile(
                    path,
                    lastModified = true,
                    compressed = false
                  ) {
                  Severity: Minor
                  Found in src/helpers/send-file.js - About 1 hr to fix

                    Function http has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      prepared.http = async (res, req) => {
                        // Allow waiting for request finishing
                        let isAborted = false;
                        res.onAborted(() => {
                          isAborted = true;
                    Severity: Minor
                    Found in src/packed/defines/proxy.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language