jakubrohleder/angular-jsonapi

View on GitHub
src/model/model-linker/model-linker.js

Summary

Maintainability
F
5 days
Test Coverage

Function AngularJsonAPIModelLinkerService has 271 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function AngularJsonAPIModelLinkerService($log) {
    var _this = this;

    _this.toLinkData = toLinkData;

Severity: Major
Found in src/model/model-linker/model-linker.js - About 1 day to fix

    File model-linker.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    (function() {
      'use strict';
    
      angular.module('angular-jsonapi')
      .service('AngularJsonAPIModelLinkerService', AngularJsonAPIModelLinkerService);
    Severity: Minor
    Found in src/model/model-linker/model-linker.js - About 2 hrs to fix

      Function link has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function link(object, key, target, oneWay, form) {
            var schema;
            form = form === undefined ? false : form;
      
            if (object === undefined) {
      Severity: Minor
      Found in src/model/model-linker/model-linker.js - About 1 hr to fix

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

            function __processAddHasOne(object, key, target, form) {
              var reflectionKey = object.schema.relationships[key].reflection;
              var oldReflection = object.relationships[key];
              var reflectionSchema;
              var oldReflectionSchema;
        Severity: Minor
        Found in src/model/model-linker/model-linker.js - About 1 hr to fix

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

              function unlink(object, key, target, oneWay, form) {
          Severity: Minor
          Found in src/model/model-linker/model-linker.js - About 35 mins to fix

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

                function link(object, key, target, oneWay, form) {
            Severity: Minor
            Found in src/model/model-linker/model-linker.js - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                        return [];
              Severity: Major
              Found in src/model/model-linker/model-linker.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return __processAddHasMany(object, key, target, form);
                Severity: Major
                Found in src/model/model-linker/model-linker.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return __processAddHasOne(object, key, target, form);
                  Severity: Major
                  Found in src/model/model-linker/model-linker.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return [];
                    Severity: Major
                    Found in src/model/model-linker/model-linker.js - About 30 mins to fix

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

                            if (target !== undefined && target !== null && reflectionKey !== false) {
                              reflectionSchema = target.schema.relationships[reflectionKey];
                              if (reflectionSchema !== undefined) {
                                if (reflectionSchema.type === 'hasOne') {
                                  __addHasOne(target, reflectionKey, object, form);
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 1 other location - About 5 hrs to fix
                      src/model/model-linker/model-linker.js on lines 178..193

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

                      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 (oldReflection !== undefined && oldReflection !== null) {
                              oldReflectionSchema = oldReflection.schema.relationships[reflectionKey];
                      
                              if (oldReflectionSchema !== undefined) {
                                if (oldReflectionSchema.type === 'hasOne') {
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 1 other location - About 5 hrs to fix
                      src/model/model-linker/model-linker.js on lines 195..209

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

                      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

                            if (target === undefined) {
                              $log.error('Can\'t link non existing object', object, key, target, schema);
                              $log.error('Object:', object.data.type, object);
                              $log.error('Target:', target.data.type, target);
                              $log.error('Key:', key);
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 2 other locations - About 3 hrs to fix
                      src/model/model-linker/model-linker.js on lines 60..67
                      src/model/model-linker/model-linker.js on lines 116..123

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

                      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

                            if (schema === undefined) {
                              $log.error('Can\'t add link not present in schema:', object, key, target, schema);
                              $log.error('Object:', object.data.type, object);
                              $log.error('Target:', target.data.type, target);
                              $log.error('Key:', key);
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 2 other locations - About 3 hrs to fix
                      src/model/model-linker/model-linker.js on lines 51..58
                      src/model/model-linker/model-linker.js on lines 116..123

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

                      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

                            if (schema === undefined) {
                              $log.error('Can\'t remove link not present in schema:', object, key, target, schema);
                              $log.error('Object:', object.data.type, object);
                              $log.error('Target:', target.data.type, target);
                              $log.error('Key:', key);
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 2 other locations - About 3 hrs to fix
                      src/model/model-linker/model-linker.js on lines 51..58
                      src/model/model-linker/model-linker.js on lines 60..67

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

                      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 (object === undefined) {
                              $log.error('Can\'t add link to non existing object', object, key, target);
                              $log.error('Object:', object.data.type, object);
                              $log.error('Target:', target.data.type, target);
                              $log.error('Key:', key);
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 1 other location - About 2 hrs to fix
                      src/model/model-linker/model-linker.js on lines 106..112

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

                      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 (object === undefined) {
                              $log.error('Can\'t remove link from non existing object', object, key, target);
                              $log.error('Object:', object.data.type, object);
                              $log.error('Target:', target.data.type, target);
                              $log.error('Key:', key);
                      Severity: Major
                      Found in src/model/model-linker/model-linker.js and 1 other location - About 2 hrs to fix
                      src/model/model-linker/model-linker.js on lines 41..47

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

                      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

                            } else {
                              $log.error('Cannot find reflection of', key, 'relationship for', object.data.type, 'in', target.data.type);
                              $log.error('For one side relationships set schema.reflection to false');
                              return [];
                            }
                      Severity: Minor
                      Found in src/model/model-linker/model-linker.js and 1 other location - About 45 mins to fix
                      src/model/model-linker/model-linker.js on lines 148..152

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

                      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 (reflectionSchema === undefined) {
                              $log.error('Cannot find reflection of', key, 'relationship for', object.data.type, 'in', target.data.type);
                              $log.error('For one side relationships set schema.reflection to false');
                              return [];
                            } else if (reflectionSchema.type === 'hasOne') {
                      Severity: Minor
                      Found in src/model/model-linker/model-linker.js and 1 other location - About 45 mins to fix
                      src/model/model-linker/model-linker.js on lines 237..241

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

                      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