Showing 37 of 141 total issues

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

exports = module.exports = function decorate(leaf, options) {
  options = options || {};

  let koa = leaf.koa;
  // koa request
Severity: Minor
Found in lib/decorator/index.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 constructor has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(mod, config) {
    super();
    if (!(this instanceof Leaf)) return new Leaf(mod, config);
    logger(`root pwd is ${pathModule.resolve(".")}`);

Severity: Minor
Found in index.js - About 1 hr to fix

    Function get has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      get(name, ver) {
        let time = new Date();
        // think of a way to refactor this into a generator, so we can just store that as a cache and yield everytime
        // hopeful usage would be:
        // var service = cache[service@version].next();
    Severity: Minor
    Found in lib/provider/browser.js - About 1 hr to fix

      Function initialize has a Cognitive Complexity of 12 (exceeds 5 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 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 advertise has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        advertise(leaf) {
          if (leaf._ad) {
            leaf._ad.stop();
          }
          let adSettings = {
      Severity: Minor
      Found in lib/provider/mdns.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 advertise has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        advertise(leaf) {
          if (leaf._ad) {
            leaf._ad.stop();
          }
          let adSettings = {
      Severity: Minor
      Found in lib/provider/mdns.js - About 1 hr to fix

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

        exports = module.exports = function(options) {
          options = options || {};
        
          if (!options.calculate) {
            var hash = options.hash;
        Severity: Minor
        Found in lib/middleware/conditional-get.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 exports has 30 lines of code (exceeds 25 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 1 hr to fix

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

              req.logIn = function (user, options, done) {
                if (typeof options == "function") { // arguments is user, done
                  done = options;
                  options = {};
                }
          Severity: Minor
          Found in lib/decorator/passport-req.js - About 1 hr to fix

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

                  function resolver() {
                    logger("looping through browser caches");
                    // keep trying for a specific amount of time, now hard coded, 1s
                    if (new Date() - time > 2000) {
                      logger("timeout");
            Severity: Minor
            Found in lib/provider/browser.js - About 1 hr to fix

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

                    this.res.pushStatic = ((reqPath, originalPath) => {
                      let rs = this.res;
                      if (reqPath.startsWith(path)) {
                        // first implement a naive implementation
                        let stream = this.res.push(originalPath, {
              Severity: Minor
              Found in lib/middleware/static-server.js - About 1 hr to fix

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

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

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

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

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

                          this.req.body = function*() {
                            logger("req.body req headers:", self.req.headers, body);
                            if (!self.req.headers["content-length"] && !self.req.headers["transfer-encoding"]) {
                              logger("it doesnt have content-length neither does it have transfer-encoding, set it empty");
                              body = {};
                    Severity: Minor
                    Found in lib/middleware/body.js - About 1 hr to fix

                      Function _request has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          function _request(sc, path, nsp, method, data, headers, resolve, reject) {
                      Severity: Major
                      Found in lib/provider/service.js - About 1 hr to fix

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

                          response.cacheControl = function(maxage) {
                            if (maxage === false) {
                              this.set('Cache-Control', 'private, no-cache');
                              return this;
                            }
                        Severity: Minor
                        Found in lib/decorator/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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          constructor(mod, config) {
                            super();
                            if (!(this instanceof Leaf)) return new Leaf(mod, config);
                            logger(`root pwd is ${pathModule.resolve(".")}`);
                        
                        
                        Severity: Minor
                        Found in index.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