apantle/awsome-factory-associator

View on GitHub
lib/Definition.js

Summary

Maintainability
D
1 day
Test Coverage

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

          There are no issues that match your filters.

          Category
          Status