jakubrohleder/angular-jsonapi

View on GitHub
src/collection/collection.factory.js

Summary

Maintainability
D
2 days
Test Coverage

Function AngularJsonAPICollectionWrapper has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function AngularJsonAPICollectionWrapper(
    AngularJsonAPIModelSourceError,
    AngularJsonAPIModelErrorsManager,
    $rootScope,
    $injector,
Severity: Major
Found in src/collection/collection.factory.js - About 5 hrs to fix

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

        function fetch() {
          var _this = this;
          var deferred = $q.defer();
          var $jsonapi = $injector.get('$jsonapi');
          var config = {
    Severity: Major
    Found in src/collection/collection.factory.js - About 2 hrs to fix

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

          function AngularJsonAPICollection(resource, params) {
            var _this = this;
      
            _this.resource = resource;
            _this.type = resource.schema.type;
      Severity: Minor
      Found in src/collection/collection.factory.js - About 1 hr to fix

        Function resolve has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              function resolve(response) {
                var results = $jsonapi.__proccesResults(response.data);
                $rootScope.$emit('angularJsonAPI:' + _this.type + ':collection:fetch', 'resolved', _this, response);
                $q.allSettled(results.included.map(synchronizeIncluded)).then(resolveIncluded, deferred.reject);
        
        
        Severity: Minor
        Found in src/collection/collection.factory.js - About 1 hr to fix

          Function AngularJsonAPICollectionWrapper has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              AngularJsonAPIModelSourceError,
              AngularJsonAPIModelErrorsManager,
              $rootScope,
              $injector,
              $q
          Severity: Minor
          Found in src/collection/collection.factory.js - About 35 mins to fix

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

                    function resolveIncluded(includedResponse) {
                      angular.forEach(includedResponse, function(operation, key) {
                        if (operation.success === true) {
                          $rootScope.$emit('angularJsonAPI:' + results.included[key].data.type + ':object:include', 'resolved', results.included[key], operation);
            
            
            Severity: Major
            Found in src/collection/collection.factory.js and 1 other location - About 4 hrs to fix
            src/model/abstract-model/abstract-model.js on lines 229..238

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

            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

                function hasErrors() {
                  var _this = this;
                  var answer = false;
            
                  angular.forEach(_this.errors, function(error) {
            Severity: Major
            Found in src/collection/collection.factory.js and 1 other location - About 1 hr to fix
            src/model/abstract-model/abstract-model.js on lines 609..618

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

            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

              function __decrementLoadingCounter(object) {
                object = object === undefined ? this : object;
                object.loadingCount -= 1;
                object.loading = object.loadingCount > 0;
              }
            Severity: Major
            Found in src/collection/collection.factory.js and 2 other locations - About 1 hr to fix
            src/model/abstract-model/abstract-model.js on lines 740..744
            src/model/abstract-model/abstract-model.js on lines 752..756

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

            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

                    function synchronizeIncluded(object) {
                      __incrementLoadingCounter(object);
            
                      return object.synchronize({
                        action: 'include',
            Severity: Major
            Found in src/collection/collection.factory.js and 1 other location - About 1 hr to fix
            src/model/abstract-model/abstract-model.js on lines 220..227

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

              function __incrementLoadingCounter(object) {
                object = object === undefined ? this : object;
                object.loadingCount += 1;
                object.loading = true;
              }
            Severity: Minor
            Found in src/collection/collection.factory.js and 1 other location - About 40 mins to fix
            src/model/abstract-model/abstract-model.js on lines 746..750

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

            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