contartec-team/generic-model-bookshelf

View on GitHub

Showing 11 of 20 total issues

GenericModel has 76 functions (exceeds 20 allowed). Consider refactoring.
Open

class GenericModel extends bookshelf.Model {

  /**
   * The `GenericModel` params
   * @description A mix of `bookshelf` and custom options (override this with the desired one)
Severity: Major
Found in lib/GenericModel.js - About 1 day to fix

    File GenericModel.js has 608 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict'
    
    const ObjectUtils = require('@contartec-team/object-utils')
    const validate = require('validate.js')
    
    
    Severity: Major
    Found in lib/GenericModel.js - About 1 day to fix

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

        static getQueryAll(params, model, queryBuilder, isWhere = true) {
          const queryBoolean = isWhere ?
            'where' :
            'orWhere'
      
      
      Severity: Minor
      Found in lib/GenericModel.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 getQueryAll has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static getQueryAll(params, model, queryBuilder, isWhere = true) {
          const queryBoolean = isWhere ?
            'where' :
            'orWhere'
      
      
      Severity: Minor
      Found in lib/GenericModel.js - About 1 hr to fix

        Function getAll has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static getAll(params, fetchOptions = {}) {
            const paramsTemp = { ...this.GET_ALL_DEFAULT_PARAMS, ...params }
            const fetchOptionsTemp = { ...this.GET_ALL_DEFAULT_FETCH_OPTIONS, ...fetchOptions }
        
            if (typeof(paramsTemp.orderBy) == 'string')
        Severity: Minor
        Found in lib/GenericModel.js - About 1 hr to fix

          Function serialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            serialize(options) {
              const optionsTemp = { ...this._SERIALIZE_OPTIONS, ...options }
          
              let json = super
                .serialize(optionsTemp)
          Severity: Minor
          Found in lib/GenericModel.js - About 55 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 _getAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _getAttributes(object) {
              let visibleAttributes = {}
          
              if (this._hasVisibleAttributes()) {
                const definedAttributes = this.getAttributes()
          Severity: Minor
          Found in lib/GenericModel.js - About 25 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 _getNotDefinedAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _getNotDefinedAttributes(object) {
              let notDefinedAttributes = {}
          
              if (this._hasAttributes()) {
                for (const attr in object) {
          Severity: Minor
          Found in lib/GenericModel.js - About 25 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 _getVisibleAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _getVisibleAttributes(object) {
              let visibleAttributes = {}
          
              if (this._hasVisibleAttributes()) {
                for (const attr in object) {
          Severity: Minor
          Found in lib/GenericModel.js - About 25 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 _getRelateds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _getRelateds(object) {
              const relateds = {}
          
              if (this._hasRelateds()) {
                for (const attr in object) {
          Severity: Minor
          Found in lib/GenericModel.js - About 25 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 _getHiddenAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _getHiddenAttributes(object) {
              let hiddenAttributes = {}
          
              if (this._hasHiddenAttributes()) {
                for (const attr in object) {
          Severity: Minor
          Found in lib/GenericModel.js - About 25 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

          Severity
          Category
          Status
          Source
          Language