yoctore/yoctopus-generator

View on GitHub
app/templates/applications/angular/_services.js

Summary

Maintainability
D
1 day
Test Coverage

File _services.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/**
 * A Logger utility service
 *
Severity: Minor
Found in app/templates/applications/angular/_services.js - About 3 hrs to fix

    Function build has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        build : function (activeMock) {
          // mock is active ?
          if (activeMock) {
            $http.get('assets/mocks/mocks.json').then(function successCallback (success) {
              // check if the success.data has expectRoutes
    Severity: Major
    Found in app/templates/applications/angular/_services.js - About 2 hrs to fix

      Method 'process' has a complexity of 10.
      Open

          process : function (key, properties, config) {

      Limit Cyclomatic Complexity (complexity)

      Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

      function a(x) {
          if (true) {
              return x; // 1st path
          } else if (false) {
              return x+1; // 2nd path
          } else {
              return 4; // 3rd path
          }
      }

      Rule Details

      This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

      Examples of incorrect code for a maximum of 2:

      /*eslint complexity: ["error", 2]*/
      
      function a(x) {
          if (true) {
              return x;
          } else if (false) {
              return x+1;
          } else {
              return 4; // 3rd path
          }
      }

      Examples of correct code for a maximum of 2:

      /*eslint complexity: ["error", 2]*/
      
      function a(x) {
          if (true) {
              return x;
          } else {
              return 4;
          }
      }

      Options

      Optionally, you may specify a max object property:

      "complexity": ["error", 2]

      is equivalent to

      "complexity": ["error", { "max": 2 }]

      Deprecated: the object property maximum is deprecated. Please use the property max instead.

      When Not To Use It

      If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

      Further Reading

      Related Rules

      • [max-depth](max-depth.md)
      • [max-len](max-len.md)
      • [max-nested-callbacks](max-nested-callbacks.md)
      • [max-params](max-params.md)
      • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

      Function process has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          process : function (key, properties, config) {
            // normalize properties
            properties    = _.isObject(properties) ? properties : {};
      
            // normalize config
      Severity: Major
      Found in app/templates/applications/angular/_services.js - About 2 hrs to fix

        Function successCallback has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                $http.get('assets/mocks/mocks.json').then(function successCallback (success) {
                  // check if the success.data has expectRoutes
                  if (_.has(success.data, 'expectRoutes')) {
                    // Parse the success.data.expectRoutes to build expect $httpBackend routes
                    _.forEach(success.data.expectRoutes, function (obj) {
        Severity: Minor
        Found in app/templates/applications/angular/_services.js - About 1 hr to fix

          The function binding is unnecessary.
          Open

                  }.bind(this), function (error) {

          Disallow unnecessary function binding (no-extra-bind)

          The bind() method is used to create functions with specific this values and, optionally, binds arguments to specific values. When used to specify the value of this, it's important that the function actually use this in its function body. For example:

          var boundGetName = (function getName() {
              return this.name;
          }).bind({ name: "ESLint" });
          
          console.log(boundGetName());      // "ESLint"

          This code is an example of a good use of bind() for setting the value of this.

          Sometimes during the course of code maintenance, the this value is removed from the function body. In that case, you can end up with a call to bind() that doesn't accomplish anything:

          // useless bind
          var boundGetName = (function getName() {
              return "ESLint";
          }).bind({ name: "ESLint" });
          
          console.log(boundGetName());      // "ESLint"

          In this code, the reference to this has been removed but bind() is still used. In this case, the bind() is unnecessary overhead (and a performance hit) and can be safely removed.

          Rule Details

          This rule is aimed at avoiding the unnecessary use of bind() and as such will warn whenever an immediately-invoked function expression (IIFE) is using bind() and doesn't have an appropriate this value. This rule won't flag usage of bind() that includes function argument binding.

          Note: Arrow functions can never have their this value set using bind(). This rule flags all uses of bind() with arrow functions as a problem

          Examples of incorrect code for this rule:

          /*eslint no-extra-bind: "error"*/
          /*eslint-env es6*/
          
          var x = function () {
              foo();
          }.bind(bar);
          
          var x = (() => {
              foo();
          }).bind(bar);
          
          var x = (() => {
              this.foo();
          }).bind(bar);
          
          var x = function () {
              (function () {
                this.foo();
              }());
          }.bind(bar);
          
          var x = function () {
              function foo() {
                this.bar();
              }
          }.bind(baz);

          Examples of correct code for this rule:

          /*eslint no-extra-bind: "error"*/
          
          var x = function () {
              this.foo();
          }.bind(bar);
          
          var x = function (a) {
              return a + 1;
          }.bind(foo, bar);

          When Not To Use It

          If you are not concerned about unnecessary calls to bind(), you can safely disable this rule.

          Further Reading

          unnecessary '.call()'.
          Open

                this[type].call(this, params);

          Disallow unnecessary .call() and .apply(). (no-useless-call)

          The function invocation can be written by Function.prototype.call() and Function.prototype.apply(). But Function.prototype.call() and Function.prototype.apply() are slower than the normal function invocation.

          Rule Details

          This rule is aimed to flag usage of Function.prototype.call() and Function.prototype.apply() that can be replaced with the normal function invocation.

          Examples of incorrect code for this rule:

          /*eslint no-useless-call: "error"*/
          
          // These are same as `foo(1, 2, 3);`
          foo.call(undefined, 1, 2, 3);
          foo.apply(undefined, [1, 2, 3]);
          foo.call(null, 1, 2, 3);
          foo.apply(null, [1, 2, 3]);
          
          // These are same as `obj.foo(1, 2, 3);`
          obj.foo.call(obj, 1, 2, 3);
          obj.foo.apply(obj, [1, 2, 3]);

          Examples of correct code for this rule:

          /*eslint no-useless-call: "error"*/
          
          // The `this` binding is different.
          foo.call(obj, 1, 2, 3);
          foo.apply(obj, [1, 2, 3]);
          obj.foo.call(null, 1, 2, 3);
          obj.foo.apply(null, [1, 2, 3]);
          obj.foo.call(otherObj, 1, 2, 3);
          obj.foo.apply(otherObj, [1, 2, 3]);
          
          // The argument list is variadic.
          foo.apply(undefined, args);
          foo.apply(null, args);
          obj.foo.apply(obj, args);

          Known Limitations

          This rule compares code statically to check whether or not thisArg is changed. So if the code about thisArg is a dynamic expression, this rule cannot judge correctly.

          Examples of incorrect code for this rule:

          /*eslint no-useless-call: "error"*/
          
          a[i++].foo.call(a[i++], 1, 2, 3);

          Examples of correct code for this rule:

          /*eslint no-useless-call: "error"*/
          
          a[++i].foo.call(a[i], 1, 2, 3);

          When Not To Use It

          If you don't want to be notified about unnecessary .call() and .apply(), you can safely disable this rule. Source: http://eslint.org/docs/rules/

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

              warn : function (message) {
                // process notify
                this.notify(message, 'warning');
                // only if debug is activated
                if (appConstants.keys().debug) {
          Severity: Major
          Found in app/templates/applications/angular/_services.js and 1 other location - About 1 hr to fix
          app/templates/applications/angular/_services.js on lines 70..78

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

          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

              error : function (message) {
                // process notify
                this.notify(message, 'error');
                // only if debug is activated
                if (appConstants.keys().debug) {
          Severity: Major
          Found in app/templates/applications/angular/_services.js and 1 other location - About 1 hr to fix
          app/templates/applications/angular/_services.js on lines 58..66

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

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

              info : function (message) {
                // only if debug is activated
                if (appConstants.keys().debug) {
                  // default log process
                  $log.info(message);
          Severity: Minor
          Found in app/templates/applications/angular/_services.js and 2 other locations - About 35 mins to fix
          app/templates/applications/angular/_services.js on lines 38..44
          app/templates/applications/angular/_services.js on lines 82..88

          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

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

              log : function (message) {
                // only if debug is activated
                if (appConstants.keys().debug) {
                  // default log process
                  $log.log(message);
          Severity: Minor
          Found in app/templates/applications/angular/_services.js and 2 other locations - About 35 mins to fix
          app/templates/applications/angular/_services.js on lines 48..54
          app/templates/applications/angular/_services.js on lines 82..88

          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

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

              debug : function (message) {
                // only if debug is activated
                if (appConstants.keys().debug) {
                  // default log process
                  $log.debug(message);
          Severity: Minor
          Found in app/templates/applications/angular/_services.js and 2 other locations - About 35 mins to fix
          app/templates/applications/angular/_services.js on lines 38..44
          app/templates/applications/angular/_services.js on lines 48..54

          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

          There are no issues that match your filters.

          Category
          Status