camelaissani/frontexpress

View on GitHub

Showing 13 of 13 total issues

Function routeMatcher has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

export function routeMatcher(request, route) {
    // check if http method are equals
    if (route.method && route.method !== request.method) {
        return false;
    }
Severity: Minor
Found in lib/router.js - 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

Function routeMatcher has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function routeMatcher(request, route) {
    // check if http method are equals
    if (route.method && route.method !== request.method) {
        return false;
    }
Severity: Minor
Found in lib/router.js - About 1 hr to fix

    Function fetch has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        fetch(request, resolve, reject) {
            const {method, uri, headers=[], data} = request;
    
            const fail = ({status, statusText, errorThrown}) => {
                reject(
    Severity: Minor
    Found in lib/requester.js - About 1 hr to fix

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

          _callMiddlewareMethod(meth, currentRoutes, request, response) {
              if (meth === 'exited') {
                  // currentRoutes, request, response params not needed
                  this.routers.forEach((router) => {
                      router.visited().forEach((route) => {
      Severity: Minor
      Found in lib/application.js - About 1 hr to fix

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

            listen(callback=DEFAULT.callback) {
                const request = {method: 'GET', uri: window.location.pathname + window.location.search};
                const response = {status: 200, statusText: 'OK'};
                const currentRoutes = this._routes(request);
        
        
        Severity: Minor
        Found in lib/application.js - About 1 hr to fix

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

              fetch(request, resolve, reject) {
                  const {method, uri, headers=[], data} = request;
          
                  const fail = ({status, statusText, errorThrown}) => {
                      reject(
          Severity: Minor
          Found in lib/requester.js - 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 uri has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              get uri() {
                  if (!this.uriPart && !this.method) {
                      return undefined;
                  }
          
          
          Severity: Minor
          Found in lib/router.js - 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

          Avoid too many return statements within this function.
          Open

                      return baseUri;
          Severity: Major
          Found in lib/router.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return true;
            Severity: Major
            Found in lib/router.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return this.uriPart;
              Severity: Major
              Found in lib/router.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return route.uri === baseUriToCheck;
                Severity: Major
                Found in lib/router.js - About 30 mins to fix

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

                      use(...args) {
                          let {baseUri, router, middleware, plugin} = toParameters(args);
                          if (plugin) {
                              this.plugins.push(plugin);
                          } else {
                  Severity: Minor
                  Found in lib/application.js - 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

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

                  export function toParameters(args) {
                      let baseUri, middleware, router, plugin, which;
                  
                      args.length === 1 ? [which,] = args : [baseUri, which,] = args;
                  
                  
                  Severity: Minor
                  Found in lib/application.js - 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