arlac77/sorm

View on GitHub

Showing 14 of 14 total issues

File module.js has 560 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jslint node: true, esnext: true */

'use strict';

const crypto = require('crypto'),
Severity: Major
Found in src/module.js - About 1 day to fix

    Function exec_ddl has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      exec_ddl(db, createOptions, callback) {
    
        if (!createOptions)
          createOptions = {
            'load_data': true
    Severity: Major
    Found in src/module.js - About 2 hrs to fix

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

      function parse_constraints(ps, cs) {
        let gotSomething;
        let str = ps.input;
      
        if (str) {
      Severity: Minor
      Found in src/module.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 tables_from_db has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function tables_from_db(db, callback) {
        db.all("SELECT name,sql FROM sqlite_master WHERE type='table'", (error, rows) => {
          if (error) {
            callback(error);
            return;
      Severity: Minor
      Found in src/module.js - About 1 hr to fix

        Function migrate_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          migrate_data(db, data_sets, callback) {
            const update = function (table, sql, values) {
              const v = [];
              const l = table.pk().length;
        
        
        Severity: Minor
        Found in src/module.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 pk has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            pk() {
              const pk = [];
        
              for (const i in this.attributes) {
                const a = this.attributes[i];
        Severity: Minor
        Found in src/module.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 Constraint has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export function Constraint(type, properties) {
        
          if (typeof type === 'string') {
            let c = constraints[type.toUpperCase()];
            if (c) {
        Severity: Minor
        Found in src/module.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 migrate_data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          migrate_data(db, data_sets, callback) {
            const update = function (table, sql, values) {
              const v = [];
              const l = table.pk().length;
        
        
        Severity: Minor
        Found in src/module.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                    if (oc.parse) {
                      str = oc.parse(m, cs, oc);
                    } else {
                      str = m[1];
                      cs.push(Constraint(oc));
          Severity: Major
          Found in src/module.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (m) {
                          const aname = unquote(m[1]);
                          const type = m[4];
                          ps.input = m[6];
            
            
            Severity: Major
            Found in src/module.js - About 45 mins to fix

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

                    if (!this.versions) {
                      this.versions = {};
                      this.versions[this.schemaHash] = {
                        tag: 1
                      };
              Severity: Minor
              Found in src/module.js and 1 other location - About 45 mins to fix
              src/module.js on lines 487..492

              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 50.

              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 (!this.versions) {
                    this.versions = {};
                    this.versions[this.schemaHash] = {
                      tag: 1
                    };
              Severity: Minor
              Found in src/module.js and 1 other location - About 45 mins to fix
              src/module.js on lines 502..507

              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 50.

              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

              Function Attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function Attribute(name, type, cs) {
              
                const constraints = [];
              
                if (cs instanceof Array) {
              Severity: Minor
              Found in src/module.js - About 35 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 Table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function Table(name, attributes, constraints) {
              
                for (const i in attributes) {
                  const a = attributes[i];
                  if (!(a instanceof Attribute))
              Severity: Minor
              Found in src/module.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