Showing 141 of 141 total issues

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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    app.post('/test', function*(next) {
                      var params = yield this.req.body();
                      this.body = "post" + params.name;
                    });
                Severity: Major
                Found in examples/app/Http/Controllers/TestController.js and 1 other location - About 1 hr to fix
                examples/app/Http/Controllers/TestController.js on lines 18..21

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    app.put('/test', function*(next) {
                      var params = yield this.req.body();
                      this.body = "put" + params.name;
                    });
                Severity: Major
                Found in examples/app/Http/Controllers/TestController.js and 1 other location - About 1 hr to fix
                examples/app/Http/Controllers/TestController.js on lines 13..16

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                            leaf._sio.on("connection", function(socket) {
                              logger("trigger custom namespace socket.io connection event");
                              logger("emit leaf sio connection event");
                              leaf.sio.emit("connection", socket);
                            });
                    Severity: Minor
                    Found in lib/middleware/socketio.js and 1 other location - About 50 mins to fix
                    lib/middleware/socketio.js on lines 113..117

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 52.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                              leaf._sio.on("connection", function(socket) {
                                logger("trigger custom namespace socket.io connection event");
                                logger("emit leafjs sio connection event");
                                leaf.sio.emit("connection", socket);
                              });
                    Severity: Minor
                    Found in lib/middleware/socketio.js and 1 other location - About 50 mins to fix
                    lib/middleware/socketio.js on lines 126..130

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 52.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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

                    Identical blocks of code found in 3 locations. Consider refactoring.
                    Open

                          if (this._passport && this._passport.instance) {
                            property = this._passport.instance._userProperty || property;
                          }
                    Severity: Minor
                    Found in lib/decorator/passport-req.js and 2 other locations - About 35 mins to fix
                    lib/decorator/passport-req.js on lines 70..72
                    lib/decorator/passport-req.js on lines 88..90

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 3 locations. Consider refactoring.
                    Open

                        if (this._passport && this._passport.instance) {
                          property = this._passport.instance._userProperty || property;
                        }
                    Severity: Minor
                    Found in lib/decorator/passport-req.js and 2 other locations - About 35 mins to fix
                    lib/decorator/passport-req.js on lines 34..36
                    lib/decorator/passport-req.js on lines 70..72

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 3 locations. Consider refactoring.
                    Open

                          if (this._passport && this._passport.instance) {
                            property = this._passport.instance._userProperty || property;
                          }
                    Severity: Minor
                    Found in lib/decorator/passport-req.js and 2 other locations - About 35 mins to fix
                    lib/decorator/passport-req.js on lines 34..36
                    lib/decorator/passport-req.js on lines 88..90

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    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