lebretr/sequelize-oracle

View on GitHub
lib/sql-string.js

Summary

Maintainability
D
1 day
Test Coverage

Function escape has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
  if (arguments.length === 1 && typeof arguments[0] === "object") {
    val = val.val || val.value || null
    stringifyObjects = val.stringifyObjects || val.objects || undefined
    timeZone = val.timeZone || val.zone || null
Severity: Minor
Found in lib/sql-string.js - About 3 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 escape has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
  if (arguments.length === 1 && typeof arguments[0] === "object") {
    val = val.val || val.value || null
    stringifyObjects = val.stringifyObjects || val.objects || undefined
    timeZone = val.timeZone || val.zone || null
Severity: Major
Found in lib/sql-string.js - About 2 hrs to fix

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

    SqlString.arrayToList = function(array, timeZone, dialect, field) {
      if (dialect === 'postgres') {
        if (array.map) {
          var valstr = array.map(function(v) {
            return SqlString.escape(v, true, timeZone, dialect, field)
    Severity: Minor
    Found in lib/sql-string.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

    Consider simplifying this complex logical expression.
    Open

      if (arguments.length === 1 && typeof arguments[0] === "object") {
        val = val.val || val.value || null
        stringifyObjects = val.stringifyObjects || val.objects || undefined
        timeZone = val.timeZone || val.zone || null
        dialect = val.dialect || null
    Severity: Critical
    Found in lib/sql-string.js - About 2 hrs to fix

      Function arrayToList has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      SqlString.arrayToList = function(array, timeZone, dialect, field) {
        if (dialect === 'postgres') {
          if (array.map) {
            var valstr = array.map(function(v) {
              return SqlString.escape(v, true, timeZone, dialect, field)
      Severity: Minor
      Found in lib/sql-string.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

          else if (arguments.length < 3 && typeof arguments[1] === "object") {
            timeZone = stringifyObjects.timeZone || stringifyObjects.zone || null
            dialect = stringifyObjects.dialect || null
            field = stringifyObjects.field || null
          }
        Severity: Major
        Found in lib/sql-string.js - About 40 mins to fix

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

          SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
          Severity: Minor
          Found in lib/sql-string.js - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                  return SqlString.objectToValues(newVal, timeZone)
            Severity: Major
            Found in lib/sql-string.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return "'"+newVal+"'";
              Severity: Major
              Found in lib/sql-string.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return "TO_TIMESTAMP_TZ('"+newVal+"','YYYY-MM-DD HH24:MI:SS.FF3 TZH:TZM')";
                Severity: Major
                Found in lib/sql-string.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status