rbarros/slim.js

View on GitHub

Showing 33 of 33 total issues

Function exports has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt) {
  // load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns
  require('load-grunt-tasks')(grunt);

  // Configuração da aplicação
Severity: Major
Found in Gruntfile.js - About 3 hrs to fix

    File SlimCore.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * Classe SlimCore
     *
     * @author Ramon Barros [contato@ramon-barros.com]
     * @date   2018-09-21
    Severity: Minor
    Found in src/SlimCore.js - About 2 hrs to fix

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

        SlimCore.prototype.put = function(uri, callback) {
          this.tmp.method = 'put';
          this.tmp.uri = uri;
          this.routes.put[uri.replace(/^\//, '')] = callback;
          return this;
      Severity: Major
      Found in src/SlimCore.js and 4 other locations - About 2 hrs to fix
      src/SlimCore.js on lines 305..310
      src/SlimCore.js on lines 318..323
      src/SlimCore.js on lines 344..349
      src/SlimCore.js on lines 357..362

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

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

        SlimCore.prototype.get = function(uri, callback) {
          this.tmp.method = 'get';
          this.tmp.uri = uri;
          this.routes.get[uri.replace(/^\//, '')] = callback;
          return this;
      Severity: Major
      Found in src/SlimCore.js and 4 other locations - About 2 hrs to fix
      src/SlimCore.js on lines 318..323
      src/SlimCore.js on lines 331..336
      src/SlimCore.js on lines 344..349
      src/SlimCore.js on lines 357..362

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

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

        SlimCore.prototype.post = function(uri, callback) {
          this.tmp.method = 'post';
          this.tmp.uri = uri;
          this.routes.post[uri.replace(/^\//, '')] = callback;
          return this;
      Severity: Major
      Found in src/SlimCore.js and 4 other locations - About 2 hrs to fix
      src/SlimCore.js on lines 305..310
      src/SlimCore.js on lines 331..336
      src/SlimCore.js on lines 344..349
      src/SlimCore.js on lines 357..362

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

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

        SlimCore.prototype.delete = function(uri, callback) {
          this.tmp.method = 'delete';
          this.tmp.uri = uri;
          this.routes.delete[uri.replace(/^\//, '')] = callback;
          return this;
      Severity: Major
      Found in src/SlimCore.js and 4 other locations - About 2 hrs to fix
      src/SlimCore.js on lines 305..310
      src/SlimCore.js on lines 318..323
      src/SlimCore.js on lines 331..336
      src/SlimCore.js on lines 344..349

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

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

        SlimCore.prototype.patch = function(uri, callback) {
          this.tmp.method = 'patch';
          this.tmp.uri = uri;
          this.routes.patch[uri.replace(/^\//, '')] = callback;
          return this;
      Severity: Major
      Found in src/SlimCore.js and 4 other locations - About 2 hrs to fix
      src/SlimCore.js on lines 305..310
      src/SlimCore.js on lines 318..323
      src/SlimCore.js on lines 331..336
      src/SlimCore.js on lines 357..362

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

      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 routers has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        SlimCore.prototype.routers = function() {
          console.log('SlimCore:routers()');
          var self = this;
          $(document).on('click', '[ui-sref], [sm-ref]', function (e) {
            e.preventDefault();
      Severity: Major
      Found in src/SlimCore.js - About 2 hrs to fix

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

          var SlimCore = function() {
            this.view = null;
            this.router = null;
            this.options = null;
            this.params = [];
        Severity: Minor
        Found in src/SlimCore.js - About 1 hr to fix

          Function getParamsFromRouter has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            SlimCore.prototype.getParamsFromRouter = function(rule, pathParts, queryParts) {
              var params = {},
                  missingParams = {},
                  parts = rule.split('/', 50);
          
          
          Severity: Minor
          Found in src/SlimCore.js - About 1 hr to fix

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

              Promise.all = function (arr) {
                var args = Array.prototype.slice.call(arr);
            
                return new Promise(function (resolve, reject) {
                  if (args.length === 0) {
            Severity: Minor
            Found in src/Promise.js - About 1 hr to fix

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

                    if (el && el.nodeName || el === window) {
                      el.addEventListener(type, fn, false);
                    } else if (el && el.length) {
                      for (i; i < el.length; i++) {
                        window.EventListener.addEvent(el[i], type, fn);
              Severity: Major
              Found in src/EventListener.js and 1 other location - About 1 hr to fix
              src/EventListener.js on lines 83..91

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

              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

                    if (el && el.nodeName || el === window) {
                      el.document.body.attachEvent('on' + type, function () {
                        return fn.call(el, window.event, window.EventListener);
                      });
                    } else if (el && el.length) {
              Severity: Major
              Found in src/EventListener.js and 1 other location - About 1 hr to fix
              src/EventListener.js on lines 75..81

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

              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 request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                SlimCore.prototype.request = function(method, url, params, async) {
                  console.log('SlimCore:request['+method+']['+url+']');
                  var jqxhr,
                      processData = !(params instanceof FormData), // default: true, application/x-www-form-urlencoded: false (Don't process the files)
                      // Set content type to false as jQuery will tell the server its a query string request
              Severity: Minor
              Found in src/SlimCore.js - About 1 hr to fix

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

                  var SlimExtensions = function() {
                    this.extensions = {
                      router: function() {
                        var $app = this;
                        Twig.extendFunction('route', function(name, params) {
                Severity: Minor
                Found in src/SlimExtensions.js - About 1 hr to fix

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

                      SlimDebug.prototype.error = function(arg) {
                          var self = this;
                          this.console.error('SlimDebug: ' + self.caller(), arg);
                      };
                  Severity: Major
                  Found in src/SlimDebug.js and 13 other locations - About 1 hr to fix
                  src/SlimDebug.js on lines 50..53
                  src/SlimDebug.js on lines 55..58
                  src/SlimDebug.js on lines 60..63
                  src/SlimDebug.js on lines 65..68
                  src/SlimDebug.js on lines 70..73
                  src/SlimDebug.js on lines 80..83
                  src/SlimDebug.js on lines 85..88
                  src/SlimDebug.js on lines 90..93
                  src/SlimDebug.js on lines 95..98
                  src/SlimDebug.js on lines 100..103
                  src/SlimDebug.js on lines 105..108
                  src/SlimDebug.js on lines 110..113
                  src/SlimDebug.js on lines 115..118

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

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

                      SlimDebug.prototype.exception = function(arg) {
                          var self = this;
                          this.console.exception('SlimDebug: ' + self.caller(), arg);
                      };
                  Severity: Major
                  Found in src/SlimDebug.js and 13 other locations - About 1 hr to fix
                  src/SlimDebug.js on lines 50..53
                  src/SlimDebug.js on lines 55..58
                  src/SlimDebug.js on lines 60..63
                  src/SlimDebug.js on lines 65..68
                  src/SlimDebug.js on lines 70..73
                  src/SlimDebug.js on lines 75..78
                  src/SlimDebug.js on lines 85..88
                  src/SlimDebug.js on lines 90..93
                  src/SlimDebug.js on lines 95..98
                  src/SlimDebug.js on lines 100..103
                  src/SlimDebug.js on lines 105..108
                  src/SlimDebug.js on lines 110..113
                  src/SlimDebug.js on lines 115..118

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

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

                      SlimDebug.prototype.groupCollapsed = function(arg) {
                          var self = this;
                          this.console.groupCollapsed('SlimDebug: ' + self.caller(), arg);
                      };
                  Severity: Major
                  Found in src/SlimDebug.js and 13 other locations - About 1 hr to fix
                  src/SlimDebug.js on lines 50..53
                  src/SlimDebug.js on lines 55..58
                  src/SlimDebug.js on lines 60..63
                  src/SlimDebug.js on lines 65..68
                  src/SlimDebug.js on lines 70..73
                  src/SlimDebug.js on lines 75..78
                  src/SlimDebug.js on lines 80..83
                  src/SlimDebug.js on lines 85..88
                  src/SlimDebug.js on lines 95..98
                  src/SlimDebug.js on lines 100..103
                  src/SlimDebug.js on lines 105..108
                  src/SlimDebug.js on lines 110..113
                  src/SlimDebug.js on lines 115..118

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

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

                      SlimDebug.prototype.info = function(arg) {
                          var self = this;
                          this.console.info('SlimDebug: ' + self.caller(), arg);
                      };
                  Severity: Major
                  Found in src/SlimDebug.js and 13 other locations - About 1 hr to fix
                  src/SlimDebug.js on lines 50..53
                  src/SlimDebug.js on lines 55..58
                  src/SlimDebug.js on lines 60..63
                  src/SlimDebug.js on lines 65..68
                  src/SlimDebug.js on lines 70..73
                  src/SlimDebug.js on lines 75..78
                  src/SlimDebug.js on lines 80..83
                  src/SlimDebug.js on lines 85..88
                  src/SlimDebug.js on lines 90..93
                  src/SlimDebug.js on lines 95..98
                  src/SlimDebug.js on lines 105..108
                  src/SlimDebug.js on lines 110..113
                  src/SlimDebug.js on lines 115..118

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

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

                      SlimDebug.prototype.assert = function(arg) {
                          var self = this;
                          this.console.assert('SlimDebug: ' + self.caller(), arg);
                      };
                  Severity: Major
                  Found in src/SlimDebug.js and 13 other locations - About 1 hr to fix
                  src/SlimDebug.js on lines 55..58
                  src/SlimDebug.js on lines 60..63
                  src/SlimDebug.js on lines 65..68
                  src/SlimDebug.js on lines 70..73
                  src/SlimDebug.js on lines 75..78
                  src/SlimDebug.js on lines 80..83
                  src/SlimDebug.js on lines 85..88
                  src/SlimDebug.js on lines 90..93
                  src/SlimDebug.js on lines 95..98
                  src/SlimDebug.js on lines 100..103
                  src/SlimDebug.js on lines 105..108
                  src/SlimDebug.js on lines 110..113
                  src/SlimDebug.js on lines 115..118

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language