wonderlic/swagger-validation

View on GitHub

Showing 19 of 28 total issues

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

var validateObject = function(param, value, models) {
  var isRequired = helper.isRequired(param, value);
  if (isRequired) {
    return isRequired;
  }
Severity: Major
Found in lib/validation/parameters/object.js - About 2 hrs to fix

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

    var validate = function(param, value, models) {
      var type = param.uniqueItems ? "set" : "array";
      var isRequired = helper.isRequired(param, value);
      if (isRequired) {
        return isRequired;
    Severity: Minor
    Found in lib/validation/parameters/array.js - About 1 hr to fix

      Function validateString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      var validateString = function(param, value) {
        var isRequired = helper.isRequired(param, value);
        if (isRequired) {
          return isRequired;
        }
      Severity: Minor
      Found in lib/validation/parameters/string.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 func has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var func = function(param, value) {
            var model = models[param.type];
      
            // it is probably irrelevant to check as a model without properties is pointless, but it is a nice sanity check
            if (model.properties) {
      Severity: Minor
      Found in lib/validation/parameters/object.js - About 1 hr to fix

        Function validateInt64 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        var validateInt64 = function(param, value) {
          var type = param.format ? param.format : param.type;
          var isRequired = helper.isRequired(param, value);
          if (isRequired) {
            return isRequired;
        Severity: Minor
        Found in lib/validation/parameters/integer.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 validateInteger has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        var validateInteger = function(param, value) {
          var type = param.format ? param.format : param.type;
          var isRequired = helper.isRequired(param, value);
          if (isRequired) {
            return isRequired;
        Severity: Minor
        Found in lib/validation/parameters/integer.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 validateNumber has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        var validateNumber = function(param, value) {
          var type = param.format ? param.format : param.type;
          var isRequired = helper.isRequired(param, value);
          if (isRequired) {
            return isRequired;
        Severity: Minor
        Found in lib/validation/parameters/number.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        var validate = function(param, value, models) {
          var type = param.uniqueItems ? "set" : "array";
          var isRequired = helper.isRequired(param, value);
          if (isRequired) {
            return isRequired;
        Severity: Minor
        Found in lib/validation/parameters/array.js - About 55 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 isRequired has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function isRequired(param, value) {
          if (_.isUndefined(value) || _.isNull(value) || value === '') {
            var isParamRequired = param.required && !param.defaultValue;
            return isParamRequired
              ? errorReturn("%s is required", param.name)
        Severity: Minor
        Found in lib/validation/parameters/helper.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

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

        var validate = function(spec, req, models) {
          var ret = [];
          var isSpecObject = Object.prototype.toString.call(spec) === '[object Object]';
          var validationObj = makeValidationObject(isSpecObject ? spec.validation : {});
        
        
        Severity: Minor
        Found in lib/validation/validate.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

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

        var validateObject = function(param, value, models) {
          var isRequired = helper.isRequired(param, value);
          if (isRequired) {
            return isRequired;
          }
        Severity: Minor
        Found in lib/validation/parameters/object.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

        Consider simplifying this complex logical expression.
        Open

          if (isNaN(val) || !isFinite(val) || _.isArray(value) || _.isBoolean(value) || (_.isString(value) && value.trim() === '')) {
            return helper.errorReturn("%s is not a type of %s", [param.name, type]);
          }
        Severity: Major
        Found in lib/validation/parameters/number.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

            if (req.query === undefined && req.path === undefined && req.body === undefined
              && req.form === undefined && req.header === undefined && req.params === undefined) {
              return paramTypes.object(param, req, models, validationObj);
            }
          Severity: Major
          Found in lib/validation/paramType.js - About 40 mins to fix

            Avoid too many return statements within this function.
            Open

              return helper.successReturn(val);
            Severity: Major
            Found in lib/validation/parameters/integer.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return helper.errorReturn("%s is not valid based on the pattern %s", [param.name, param.pattern]);
              Severity: Major
              Found in lib/validation/parameters/string.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return helper.errorReturn("%s is specified with an invalid pattern %s", [param.name, param.pattern]);
                Severity: Major
                Found in lib/validation/parameters/string.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return helper.successReturn(val);
                  Severity: Major
                  Found in lib/validation/parameters/number.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return helper.successReturn(val);
                    Severity: Major
                    Found in lib/validation/parameters/integer.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return helper.successReturn(value);
                      Severity: Major
                      Found in lib/validation/parameters/string.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language