FreeAllMedia/dovima

View on GitHub

Showing 39 of 148 total issues

File model.spec.js has 854 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Testing Dependencies */
import sinon from "sinon";
import Database from "almaden";
import Collection from "../lib/collection.js";
import Model from "../../";
Severity: Major
Found in es6/spec/model.spec.js - About 2 days to fix

    Model has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Model {
        /**
         * @param {Object.<String,*>} [initialAttributes] Provide default values for attributes by passing a Key-Value Object.
         * @constructor
         */
    Severity: Minor
    Found in es6/lib/model/index.js - About 4 hrs to fix

      Function argumentsEqual has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          [argumentsEqual](argumentsA, argumentsB) {
              if (argumentsA === argumentsB) {
                  return true;
              } else {
                  if (argumentsA.length === argumentsB.length) {
      Severity: Minor
      Found in es6/lib/modelFinder.js - About 4 hrs 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

      File modelFinder.js has 357 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* Dependencies */
      import inflect from "jargon";
      import privateData from "incognito";
      
      /* Private Symbols */
      Severity: Minor
      Found in es6/lib/modelFinder.js - About 4 hrs to fix

        Function isPresent has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function isPresent(associationName, callback) {
            const model = this;
            const defaultErrorMessage = "must be present on " + model.constructor.name;
        
          //apiKey
        Severity: Minor
        Found in es6/lib/validation/isPresent.js - About 4 hrs 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

        File index.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* Component Dependencies */
        import Async from "flowsync";
        import inflect from "jargon";
        import privateData from "incognito";
        
        
        Severity: Minor
        Found in es6/lib/model/index.js - About 3 hrs to fix

          ModelQuery has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class ModelQuery {
              constructor(ModelConstructor, options) {
                  const _ = privateData(this);
          
                  _.ModelConstructor = ModelConstructor;
          Severity: Minor
          Found in es6/lib/modelFinder.js - About 3 hrs to fix

            Function saveOrUpdate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            function saveOrUpdate(callback) {
              let now = new Datetime();
            
              const _ = privateData(this);
            
            
            Severity: Minor
            Found in es6/lib/model/save.js - About 2 hrs 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 isPresent has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function isPresent(associationName, callback) {
                const model = this;
                const defaultErrorMessage = "must be present on " + model.constructor.name;
            
              //apiKey
            Severity: Major
            Found in es6/lib/validation/isPresent.js - About 2 hrs to fix

              Function equalTo has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  equalTo(query) {
                      const ourChain = this.chain;
                      const theirChain = query.chain;
              
                      let isEqual = true;
              Severity: Minor
              Found in es6/lib/modelFinder.js - About 2 hrs 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 invalidAttributes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  invalidAttributes(callback) {
                      const _ = privateData(this);
                      const attributeNamesWithValidators = Object.keys(_.validations);
              
                      const compileInvalidAttributeList = (errors, validatorMessages) => {
              Severity: Minor
              Found in es6/lib/model/index.js - About 2 hrs 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 fetchByHasOne has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function fetchByHasOne(associationName, associations, callback) {
                const modelFinder = new ModelFinder(this.database);
                const association = associations[associationName];
                const ModelClass = association.constructor;
              
              
              Severity: Major
              Found in es6/lib/model/fetch.js - About 2 hrs to fix

                Function addAssociation has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function addAssociation (associationDetails) {
                  const association = {
                    parent: this,
                    type: associationDetails.type,
                    constructor: associationDetails.constructor
                Severity: Major
                Found in es6/lib/model/addAssociation.js - About 2 hrs to fix

                  Function invalidAttributes has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      invalidAttributes(callback) {
                          const _ = privateData(this);
                          const attributeNamesWithValidators = Object.keys(_.validations);
                  
                          const compileInvalidAttributeList = (errors, validatorMessages) => {
                  Severity: Major
                  Found in es6/lib/model/index.js - About 2 hrs to fix

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

                    function fetchFromDatabase(fields = [this.primaryKey], callback = undefined) {
                      let database = this.database;
                      if (!database) { throw new Error("Cannot fetch without Model.database set."); }
                    
                      let chain = database
                    Severity: Major
                    Found in es6/lib/model/fetch.js - About 2 hrs to fix

                      Function saveOrUpdate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function saveOrUpdate(callback) {
                        let now = new Datetime();
                      
                        const _ = privateData(this);
                      
                      
                      Severity: Minor
                      Found in es6/lib/model/save.js - About 1 hr to fix

                        Function symbols.callDeep has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            [symbols.callDeep] (methodName, predicate, callback) {
                                const associationNames = Object.keys(this.associations);
                        
                                Async.mapParallel(
                                    associationNames,
                        Severity: Minor
                        Found in es6/lib/model/index.js - About 1 hr to fix

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

                              fetch(callback) {
                                  function processWhereCondition(value) {
                                      if (typeof value === "string") {
                                          const snakeCasedValue = inflect(value).snake.toString();
                                          return snakeCasedValue;
                          Severity: Minor
                          Found in es6/lib/collection.js - About 1 hr to fix

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

                            function performDelete(callback) {
                              const _ = privateData(this);
                              if (_.mockDelete) {
                                if(_.softDelete) {
                                  this.deletedAt = new Datetime();
                            Severity: Minor
                            Found in es6/lib/model/delete.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 fetchByHasMany has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function fetchByHasMany(associationName, associations, callback) {
                              const association = associations[associationName];
                            
                              if (association.through) {
                                const throughAssociation = associations[association.through];
                            Severity: Minor
                            Found in es6/lib/model/fetch.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language