adammcarth/instance.js

View on GitHub

Showing 10 of 17 total issues

Function validate has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

Instance.prototype.validate = function() {
    var validations = this.validations;
    var validation_callback_queue = [];

    if ( validations ) {
Severity: Minor
Found in lib/validations/validate.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 validate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Instance.prototype.validate = function() {
    var validations = this.validations;
    var validation_callback_queue = [];

    if ( validations ) {
Severity: Major
Found in lib/validations/validate.js - About 2 hrs to fix

    Function send has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Instance.prototype.send = function( url, method, validation ) {
        if ( validation !== false ) {
            // Validate the model
            if ( this.validate() === false ) {
                // Woah. No way we're sending this off.
    Severity: Major
    Found in lib/send.js - About 2 hrs to fix

      Function send has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      Instance.prototype.send = function( url, method, validation ) {
          if ( validation !== false ) {
              // Validate the model
              if ( this.validate() === false ) {
                  // Woah. No way we're sending this off.
      Severity: Minor
      Found in lib/send.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 exports has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (grunt) {
          grunt.initConfig({
      
              pkg: grunt.file.readJSON("package.json"),
      
      
      Severity: Minor
      Found in Gruntfile.js - About 1 hr to fix

        Function get has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Instance.prototype.get = function( attr ) {
            var input,
                element;
        
            // Add the latest values of any HTML INPUT FIELDS specified
        Severity: Minor
        Found in lib/get.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                      if ( pass_callback ) { validation_callback_queue.push( pass_callback ); }
          Severity: Major
          Found in lib/validations/validate.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if ( fail_callback ) { validation_callback_queue.push( fail_callback ); }
            Severity: Major
            Found in lib/validations/validate.js - About 45 mins to fix

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

              function validates_instance_url( url, attr ) {
                  var xhr = new XMLHttpRequest();
                  xhr.open( "GET", url + "?value=" + encodeURIComponent(attr), true );
                  xhr.setRequestHeader( "Instance-Validation", attr );
                  xhr.onreadystatechange = function() {
              Severity: Minor
              Found in lib/validations/methods.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 validates_instance_presence has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function validates_instance_presence( type, attr ) {
                  if ( attr === undefined || attr === null || attr === "" || attr === 0 || attr === "0" ) {
                      var presence = false;
                  } else {
                      var presence = true;
              Severity: Minor
              Found in lib/validations/methods.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

              Severity
              Category
              Status
              Source
              Language