csballz/koala-puree

View on GitHub

Showing 580 of 580 total issues

Function setup has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        setup: function*(next) {
      // precompile all files to .tmp
            debug("Reaching koala puree dust middleware");
            var app = this._app;
            var dust;
Severity: Minor
Found in lib/dust.js - About 1 hr to fix

    Function Browser has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var Browser=function(){
      // first search for all possible mdns
      // locate the first dnscache
      // if not located, continue caching everything
      // once located, switch off all browser, and start listening to only dnscache
    Severity: Minor
    Found in lib/service.js - About 1 hr to fix

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

                function* startServer(next){
                    debug("starting startServer Mw");
                    require("pmx").init();
                    var server;
                    yield* next;
      Severity: Minor
      Found in index.js - About 1 hr to fix

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

                                    schema.static("findBy"+name, function _reverseLocate(id){
                                        if ( id._id ) {
                                            id = id._id;
                                        }
                                        var self = this;
        Severity: Minor
        Found in lib/models.js - About 1 hr to fix

          Function _getRelation has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                                      schema.method(methodName, function _getRelation(){
                                          var self = this;
                                          var query = this._orientose()
                                                  ._db
                                                  .select()
          Severity: Minor
          Found in lib/models.js - About 1 hr to fix

            Function middleware has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                middleware: function(){
                    return {
                        setup: function *(next) {
                            var app = this;
                            yield (new Promise(function(resolve/*, reject*/){
            Severity: Minor
            Found in lib/service.js - About 1 hr to fix

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

                  function advertise(self) {
                      if ( self._ad ) { self._ad.stop(); }
                      debug("Starting mdns middleware");
                      debug(self._config);
                      var adSettings = {
              Severity: Minor
              Found in lib/mdns.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                            if (!app._config.db || !app._config.db.url) {
                                let config = app._config.db || {};
                                let username = config.username || "root";
                                let password = config.password || "root";
                                let host = config.host || "localhost";
                Severity: Critical
                Found in lib/models.js - About 1 hr to fix

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

                      get: function(name, ver) {
                          var 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/service.js - About 1 hr to fix

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

                      constructor(mod, config) {
                          super();
                          var closestPath = closest.sync(require("path").dirname(mod.filename));
                          this._basePath = require("path").dirname(closestPath);
                          var pkginfo = require("@shekhei/pkginfo")(mod);
                    Severity: Minor
                    Found in 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 listen has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          app.listen = function listen(port, cb, options) {
                    
                              if (typeof port === "function") options = cb, cb = port, port = null;
                              if ( options === undefined && typeof cb !== "function" ) options = cb, cb = undefined;
                              options = options || {};
                    Severity: Minor
                    Found in index.js - About 1 hr to fix

                      Function seed has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              seed: function(app) {
                                  return new Promise(function(resolve, reject){
                                      glob(require("path").resolve(app._basePath, "db/seed/*.js"), function(er, files) {
                                          if (er) {
                                              return reject(er);
                      Severity: Minor
                      Found in lib/models.js - About 1 hr to fix

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

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

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

                                          this.req.body = function*(){
                          
                                              debug("body generator");
                                              debug("req.body req headers:",self.req.headers);
                                              if ( !self.req.headers["content-length"] && !self.req.headers["transfer-encoding"] ) {
                          Severity: Minor
                          Found in lib/controllers.js - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                                    if ( "link" in rel || "in" in rel || "out" in rel || "both" in rel ) {
                                                        var cond = rel.link || rel.in || rel.out || rel.both;
                                                        var reverseCond;
                                                        if ( "link" !== rel.linkType ) {
                                                            if ( rel.in ) {
                            Severity: Major
                            Found in lib/models.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/service.js - About 1 hr to fix

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

                                                    for (var i = 0; i < builders.length; i++) {
                                                        schemas[builders[i]._name] = builders[i]._schema;
                                                    }
                                Severity: Minor
                                Found in lib/models.js and 1 other location - About 55 mins to fix
                                lib/models.js on lines 451..453

                                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 54.

                                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 2 locations. Consider refactoring.
                                Open

                                                        for (var i = 0; i < builders.length; i++) {
                                                            schemas[builders[i]._name] = builders[i]._schema;
                                                        }
                                Severity: Minor
                                Found in lib/models.js and 1 other location - About 55 mins to fix
                                lib/models.js on lines 427..429

                                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 54.

                                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

                                Avoid deeply nested control flow statements.
                                Open

                                                                if ( one ) {
                                                                    query.limit(1);
                                                                }
                                Severity: Major
                                Found in lib/models.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                                          if ( one ) {
                                                                              return Promise.resolve(model._createDocument(m[0]));
                                                                          }
                                  Severity: Major
                                  Found in lib/models.js - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language