waterlinejs/postgresql-adapter

View on GitHub

Showing 14 of 16 total issues

File adapter.js has 366 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Knex from 'knex'
import _ from 'lodash'
import camelize from 'camelize'
import WaterlineSequel from 'waterline-sequel'

Severity: Minor
Found in lib/adapter.js - About 4 hrs to fix

    File util.js has 350 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import _ from 'lodash'
    import Adapter from './adapter'
    import CriteriaParser from 'waterline-sequel/sequel/lib/criteriaProcessor'
    import SpatialUtil from './spatial'
    import Procedures from './procedures'
    Severity: Minor
    Found in lib/util.js - About 4 hrs to fix

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

      const Util = {
      
        PG_MAX_INT: 2147483647,
      
        initializeConnection (cxn) {
      Severity: Minor
      Found in lib/util.js - About 3 hrs to fix

        Function toKnexColumn has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          toKnexColumn (table, _name, attrDefinition, wlModel, schema) {
            let attr = _.isObject(attrDefinition) ? attrDefinition : { type: attrDefinition }
            let type = attr.autoIncrement ? 'serial' : attr.type
            let name = attr.columnName || _name
        
        
        Severity: Major
        Found in lib/util.js - About 3 hrs to fix

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

          const Adapter = {
          
            identity: 'waterline-postgresql',
          
            wlSqlOptions: {
          Severity: Minor
          Found in lib/adapter.js - About 2 hrs to fix

            Function toKnexColumn has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              toKnexColumn (table, _name, attrDefinition, wlModel, schema) {
                let attr = _.isObject(attrDefinition) ? attrDefinition : { type: attrDefinition }
                let type = attr.autoIncrement ? 'serial' : attr.type
                let name = attr.columnName || _name
            
            
            Severity: Minor
            Found in lib/util.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 applyParticularColumnConstraint has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              applyParticularColumnConstraint (column, constraintName, value, definition) {
                if (!value) return
            
                switch (constraintName) {
            
            
            Severity: Minor
            Found in lib/util.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 registerConnection has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              registerConnection (connection, collections, cb) {
                if (!connection.identity) {
                  return cb(WaterlineError.adapter.IdentityMissing)
                }
                if (Adapter.connections.get(connection.identity)) {
            Severity: Minor
            Found in lib/adapter.js - About 1 hr to fix

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

                update (connectionName, tableName, options, data, cb) {
              Severity: Minor
              Found in lib/adapter.js - About 35 mins to fix

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

                  query (connectionName, tableName, queryString, args, cb) {
                Severity: Minor
                Found in lib/adapter.js - About 35 mins to fix

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

                    addAttribute (connectionName, tableName, attributeName, definition, cb) {
                  Severity: Minor
                  Found in lib/adapter.js - About 35 mins to fix

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

                      toKnexColumn (table, _name, attrDefinition, wlModel, schema) {
                    Severity: Minor
                    Found in lib/util.js - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return value
                      Severity: Major
                      Found in lib/util.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                  return column.defaultTo(knex.raw('uuid_generate_v4()'))
                        Severity: Major
                        Found in lib/util.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language