zammad/zammad

View on GitHub
app/assets/javascripts/app/lib/base/marked.js

Summary

Maintainability
F
1 wk
Test Coverage

File marked.js has 912 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/app/lib/base/marked.js - About 2 days to fix

    Function token has 214 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/app/lib/base/marked.js - About 1 day to fix

      Function output has 107 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/app/lib/base/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/app/lib/base/marked.js - About 3 hrs to fix

          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/app/lib/base/marked.js - About 2 hrs to fix

            Avoid deeply nested control flow statements.
            Open

                      if (bull !== b && !(bull.length > 1 && b.length > 1)) {
                        src = cap.slice(i + 1).join('\n') + src;
                        i = l - 1;
                      }
            Severity: Major
            Found in app/assets/javascripts/app/lib/base/marked.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (!loose) loose = next;
              Severity: Major
              Found in app/assets/javascripts/app/lib/base/marked.js - About 45 mins to fix

                Avoid too many return statements within this function.
                Open

                      return this.renderer.listitem(body);
                Severity: Major
                Found in app/assets/javascripts/app/lib/base/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/app/lib/base/marked.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

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

                      Avoid too many return statements within this function.
                      Open

                            return this.renderer.paragraph(this.parseText());
                      Severity: Major
                      Found in app/assets/javascripts/app/lib/base/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/app/lib/base/marked.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/app/lib/base/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/app/lib/base/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/app/lib/base/marked.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return Parser.parse(Lexer.lex(src, opt), opt);
                                Severity: Major
                                Found in app/assets/javascripts/app/lib/base/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/app/lib/base/marked.js - About 30 mins 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/app/lib/base/marked.js and 1 other location - About 6 hrs to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 391..401

                                    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/app/lib/base/marked.js and 1 other location - About 6 hrs to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 219..229

                                    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

                                    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/app/lib/base/marked.js and 1 other location - About 2 hrs to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 648..652

                                    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.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/app/lib/base/marked.js and 1 other location - About 2 hrs to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 655..659

                                    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/app/lib/base/marked.js and 1 other location - About 2 hrs to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 212..217

                                    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/app/lib/base/marked.js and 1 other location - About 2 hrs to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 384..389

                                    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

                                        case 'blockquote_start': {
                                          var body = '';
                                    
                                          while (this.next().type !== 'blockquote_end') {
                                            body += this.tok();
                                    Severity: Major
                                    Found in app/assets/javascripts/app/lib/base/marked.js and 1 other location - About 1 hr to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 1059..1067

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

                                    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

                                        case 'loose_item_start': {
                                          var body = '';
                                    
                                          while (this.next().type !== 'list_item_end') {
                                            body += this.tok();
                                    Severity: Major
                                    Found in app/assets/javascripts/app/lib/base/marked.js and 1 other location - About 1 hr to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 1029..1037

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

                                    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.options.gfm) {
                                        if (this.options.breaks) {
                                          this.rules = inline.breaks;
                                        } else {
                                          this.rules = inline.gfm;
                                    Severity: Minor
                                    Found in app/assets/javascripts/app/lib/base/marked.js and 1 other location - About 55 mins to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 108..114

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

                                    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.options.gfm) {
                                        if (this.options.tables) {
                                          this.rules = block.tables;
                                        } else {
                                          this.rules = block.gfm;
                                    Severity: Minor
                                    Found in app/assets/javascripts/app/lib/base/marked.js and 1 other location - About 55 mins to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 532..540

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

                                    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

                                    Parser.parse = function(src, options, renderer) {
                                      var parser = new Parser(options, renderer);
                                      return parser.parse(src);
                                    };
                                    Severity: Minor
                                    Found in app/assets/javascripts/app/lib/base/marked.js and 1 other location - About 35 mins to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 553..556

                                    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

                                    InlineLexer.output = function(src, links, options) {
                                      var inline = new InlineLexer(links, options);
                                      return inline.output(src);
                                    };
                                    Severity: Minor
                                    Found in app/assets/javascripts/app/lib/base/marked.js and 1 other location - About 35 mins to fix
                                    app/assets/javascripts/app/lib/base/marked.js on lines 920..923

                                    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