Aigeruth/docker-private-registry

View on GitHub
public/js/lib/swagger.js

Summary

Maintainability
F
2 wks
Test Coverage

File swagger.js has 1430 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// swagger.js
// version 2.0.37

var __bind = function(fn, me){
  return function(){
Severity: Major
Found in public/js/lib/swagger.js - About 3 days to fix

    Function SwaggerOperation has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    var SwaggerOperation = function(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
      var _this = this;
    
      var errors = [];
      this.nickname = (nickname||errors.push("SwaggerOperations must have a nickname."));
    Severity: Minor
    Found in public/js/lib/swagger.js - About 7 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 SwaggerRequest has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
      var _this = this;
      var errors = [];
      this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
      this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
    Severity: Minor
    Found in public/js/lib/swagger.js - About 6 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 execute has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    JQueryHttpClient.prototype.execute = function(obj) {
      var cb = obj.on;
      var request = obj;
    
      obj.type = obj.method;
    Severity: Minor
    Found in public/js/lib/swagger.js - About 5 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 setHeaders has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    SwaggerRequest.prototype.setHeaders = function(params, operation) {
      // default type
      var accepts = "application/json";
      var consumes = "application/json";
    
    
    Severity: Minor
    Found in public/js/lib/swagger.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 addOperations has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
      if (ops) {
        output = [];
        for (var i = 0; i < ops.length; i++) {
          o = ops[i];
    Severity: Minor
    Found in public/js/lib/swagger.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 SwaggerRequest has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
      var _this = this;
      var errors = [];
      this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
      this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
    Severity: Major
    Found in public/js/lib/swagger.js - About 3 hrs to fix

      Function SwaggerOperation has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var SwaggerOperation = function(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
        var _this = this;
      
        var errors = [];
        this.nickname = (nickname||errors.push("SwaggerOperations must have a nickname."));
      Severity: Major
      Found in public/js/lib/swagger.js - About 3 hrs to fix

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

        SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
          var status = null;
          var key;
        
          // if the "authorizations" key is undefined, or has an empty array, add all keys
        Severity: Minor
        Found in public/js/lib/swagger.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 formatXml has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        SwaggerOperation.prototype.formatXml = function(xml) {
          var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
          reg = /(>)(<)(\/*)/g;
          wsexp = /[ ]*(.*)[ ]+\n/g;
          contexp = /(<.+>)(.+\n)/g;
        Severity: Major
        Found in public/js/lib/swagger.js - About 2 hrs to fix

          Function execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          ShredHttpClient.prototype.execute = function(obj) {
            if(!this.isInitialized)
              this.initShred();
          
            var cb = obj.on, res;
          Severity: Minor
          Found in public/js/lib/swagger.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 getSampleJSON has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          SwaggerOperation.prototype.getSampleJSON = function(type, models) {
            var isPrimitive, listType, val;
            listType = this.isListType(type);
            isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
            val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
          Severity: Minor
          Found in public/js/lib/swagger.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 execute has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          JQueryHttpClient.prototype.execute = function(obj) {
            var cb = obj.on;
            var request = obj;
          
            obj.type = obj.method;
          Severity: Major
          Found in public/js/lib/swagger.js - About 2 hrs to fix

            Function setHeaders has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            SwaggerRequest.prototype.setHeaders = function(params, operation) {
              // default type
              var accepts = "application/json";
              var consumes = "application/json";
            
            
            Severity: Major
            Found in public/js/lib/swagger.js - About 2 hrs to fix

              Function urlify has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              SwaggerOperation.prototype.urlify = function(args) {
                var url = this.resource.basePath + this.pathJson();
                var params = this.parameters;
                for(var i = 0; i < params.length; i ++){
                  var param = params[i];
              Severity: Minor
              Found in public/js/lib/swagger.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 buildFrom1_1Spec has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
                log("This API is using a deprecated version of Swagger!  Please see http://github.com/wordnik/swagger-core/wiki for more info");
                if (response.apiVersion != null)
                  this.apiVersion = response.apiVersion;
                this.apis = {};
              Severity: Minor
              Found in public/js/lib/swagger.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 SwaggerResource has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var SwaggerResource = function(resourceObj, api) {
                var _this = this;
                this.api = api;
                this.api = this.api;
                consumes = (this.consumes | []);
              Severity: Minor
              Found in public/js/lib/swagger.js - About 2 hrs to fix

                Function buildFromSpec has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                SwaggerApi.prototype.buildFromSpec = function(response) {
                  if (response.apiVersion != null) {
                    this.apiVersion = response.apiVersion;
                  }
                  this.apis = {};
                Severity: Minor
                Found in public/js/lib/swagger.js - About 1 hr to fix

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

                  SwaggerApi.prototype.buildFromSpec = function(response) {
                    if (response.apiVersion != null) {
                      this.apiVersion = response.apiVersion;
                    }
                    this.apis = {};
                  Severity: Minor
                  Found in public/js/lib/swagger.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 buildFrom1_1Spec has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
                    log("This API is using a deprecated version of Swagger!  Please see http://github.com/wordnik/swagger-core/wiki for more info");
                    if (response.apiVersion != null)
                      this.apiVersion = response.apiVersion;
                    this.apis = {};
                  Severity: Minor
                  Found in public/js/lib/swagger.js - About 1 hr to fix

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

                    SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
                      if (ops) {
                        output = [];
                        for (var i = 0; i < ops.length; i++) {
                          o = ops[i];
                    Severity: Minor
                    Found in public/js/lib/swagger.js - About 1 hr to fix

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

                      ShredHttpClient.prototype.execute = function(obj) {
                        if(!this.isInitialized)
                          this.initShred();
                      
                        var cb = obj.on, res;
                      Severity: Minor
                      Found in public/js/lib/swagger.js - About 1 hr to fix

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

                        var SwaggerModelProperty = function(name, obj) {
                          this.name = name;
                          this.dataType = obj.type || obj.dataType || obj["$ref"];
                          this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
                          this.descr = obj.description;
                        Severity: Minor
                        Found in public/js/lib/swagger.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 SwaggerOperation has 12 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        var SwaggerOperation = function(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
                        Severity: Major
                        Found in public/js/lib/swagger.js - About 1 hr to fix

                          Function complete has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            obj.complete = function(response, textStatus, opts) {
                              var headers = {},
                                  headerArray = response.getAllResponseHeaders().split("\n");
                          
                              for(var i = 0; i < headerArray.length; i++) {
                          Severity: Minor
                          Found in public/js/lib/swagger.js - About 1 hr to fix

                            Function build has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            SwaggerApi.prototype.build = function() {
                              var _this = this;
                              this.progress('fetching resource list: ' + this.url);
                              var obj = {
                                useJQuery: this.useJQuery,
                            Severity: Minor
                            Found in public/js/lib/swagger.js - About 1 hr to fix

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

                              var SwaggerResource = function(resourceObj, api) {
                                var _this = this;
                                this.api = api;
                                this.api = this.api;
                                consumes = (this.consumes | []);
                              Severity: Minor
                              Found in public/js/lib/swagger.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 SwaggerModel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                              var SwaggerModel = function(modelName, obj) {
                                this.name = obj.id != null ? obj.id : modelName;
                                this.properties = [];
                                var propertyName;
                                for (propertyName in obj.properties) {
                              Severity: Minor
                              Found in public/js/lib/swagger.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 SwaggerModelProperty has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              var SwaggerModelProperty = function(name, obj) {
                                this.name = name;
                                this.dataType = obj.type || obj.dataType || obj["$ref"];
                                this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
                                this.descr = obj.description;
                              Severity: Minor
                              Found in public/js/lib/swagger.js - About 1 hr to fix

                                Function urlify has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                SwaggerOperation.prototype.urlify = function(args) {
                                  var url = this.resource.basePath + this.pathJson();
                                  var params = this.parameters;
                                  for(var i = 0; i < params.length; i ++){
                                    var param = params[i];
                                Severity: Minor
                                Found in public/js/lib/swagger.js - About 1 hr to fix

                                  Function keys has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  Object.keys = Object.keys || (function () {
                                    var hasOwnProperty = Object.prototype.hasOwnProperty,
                                      hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
                                      DontEnums = [
                                        'toString',
                                  Severity: Minor
                                  Found in public/js/lib/swagger.js - About 1 hr to fix

                                    Function help has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    SwaggerApi.prototype.help = function() {
                                      var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
                                      _ref = this.apis;
                                      for (resource_name in _ref) {
                                        resource = _ref[resource_name];
                                    Severity: Minor
                                    Found in public/js/lib/swagger.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 SwaggerRequest has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
                                    Severity: Major
                                    Found in public/js/lib/swagger.js - About 1 hr to fix

                                      Function SwaggerApi has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      var SwaggerApi = function(url, options) {
                                        this.url = null;
                                        this.debug = false;
                                        this.basePath = null;
                                        this.authorizations = null;
                                      Severity: Minor
                                      Found in public/js/lib/swagger.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 build has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      SwaggerApi.prototype.build = function() {
                                        var _this = this;
                                        this.progress('fetching resource list: ' + this.url);
                                        var obj = {
                                          useJQuery: this.useJQuery,
                                      Severity: Minor
                                      Found in public/js/lib/swagger.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

                                      Avoid deeply nested control flow statements.
                                      Open

                                                if(encoded !== "")
                                                  encoded += "&";
                                      Severity: Major
                                      Found in public/js/lib/swagger.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                if(typeof value !== 'undefined') {
                                                  data += '--' + boundary + '\n';
                                                  data += 'Content-Disposition: form-data; name="' + key + '"';
                                                  data += '\n\n';
                                                  data += value + "\n";
                                        Severity: Major
                                        Found in public/js/lib/swagger.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                    if (result === true)
                                                      status = true;
                                          Severity: Major
                                          Found in public/js/lib/swagger.js - About 45 mins to fix

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

                                            SwaggerResource.prototype.addModels = function(models) {
                                              if (models != null) {
                                                var modelName;
                                                for (modelName in models) {
                                                  if (this.models[modelName] == null) {
                                            Severity: Minor
                                            Found in public/js/lib/swagger.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 getSampleValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                            SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
                                              var result;
                                              if ((this.refModel != null) && (modelsToIgnore.indexOf(prop.refModel.name) === -1)) {
                                                result = this.refModel.createJSONSample(modelsToIgnore);
                                              } else {
                                            Severity: Minor
                                            Found in public/js/lib/swagger.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(param.allowableValues.values) {
                                                      for(var j = 0; j < param.allowableValues.values.length; j++){
                                                        var v = param.allowableValues.values[j];
                                                        if(param.defaultValue != null) {
                                                          param.allowableValues.descriptiveValues.push ({
                                            Severity: Major
                                            Found in public/js/lib/swagger.js - About 45 mins to fix

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

                                              SwaggerResource.prototype.addApiDeclaration = function(response) {
                                                if (response.produces != null)
                                                  this.produces = response.produces;
                                                if (response.consumes != null)
                                                  this.consumes = response.consumes;
                                              Severity: Minor
                                              Found in public/js/lib/swagger.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 getSignature has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                              SwaggerOperation.prototype.getSignature = function(type, models) {
                                                var isPrimitive, listType;
                                                listType = this.isListType(type);
                                                isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
                                                if (isPrimitive) {
                                              Severity: Minor
                                              Found in public/js/lib/swagger.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 setConsolidatedModels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                              SwaggerApi.prototype.setConsolidatedModels = function() {
                                                var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
                                                this.modelsArray = [];
                                                this.models = {};
                                                _ref = this.apis;
                                              Severity: Minor
                                              Found in public/js/lib/swagger.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

                                              Avoid too many return statements within this function.
                                              Open

                                                    return base + "/" + relativeBasePath;
                                              Severity: Major
                                              Found in public/js/lib/swagger.js - About 30 mins to fix

                                                Function filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                  Array.prototype.filter= function(filter, that /*opt*/) {
                                                    var other= [], v;
                                                    for (var i=0, n= this.length; i<n; i++)
                                                      if (i in this && filter.call(that, v= this[i], i, this))
                                                        other.push(v);
                                                Severity: Minor
                                                Found in public/js/lib/swagger.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

                                                Function isIE8 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                SwaggerHttp.prototype.isIE8 = function() {
                                                  var detectedIE = false;
                                                  if (typeof navigator !== 'undefined' && navigator.userAgent) {
                                                    nav = navigator.userAgent.toLowerCase();
                                                    if (nav.indexOf('msie') !== -1) {
                                                Severity: Minor
                                                Found in public/js/lib/swagger.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

                                                Function help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                SwaggerResource.prototype.help = function() {
                                                  var op = this.operations;
                                                  var output = [];
                                                  var operation_name;
                                                  for (operation_name in op) {
                                                Severity: Minor
                                                Found in public/js/lib/swagger.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

                                                Function indexOf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                  Array.prototype.indexOf = function(obj, start) {
                                                    for (var i = (start || 0), j = this.length; i < j; i++) {
                                                      if (this[i] === obj) { return i; }
                                                    }
                                                    return -1;
                                                Severity: Minor
                                                Found in public/js/lib/swagger.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

                                                Function toSampleValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                SwaggerModelProperty.prototype.toSampleValue = function(value) {
                                                  var result;
                                                  if (value === "integer") {
                                                    result = 0;
                                                  } else if (value === "boolean") {
                                                Severity: Minor
                                                Found in public/js/lib/swagger.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

                                                Function getAbsoluteBasePath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
                                                  var pos, url;
                                                  url = this.api.basePath;
                                                  pos = url.lastIndexOf(relativeBasePath);
                                                  var parts = url.split("/");
                                                Severity: Minor
                                                Found in public/js/lib/swagger.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

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

                                                            if(param.defaultValue != null) {
                                                              param.allowableValues.descriptiveValues.push ({
                                                                value: String(v),
                                                                isDefault: (v === param.defaultValue)
                                                              });
                                                Severity: Major
                                                Found in public/js/lib/swagger.js and 1 other location - About 3 hrs to fix
                                                public/js/lib/swagger.js on lines 731..742

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

                                                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

                                                        if(param.defaultValue != null) {
                                                          param.allowableValues.descriptiveValues.push ({
                                                            value: String(v),
                                                            isDefault: (v === param.defaultValue)
                                                          });
                                                Severity: Major
                                                Found in public/js/lib/swagger.js and 1 other location - About 3 hrs to fix
                                                public/js/lib/swagger.js on lines 755..766

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

                                                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(key == name) {
                                                          value = this.authz[key];
                                                          result = value.apply(obj, authorizations);
                                                          if (result === true)
                                                            status = true;
                                                Severity: Minor
                                                Found in public/js/lib/swagger.js and 1 other location - About 40 mins to fix
                                                public/js/lib/swagger.js on lines 1510..1515

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

                                                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

                                                    for (key in this.authz) {
                                                      value = this.authz[key];
                                                      result = value.apply(obj, authorizations);
                                                      if (result === true)
                                                        status = true;
                                                Severity: Minor
                                                Found in public/js/lib/swagger.js and 1 other location - About 40 mins to fix
                                                public/js/lib/swagger.js on lines 1520..1525

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

                                                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

                                                    if (this.values != null) {
                                                      this.valueString = "'" + this.values.join("' or '") + "'";
                                                    }
                                                Severity: Minor
                                                Found in public/js/lib/swagger.js and 1 other location - About 35 mins to fix
                                                public/js/lib/swagger.js on lines 608..610

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

                                                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

                                                    if (this.values != null) {
                                                      this.valuesString = "'" + this.values.join("' or '") + "'";
                                                    }
                                                Severity: Minor
                                                Found in public/js/lib/swagger.js and 1 other location - About 35 mins to fix
                                                public/js/lib/swagger.js on lines 615..617

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

                                                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