rbarros/slim.js

View on GitHub
src/SlimCore.js

Summary

Maintainability
D
2 days
Test Coverage

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

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

            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

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

                  if (self.routes.hasOwnProperty(method)) {
                    if (self.routes[method].hasOwnProperty(action)) {
                      e.stopPropagation(); // Stop stuff happening
                      e.preventDefault(); // Totally stop stuff happening
                      self.params = [];
            Severity: Minor
            Found in src/SlimCore.js and 1 other location - About 50 mins to fix
            src/SlimCore.js on lines 184..190

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

            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

                    } else if (action.match('http')) {
                      return;
                    } else {
                      e.stopPropagation(); // Stop stuff happening
                      e.preventDefault(); // Totally stop stuff happening
            Severity: Minor
            Found in src/SlimCore.js and 1 other location - About 50 mins to fix
            src/SlimCore.js on lines 166..195

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

            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

            There are no issues that match your filters.

            Category
            Status