Showing 37 of 141 total issues

Function decorate has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

exports = module.exports = function decorate(req) {

  /**
   * Intiate a login session for `user`.
   *
Severity: Minor
Found in lib/decorator/passport-req.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 initialize has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  * initialize(next) {
    let koa = this.koa;

    logger("using leafjs body middleware");

Severity: Minor
Found in lib/middleware/body.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 initialize has 106 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  * initialize(next) {
    logger("using leafjs socketio middleware");

    let leaf = this;
    let koa = leaf.koa;
Severity: Major
Found in lib/middleware/socketio.js - About 4 hrs to fix

    Function initialize has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      * initialize(next) {
        yield * next;
        logger("using leafjs controller middleware");
        let leaf = this;
        let koa = leaf.koa;
    Severity: Major
    Found in lib/middleware/controllers.js - About 3 hrs to fix

      Function exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      exports = module.exports = function( options ) {
        options = options || {};
      
        let hsts;
        if (options.hsts) {
      Severity: Minor
      Found in lib/middleware/headers.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 start has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        start(app, forConsole) {
          let leaf = this;
          leaf._forConsole = forConsole;
      
          return new Promise((resolve, reject) => {
      Severity: Major
      Found in index.js - About 3 hrs to fix

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

          * initialize(next) {
            yield * next;
            logger("using leafjs controller middleware");
            let leaf = this;
            let koa = leaf.koa;
        Severity: Minor
        Found in lib/middleware/controllers.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 request has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          request(method, path, data, headers) {
            logger(`calling general request helper: start`);
        
            function _request(sc, path, nsp, method, data, headers, resolve, reject) {
              let realPath = "";
        Severity: Major
        Found in lib/provider/service.js - About 2 hrs to fix

          Function initialize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            * initialize(next) {
              logger("using leafjs socketio middleware");
          
              let leaf = this;
              let koa = leaf.koa;
          Severity: Minor
          Found in lib/middleware/socketio.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 initialize has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            * initialize(next) {
              let koa = this.koa;
          
              logger("using leafjs body middleware");
          
          
          Severity: Major
          Found in lib/middleware/body.js - About 2 hrs to fix

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

              constructor() {
                function serviceUp(service) {
                  logger(`serviceup: ${service.type.name}`, service);
                  if (service.type.name !== "leaf") {
                    logger('ignoring service, service name not leaf');
            Severity: Major
            Found in lib/provider/browser.js - About 2 hrs to fix

              Function bodyParseMiddleware has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  koa.use(function* bodyParseMiddleware(next) {
                    let body, parts;
                    let contentType = this.req.headers['content-type'],
                      contentLength = this.req.headers["content-length"],
                      transferEncoding = this.req.headers["transfer-encoding"];
              Severity: Major
              Found in lib/middleware/body.js - About 2 hrs to fix

                Function handler has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function handler(origHeaders) {
                      logger("delete accept-encoding in origHeaders");
                      delete origHeaders["accept-encoding"];
                      return function _handler(method, route, data, headers, cb) {
                        logger(`trigger socket.io s handler, with (${method}, ${route}, ${data}, ${headers})`);
                Severity: Major
                Found in lib/middleware/socketio.js - About 2 hrs to fix

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

                    constructor() {
                      function serviceUp(service) {
                        logger(`serviceup: ${service.type.name}`, service);
                        if (service.type.name !== "leaf") {
                          logger('ignoring service, service name not leaf');
                  Severity: Minor
                  Found in lib/provider/browser.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 decorate has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports = module.exports = function decorate(leaf, options) {
                    options = options || {};
                  
                    let koa = leaf.koa;
                    // koa request
                  Severity: Major
                  Found in lib/decorator/index.js - About 2 hrs to fix

                    Function _handler has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          return function _handler(method, route, data, headers, cb) {
                            logger(`trigger socket.io s handler, with (${method}, ${route}, ${data}, ${headers})`);
                            if (undefined === cb) { //arguments is method, route, headers, cb
                              cb = headers;
                              headers = data;
                    Severity: Major
                    Found in lib/middleware/socketio.js - About 2 hrs to fix

                      Function decorate has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports = module.exports = function decorate(req) {
                      
                        /**
                         * Intiate a login session for `user`.
                         *
                      Severity: Major
                      Found in lib/decorator/passport-req.js - About 2 hrs to fix

                        Function initialize has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          * initialize(next) {
                            logger("using leaf static server middleware");
                            let leaf = this;
                            let koa = this.koa;
                        
                        
                        Severity: Minor
                        Found in lib/middleware/static-server.js - About 2 hrs to fix

                          Function startServer has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                let serverMw = function* startServer(next) {
                                  logger("require pmx and initalizing");
                                  require("pmx").init();
                          
                                  yield * next;
                          Severity: Minor
                          Found in index.js - About 1 hr to fix

                            Function staticServer has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                koa.use(function* staticServer(next) {
                                  let path = options.uri;
                                  if (this.request.path) {
                                    if (leaf.namespace && leaf.namespace !== "/") {
                                      path = leaf.namespace + path;
                            Severity: Minor
                            Found in lib/middleware/static-server.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language