GCSBOSS/nodecaf

View on GitHub

Showing 14 of 14 total issues

Function serialize has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

function serialize(key, val, options) {
    const opt = options ?? {};
    
    if(!fieldContentRegExp.test(key)) 
        throw new TypeError('argument name is invalid');
Severity: Minor
Found in lib/cookie.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 serialize has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function serialize(key, val, options) {
    const opt = options ?? {};
    
    if(!fieldContentRegExp.test(key)) 
        throw new TypeError('argument name is invalid');
Severity: Major
Found in lib/cookie.js - About 2 hrs to fix

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

    function parse(header) {
        if(typeof header !== 'string') 
            throw new TypeError('argument str must be a string');
    
        const obj = {}
    Severity: Minor
    Found in lib/cookie.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 trigger has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async trigger(method, path, input){
            method = method.toUpperCase();
            const params = {};
    
            const app = this.context;
    Severity: Minor
    Found in lib/api.js - About 1 hr to fix

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

      function parse(header) {
          if(typeof header !== 'string') 
              throw new TypeError('argument str must be a string');
      
          const obj = {}
      Severity: Minor
      Found in lib/cookie.js - About 1 hr to fix

        Function trigger has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async trigger(method, path, input = {}){
        
                if(!(input.body instanceof Readable)){
                    const ob = input.body ?? '';
                    const oh = input.headers ?? {};
        Severity: Minor
        Found in lib/main.js - About 1 hr to fix

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

          function initCors(opts, origin, res){
          
              const options = { ...DEFAULT_OPTIONS, ...opts };
          
              /* Configure Origin */
          Severity: Minor
          Found in lib/cors.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 trigger has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              async trigger(method, path, input = {}){
          
                  if(!(input.body instanceof Readable)){
                      const ob = input.body ?? '';
                      const oh = input.headers ?? {};
          Severity: Minor
          Found in lib/main.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 matchRoute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function matchRoute(method, path, params){
              // this => API
          
              const route = method + ' ' + path;
              if(route in this.static)
          Severity: Minor
          Found in lib/api.js - About 45 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 validateOpts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function validateOpts(opts){
              if(typeof opts != 'object')
                  throw new TypeError('Options argument must be an object');
          
              this._websocket = opts.websocket;
          Severity: Minor
          Found in lib/main.js - About 45 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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function run(opts = {}){
          
              const app = require(opts.path)();
          
              if(! (app instanceof Nodecaf))
          Severity: Minor
          Found in lib/run.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

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

          function format(str, ...args){
              let lastPos = 0;
              while(args.length > 0){
                  const pos = str.indexOf('%s', lastPos);
                  
          Severity: Minor
          Found in lib/response.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

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

          function handleOptions(opts, neededHeaders, res){
              const options = { ...DEFAULT_OPTIONS, ...opts };
          
              /* Configure Methods */
              const methods = options.methods;
          Severity: Minor
          Found in lib/cors.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 new HTTPError(500, String(thing), 'text');
          Severity: Major
          Found in lib/error.js - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language