apantle/awsome-factory-associator

View on GitHub

Showing 12 of 12 total issues

File Definition.js has 430 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const Promise = require('bluebird');
const Collection = require('./Collection');
const utils = require('./utils');
const _ = require('lodash');
const debug = require('debug');
Severity: Minor
Found in lib/Definition.js - About 6 hrs to fix

    Definition has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Definition {
      constructor(factory, name, model) {
        const creatingFromCopy = factory instanceof Definition;
        const defaultRetries = 1;
    
    
    Severity: Minor
    Found in lib/Definition.js - About 2 hrs to fix

      Function _doCreate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _doCreate(saved) {
          const isRootCreation = !saved;
          let createdModel;
      
          if (isRootCreation) {
      Severity: Minor
      Found in lib/Definition.js - About 1 hr to fix

        Function getIfSavedAtttribute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function getIfSavedAtttribute(saved, phrase) {
          const isASavedPhrase = typeof phrase == 'string' && phrase.charAt(0) == '$';
        
          if (!isASavedPhrase) {
            return phrase;
        Severity: Minor
        Found in lib/utils.js - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function getIfSavedAtttribute has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getIfSavedAtttribute(saved, phrase) {
          const isASavedPhrase = typeof phrase == 'string' && phrase.charAt(0) == '$';
        
          if (!isASavedPhrase) {
            return phrase;
        Severity: Minor
        Found in lib/utils.js - About 1 hr to fix

          Function clone has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function clone(object) {
            if (object instanceof Collection) {
              return object;
            } else if (Array.isArray(object)) {
              return object.map(clone);
          Severity: Minor
          Found in lib/utils.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

            getValidAssociation(as, type) {
              if (!this.model) {
                throw new Error(
                  'No model defined for factory ' +
                    this.name +
          Severity: Minor
          Found in lib/Definition.js - About 1 hr to fix

            Function retryCreate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              async retryCreate(saved) {
                let tries = 0;
                let out;
                let reason;
            
            
            Severity: Minor
            Found in lib/Definition.js - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function addOptionsToConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              addOptionsToConfig(options) {
                if (!this.model) {
                  throw new Error(
                    'No model defined for factory ' +
                      this.name +
            Severity: Minor
            Found in lib/Definition.js - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              constructor(factory, name, model) {
                const creatingFromCopy = factory instanceof Definition;
                const defaultRetries = 1;
            
                this.creationRetries = parseInt(process.env.AFA_RETRIES, 10);
            Severity: Minor
            Found in lib/Definition.js - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Avoid too many return statements within this function.
            Open

                return object;
            Severity: Major
            Found in lib/utils.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return objectConed;
              Severity: Major
              Found in lib/utils.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language