resource-watch/sql2json

View on GitHub
lib/sql2json.js

Summary

Maintainability
F
3 wks
Test Coverage

File sql2json.js has 975 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const lexer = require('rw-sql-parser').lexer;

const between = /^between$/gi;
const sqlStatements = /^delete$/gi;

Severity: Major
Found in lib/sql2json.js - About 2 days to fix

    Function parseWhere has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
    Open

    sql2json.prototype.parseWhere = function () {
        const nodeTypeStopList = ['in', 'between', 'operator', 'operatorPlaceholder', 'conditional', 'bracket'];
        const stack = [];
        let operator = null;
        let conditional = null;
    Severity: Minor
    Found in lib/sql2json.js - About 1 day 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 parseWhere has 203 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    sql2json.prototype.parseWhere = function () {
        const nodeTypeStopList = ['in', 'between', 'operator', 'operatorPlaceholder', 'conditional', 'bracket'];
        const stack = [];
        let operator = null;
        let conditional = null;
    Severity: Major
    Found in lib/sql2json.js - About 1 day to fix

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

      sql2json.prototype.parseSelectExperimental = function () {
          this.parsed.select = [];
          let prependSpace = false;
          while (this.hasNext()) {
              const token = this.next();
      Severity: Minor
      Found in lib/sql2json.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

      Function parseGroupExperimental has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      sql2json.prototype.parseGroupExperimental = function () {
          const stack = [];
          let lastParen = false;
          while (this.hasNext()) {
              const token = this.next();
      Severity: Minor
      Found in lib/sql2json.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 parseOrderExperimental has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      sql2json.prototype.parseOrderExperimental = function () {
          const stack = [];
          let lastParen = false;
          while (this.hasNext()) {
              const token = this.next();
      Severity: Minor
      Found in lib/sql2json.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 parseWhereExperimental has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      sql2json.prototype.parseWhereExperimental = function () {
          const stack = [];
          let lastParen = false;
          while (this.hasNext()) {
              const token = this.next();
      Severity: Minor
      Found in lib/sql2json.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 parseSelect has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      sql2json.prototype.parseSelect = function () {
          this.parsed.select = [];
          let containAs = false;
          let isDistinct = false;
      
      
      Severity: Major
      Found in lib/sql2json.js - About 3 hrs to fix

        Function parseFunction has 88 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        sql2json.prototype.parseFunction = function (functionName, isInSelect) {
            const stack = [];
            let findParen = false;
            while (this.hasNext()) {
                const token = this.next();
        Severity: Major
        Found in lib/sql2json.js - About 3 hrs to fix

          Function parseSelect has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          sql2json.prototype.parseSelect = function () {
              this.parsed.select = [];
              let containAs = false;
              let isDistinct = false;
          
          
          Severity: Minor
          Found in lib/sql2json.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 parse has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          sql2json.prototype.parse = function () {
              while (this.hasNext()) {
                  const token = this.next();
                  const tokenType = obtainType(token, this.lookAhead());
                  switch (tokenType) {
          Severity: Minor
          Found in lib/sql2json.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 parseFunction has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          sql2json.prototype.parseFunction = function (functionName, isInSelect) {
              const stack = [];
              let findParen = false;
              while (this.hasNext()) {
                  const token = this.next();
          Severity: Minor
          Found in lib/sql2json.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 parseOrder has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          sql2json.prototype.parseOrder = function () {
              const stack = [];
              while (this.hasNext()) {
                  const token = this.next();
                  switch (obtainType(token, this.lookAhead())) {
          Severity: Major
          Found in lib/sql2json.js - About 2 hrs to fix

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

            sql2json.prototype.parse = function () {
                while (this.hasNext()) {
                    const token = this.next();
                    const tokenType = obtainType(token, this.lookAhead());
                    switch (tokenType) {
            Severity: Major
            Found in lib/sql2json.js - About 2 hrs to fix

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

              sql2json.prototype.parseGroupExperimental = function () {
                  const stack = [];
                  let lastParen = false;
                  while (this.hasNext()) {
                      const token = this.next();
              Severity: Minor
              Found in lib/sql2json.js - About 1 hr to fix

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

                sql2json.prototype.parseOrderExperimental = function () {
                    const stack = [];
                    let lastParen = false;
                    while (this.hasNext()) {
                        const token = this.next();
                Severity: Minor
                Found in lib/sql2json.js - About 1 hr to fix

                  Function parseWhereExperimental has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  sql2json.prototype.parseWhereExperimental = function () {
                      const stack = [];
                      let lastParen = false;
                      while (this.hasNext()) {
                          const token = this.next();
                  Severity: Minor
                  Found in lib/sql2json.js - About 1 hr to fix

                    Function parseSelectExperimental has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    sql2json.prototype.parseSelectExperimental = function () {
                        this.parsed.select = [];
                        let prependSpace = false;
                        while (this.hasNext()) {
                            const token = this.next();
                    Severity: Minor
                    Found in lib/sql2json.js - About 1 hr to fix

                      Function parseBetween has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      sql2json.prototype.parseBetween = function (between) {
                          const stack = [];
                          let mult = 1;
                          while (this.hasNext()) {
                              const token = this.next();
                      Severity: Minor
                      Found in lib/sql2json.js - About 1 hr to fix

                        Function parseGroup has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        sql2json.prototype.parseGroup = function () {
                            const stack = [];
                            while (this.hasNext()) {
                                const token = this.next();
                                const tokenType = obtainType(token, this.lookAhead());
                        Severity: Minor
                        Found in lib/sql2json.js - About 1 hr to fix

                          Function parseMath has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          sql2json.prototype.parseMath = function (value, first) {
                              const stack = [first];
                              let minus = false;
                              while (this.hasNext()) {
                                  const token = this.next();
                          Severity: Minor
                          Found in lib/sql2json.js - About 1 hr to fix

                            Function parseIn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            sql2json.prototype.parseIn = function () {
                                const stack = [];
                                while (this.hasNext()) {
                                    const token = this.next();
                                    switch (obtainType(token, this.lookAhead())) {
                            Severity: Minor
                            Found in lib/sql2json.js - About 1 hr to fix

                              Function parseNamedArgument has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              sql2json.prototype.parseNamedArgument = function (value, first) {
                                  const name = first.value;
                              
                                  while (this.hasNext()) {
                                      const token = this.next();
                              Severity: Minor
                              Found in lib/sql2json.js - About 1 hr to fix

                                Function parseFrom has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                sql2json.prototype.parseFrom = function () {
                                    let name = '';
                                    while (this.hasNext()) {
                                        const token = this.next();
                                        switch (obtainType(token, this.lookAhead())) {
                                Severity: Minor
                                Found in lib/sql2json.js - About 1 hr to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if (token[1] === '(') {
                                                              lastParen = true;
                                                          } else {
                                                              lastParen = false;
                                                          }
                                  Severity: Major
                                  Found in lib/sql2json.js - About 45 mins to fix

                                    Function parseBetween has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    sql2json.prototype.parseBetween = function (between) {
                                        const stack = [];
                                        let mult = 1;
                                        while (this.hasNext()) {
                                            const token = this.next();
                                    Severity: Minor
                                    Found in lib/sql2json.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

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if (token[1] === '(') {
                                                                lastParen = true;
                                                            } else {
                                                                lastParen = false;
                                                            }
                                    Severity: Major
                                    Found in lib/sql2json.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if (token[1] === '(') {
                                                                  lastParen = true;
                                                              } else {
                                                                  lastParen = false;
                                                              }
                                      Severity: Major
                                      Found in lib/sql2json.js - About 45 mins to fix

                                        Function parseMath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        sql2json.prototype.parseMath = function (value, first) {
                                            const stack = [first];
                                            let minus = false;
                                            while (this.hasNext()) {
                                                const token = this.next();
                                        Severity: Minor
                                        Found in lib/sql2json.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

                                        Avoid deeply nested control flow statements.
                                        Open

                                                                if (token[1] === '(' || token[1] === '.') {
                                                                    prependSpace = true;
                                                                } else {
                                                                    prependSpace = false;
                                                                }
                                        Severity: Major
                                        Found in lib/sql2json.js - About 45 mins to fix

                                          Consider simplifying this complex logical expression.
                                          Open

                                                              if (!prependSpace && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') {
                                                                  el.value += ' ' + token[1];
                                                              } else {
                                                                  if (token[1] === '(' || token[1] === '.') {
                                                                      prependSpace = true;
                                          Severity: Major
                                          Found in lib/sql2json.js - About 40 mins to fix

                                            Consider simplifying this complex logical expression.
                                            Open

                                                                if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') {
                                                                    el.value += ' ' + token[1];
                                                                } else {
                                                                    if (token[1] === '(') {
                                                                        lastParen = true;
                                            Severity: Major
                                            Found in lib/sql2json.js - About 40 mins to fix

                                              Consider simplifying this complex logical expression.
                                              Open

                                                                  if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') {
                                                                      el.value += ' ' + token[1];
                                                                  } else {
                                                                      if (token[1] === '(') {
                                                                          lastParen = true;
                                              Severity: Major
                                              Found in lib/sql2json.js - About 40 mins to fix

                                                Consider simplifying this complex logical expression.
                                                Open

                                                                    if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') {
                                                                        el.value += ' ' + token[1];
                                                                    } else {
                                                                        if (token[1] === '(') {
                                                                            lastParen = true;
                                                Severity: Major
                                                Found in lib/sql2json.js - About 40 mins to fix

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  sql2json.prototype.parseOrderExperimental = function () {
                                                      const stack = [];
                                                      let lastParen = false;
                                                      while (this.hasNext()) {
                                                          const token = this.next();
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 1 other location - About 2 days to fix
                                                  lib/sql2json.js on lines 971..1018

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 423.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  sql2json.prototype.parseGroupExperimental = function () {
                                                      const stack = [];
                                                      let lastParen = false;
                                                      while (this.hasNext()) {
                                                          const token = this.next();
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 1 other location - About 2 days to fix
                                                  lib/sql2json.js on lines 850..899

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 423.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  if (stack.length >= 2 && conditional) {
                                                                      const right = [];
                                                                      const left = [];
                                                  
                                                                      right.unshift(stack.pop());
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 2 other locations - About 1 day to fix
                                                  lib/sql2json.js on lines 553..576
                                                  lib/sql2json.js on lines 656..680

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 260.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  if (stack.length >= 2 && conditional) {
                                                                      const right = [];
                                                                      const left = [];
                                                  
                                                                      right.unshift(stack.pop());
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 2 other locations - About 1 day to fix
                                                  lib/sql2json.js on lines 656..680
                                                  lib/sql2json.js on lines 709..733

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 260.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  if (stack.length >= 2 && conditional) {
                                                                      const right = [];
                                                                      const left = [];
                                                  
                                                                      right.unshift(stack.pop());
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 2 other locations - About 1 day to fix
                                                  lib/sql2json.js on lines 553..576
                                                  lib/sql2json.js on lines 709..733

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 260.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                                  if (operator && stack.length >= 2) {
                                                                      const right = [];
                                                                      const left = [];
                                                  
                                                                      while (stack.length && !nodeTypeStopList.includes(stack[stack.length - 1].type)) {
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 1 other location - About 1 day to fix
                                                  lib/sql2json.js on lines 684..708

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 241.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                                  if (stack.length >= 2 && operator) {
                                                                      const right = [];
                                                                      const left = [];
                                                  
                                                                      while (stack.length && !nodeTypeStopList.includes(stack[stack.length - 1].type)) {
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 1 other location - About 1 day to fix
                                                  lib/sql2json.js on lines 528..552

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 241.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  sql2json.prototype.parseLimit = function () {
                                                      while (this.hasNext()) {
                                                          const token = this.next();
                                                          switch (obtainType(token, this.lookAhead())) {
                                                  
                                                  
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 1 other location - About 3 hrs to fix
                                                  lib/sql2json.js on lines 917..930

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 96.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  sql2json.prototype.parseOfsset = function () {
                                                      while (this.hasNext()) {
                                                          const token = this.next();
                                                          switch (obtainType(token, this.lookAhead())) {
                                                  
                                                  
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 1 other location - About 3 hrs to fix
                                                  lib/sql2json.js on lines 902..915

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 96.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  if (containAs) {
                                                                      this.parsed.select[this.parsed.select.length - 1].alias = token[1];
                                                                      containAs = false;
                                                                  } else {
                                                                      this.parsed.select.push(this.parseFunction(token[1], true));
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 2 other locations - About 55 mins to fix
                                                  lib/sql2json.js on lines 244..253
                                                  lib/sql2json.js on lines 256..265

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 54.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  if (containAs) {
                                                                      this.parsed.select[this.parsed.select.length - 1].alias = token[1];
                                                                      containAs = false;
                                                                  } else {
                                                                      this.parsed.select.push({
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 2 other locations - About 55 mins to fix
                                                  lib/sql2json.js on lines 256..265
                                                  lib/sql2json.js on lines 286..291

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 54.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  if (containAs) {
                                                                      this.parsed.select[this.parsed.select.length - 1].alias = token[1];
                                                                      containAs = false;
                                                                  } else {
                                                                      this.parsed.select.push({
                                                  Severity: Major
                                                  Found in lib/sql2json.js and 2 other locations - About 55 mins to fix
                                                  lib/sql2json.js on lines 244..253
                                                  lib/sql2json.js on lines 286..291

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 54.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status