ruby-grape/grape-swagger-rails

View on GitHub

Showing 51 of 85 total issues

Avoid too many return statements within this function.
Open

    var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
Severity: Major
Found in app/assets/javascripts/grape_swagger_rails/es5-shim.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return this.renderer.listitem(body);
    Severity: Major
    Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return this.renderer.paragraph(this.inline.output(this.token.text));
      Severity: Major
      Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return this.renderer.list(body, ordered);
        Severity: Major
        Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return '<p>An error occured:</p><pre>'
                  + escape(e.message + '', true)
                  + '</pre>';
          Severity: Major
          Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return this.renderer.table(header, body);
            Severity: Major
            Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return this.renderer.html(html);
              Severity: Major
              Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 30 mins to fix

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

                  _utf8_encode : function(string) {
                    string = string.replace(/\r\n/g, "\n");
                    var utftext = "";
                
                    for (var n = 0; n < string.length; n++) {
                Severity: Minor
                Found in lib/javascripts/base64.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 _utf8_decode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  _utf8_decode : function(utftext) {
                    var string = "";
                    var i = 0;
                    var c = c1 = c2 = 0;
                
                
                Severity: Minor
                Found in app/assets/javascripts/grape_swagger_rails/base64.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 _utf8_decode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  _utf8_decode : function(utftext) {
                    var string = "";
                    var i = 0;
                    var c = c1 = c2 = 0;
                
                
                Severity: Minor
                Found in lib/javascripts/base64.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 _utf8_encode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  _utf8_encode : function(string) {
                    string = string.replace(/\r\n/g, "\n");
                    var utftext = "";
                
                    for (var n = 0; n < string.length; n++) {
                Severity: Minor
                Found in app/assets/javascripts/grape_swagger_rails/base64.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