ruby-grape/grape-swagger-rails

View on GitHub

Showing 85 of 85 total issues

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

var Base64 = {

  // private property
  _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

Severity: Major
Found in lib/javascripts/base64.js and 1 other location - About 1 wk to fix
app/assets/javascripts/grape_swagger_rails/base64.js on lines 7..134

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

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

var Base64 = {

  // private property
  _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

Severity: Major
Found in app/assets/javascripts/grape_swagger_rails/base64.js and 1 other location - About 1 wk to fix
lib/javascripts/base64.js on lines 7..134

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

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

File es5-shim.js has 1509 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * https://github.com/es-shims/es5-shim
 * @license es5-shim Copyright 2009-2015 by contributors, MIT License
 * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
 */
Severity: Major
Found in app/assets/javascripts/grape_swagger_rails/es5-shim.js - About 4 days to fix

    File marked.js has 901 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * marked - a markdown parser
     * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
     * https://github.com/chjj/marked
     */
    Severity: Major
    Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 2 days to fix

      Function token has 213 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Lexer.prototype.token = function(src, top, bq) {
        var src = src.replace(/^ +$/gm, '')
          , next
          , loose
          , cap
      Severity: Major
      Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 1 day to fix

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

              for (i = 0; i < item.align.length; i++) {
                if (/^ *-+: *$/.test(item.align[i])) {
                  item.align[i] = 'right';
                } else if (/^ *:-+: *$/.test(item.align[i])) {
                  item.align[i] = 'center';
        Severity: Major
        Found in app/assets/javascripts/grape_swagger_rails/marked.js and 1 other location - About 6 hrs to fix
        app/assets/javascripts/grape_swagger_rails/marked.js on lines 389..399

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

        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 (i = 0; i < item.align.length; i++) {
                if (/^ *-+: *$/.test(item.align[i])) {
                  item.align[i] = 'right';
                } else if (/^ *:-+: *$/.test(item.align[i])) {
                  item.align[i] = 'center';
        Severity: Major
        Found in app/assets/javascripts/grape_swagger_rails/marked.js and 1 other location - About 6 hrs to fix
        app/assets/javascripts/grape_swagger_rails/marked.js on lines 218..228

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

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function handleLogin has 147 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function handleLogin() {
          var scopes = [];
        
          var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
          if(auths) {
        Severity: Major
        Found in app/assets/javascripts/grape_swagger_rails/swagger-oauth.js - About 5 hrs to fix

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

                  getDate: function getDate() {
                      if (!this || !(this instanceof Date)) {
                          throw new TypeError('this is not a Date object.');
                      }
                      var year = originalGetFullYear(this);
          Severity: Major
          Found in app/assets/javascripts/grape_swagger_rails/es5-shim.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/grape_swagger_rails/es5-shim.js on lines 1204..1219

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

          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

                  getUTCDate: function getUTCDate() {
                      if (!this || !(this instanceof Date)) {
                          throw new TypeError('this is not a Date object.');
                      }
                      var year = originalGetUTCFullYear(this);
          Severity: Major
          Found in app/assets/javascripts/grape_swagger_rails/es5-shim.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/grape_swagger_rails/es5-shim.js on lines 1167..1182

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function handleLogin has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

          function handleLogin() {
            var scopes = [];
          
            var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
            if(auths) {
          Severity: Minor
          Found in app/assets/javascripts/grape_swagger_rails/swagger-oauth.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 output has 105 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          InlineLexer.prototype.output = function(src) {
            var out = ''
              , link
              , text
              , href
          Severity: Major
          Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 4 hrs to fix

            Function tok has 92 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Parser.prototype.tok = function() {
              switch (this.token.type) {
                case 'space': {
                  return '';
                }
            Severity: Major
            Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 3 hrs to fix

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

              var appName;
              var popupMask;
              var popupDialog;
              var clientId;
              var realm;
              Severity: Minor
              Found in app/assets/javascripts/grape_swagger_rails/swagger-oauth.js - About 3 hrs to fix

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

                    if (cap = this.rules.strong.exec(src)) {
                      src = src.substring(cap[0].length);
                      out += this.renderer.strong(this.output(cap[2] || cap[1]));
                      continue;
                    }
                Severity: Major
                Found in app/assets/javascripts/grape_swagger_rails/marked.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/grape_swagger_rails/marked.js on lines 651..655

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

                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 (cap = this.rules.em.exec(src)) {
                      src = src.substring(cap[0].length);
                      out += this.renderer.em(this.output(cap[2] || cap[1]));
                      continue;
                    }
                Severity: Major
                Found in app/assets/javascripts/grape_swagger_rails/marked.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/grape_swagger_rails/marked.js on lines 644..648

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

                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

                      item = {
                        type: 'table',
                        header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
                        align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
                        cells: cap[3].replace(/\n$/, '').split('\n')
                Severity: Major
                Found in app/assets/javascripts/grape_swagger_rails/marked.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/grape_swagger_rails/marked.js on lines 382..387

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

                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

                      item = {
                        type: 'table',
                        header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
                        align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
                        cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
                Severity: Major
                Found in app/assets/javascripts/grape_swagger_rails/marked.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/grape_swagger_rails/marked.js on lines 211..216

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function marked has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function marked(src, opt, callback) {
                  if (callback || typeof opt === 'function') {
                    if (!callback) {
                      callback = opt;
                      opt = null;
                Severity: Major
                Found in app/assets/javascripts/grape_swagger_rails/marked.js - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                                  if (match) {
                                      // parse months, days, hours, minutes, seconds, and milliseconds
                                      // provide default values if necessary
                                      // parse the UTC offset component
                                      var year = $Number(match[1]),
                  Severity: Critical
                  Found in app/assets/javascripts/grape_swagger_rails/es5-shim.js - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language