showdownjs/showdown

View on GitHub

Showing 100 of 103 total issues

Function exports has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (config) {
  config.set({
    // global config of your BrowserStack account
    browserStack: {
      username: process.env.BROWSERSTACK_USERNAME,
Severity: Major
Found in karma.browserstack.js - About 2 hrs to fix

Function makeMarkdown has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  this.makeMarkdown = function (src) {

    // replace \r\n with \n
    src = src.replace(/\r\n/g, '\n');
    src = src.replace(/\r/g, '\n'); // old macs
Severity: Major
Found in src/converter.js - About 2 hrs to fix

Function makeHtml has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  this.makeHtml = function (text) {
    //check if text is not falsy
    if (!text) {
      return text;
    }
Severity: Major
Found in src/converter.js - About 2 hrs to fix

Function parseTable has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function parseTable (rawTable) {
    var i, tableLines = rawTable.split('\n');

    for (i = 0; i < tableLines.length; ++i) {
      // strip wrong first and last column if wrapped tables are used
Severity: Major
Found in src/subParsers/makehtml/tables.js - About 2 hrs to fix

Function headerId has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function headerId (m) {
    var title,
        prefix;

    // It is separate from other options to allow combining prefix and customized
Severity: Minor
Found in src/subParsers/makehtml/headers.js - About 1 hr to fix

Function writeImageTag has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {

    var gUrls   = globals.gUrls,
        gTitles = globals.gTitles,
        gDims   = globals.gDimensions;
Severity: Minor
Found in src/subParsers/makehtml/images.js - About 1 hr to fix

Function writeAnchorTag has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function writeAnchorTag (evt, options, globals, emptyCase) {

    var wholeMatch = evt.getMatches().wholeMatch;
    var text = evt.getMatches().text;
    var id = evt.getMatches().id;
Severity: Minor
Found in src/subParsers/makehtml/links.js - About 1 hr to fix

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

showdown.helper.forEach = function (obj, callback) {
  'use strict';
  // check if obj is defined
  if (showdown.helper.isUndefined(obj)) {
    throw new Error('obj param is required');
Severity: Minor
Found in src/helpers.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 Event has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

showdown.helper.Event = function (name, text, params) {
  'use strict';

  var regexp = params.regexp || null;
  var matches = params.matches || {};
Severity: Minor
Found in src/helpers.js - About 1 hr to fix

Function _parseExtension has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function _parseExtension (ext, name) {

    name = name || null;
    // If it's a string, the extension was previously loaded
    if (showdown.helper.isString(ext)) {
Severity: Minor
Found in src/converter.js - About 1 hr to fix

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

      if (options.encodeEmails) {
        url = showdown.helper.encodeEmailAddress(url + mail);
        mail = showdown.helper.encodeEmailAddress(mail);
      } else {
        url = url + mail;
Severity: Major
Found in src/subParsers/makehtml/links.js and 1 other location - About 1 hr to fix
src/subParsers/makehtml/links.js on lines 315..320

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

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 (options.encodeEmails) {
        url = showdown.helper.encodeEmailAddress(url + mail);
        mail = showdown.helper.encodeEmailAddress(mail);
      } else {
        url = url + mail;
Severity: Major
Found in src/subParsers/makehtml/links.js and 1 other location - About 1 hr to fix
src/subParsers/makehtml/links.js on lines 414..419

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

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 4 locations. Consider refactoring.
Open

    if (node.querySelectorAll(':scope>tbody').length !== 0 && node.querySelectorAll(':scope>tbody>tr').length !== 0) {
      var tbody = node.querySelectorAll(':scope>tbody>tr');
      // tbody>tr can have td and th children, although th are not very screen reader friendly
      for (i = 0; i < tbody.length; ++i) {
        rows.push(iterateRow(tbody[i]));
Severity: Major
Found in src/subParsers/makemarkdown/table.js and 3 other locations - About 1 hr to fix
src/subParsers/makemarkdown/table.js on lines 42..49
src/subParsers/makemarkdown/table.js on lines 62..68
src/subParsers/makemarkdown/table.js on lines 71..78

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

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 4 locations. Consider refactoring.
Open

    if (node.querySelectorAll(':scope>tr').length !== 0) {

      var tr = node.querySelectorAll(':scope>tr');
      // tfoot>tr can have td and th children, although th are not very screen reader friendly
      for (i = 0; i < tr.length; ++i) {
Severity: Major
Found in src/subParsers/makemarkdown/table.js and 3 other locations - About 1 hr to fix
src/subParsers/makemarkdown/table.js on lines 42..49
src/subParsers/makemarkdown/table.js on lines 53..59
src/subParsers/makemarkdown/table.js on lines 62..68

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

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 4 locations. Consider refactoring.
Open

    if (node.querySelectorAll(':scope>tfoot').length !== 0 && node.querySelectorAll(':scope>tfoot>tr').length !== 0) {
      var tfoot = node.querySelectorAll(':scope>tfoot>tr');
      // tfoot>tr can have td and th children, although th are not very screen reader friendly
      for (i = 0; i < tfoot.length; ++i) {
        rows.push(iterateRow(tfoot[i]));
Severity: Major
Found in src/subParsers/makemarkdown/table.js and 3 other locations - About 1 hr to fix
src/subParsers/makemarkdown/table.js on lines 42..49
src/subParsers/makemarkdown/table.js on lines 53..59
src/subParsers/makemarkdown/table.js on lines 71..78

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

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 4 locations. Consider refactoring.
Open

    if (node.querySelectorAll(':scope>thead').length !== 0 && node.querySelectorAll(':scope>thead>tr').length !== 0) {
      var thead = node.querySelectorAll(':scope>thead>tr');

      // thead>tr can have td and th children
      for (i = 0; i < thead.length; ++i) {
Severity: Major
Found in src/subParsers/makemarkdown/table.js and 3 other locations - About 1 hr to fix
src/subParsers/makemarkdown/table.js on lines 53..59
src/subParsers/makemarkdown/table.js on lines 62..68
src/subParsers/makemarkdown/table.js on lines 71..78

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

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 extension has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

showdown.extension = function (name, ext) {
  'use strict';

  if (!showdown.helper.isString(name)) {
    throw Error('Extension \'name\' must be a string');
Severity: Minor
Found in src/showdown.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 replaceRecursiveRegExp has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
  'use strict';

  if (!showdown.helper.isFunction(replacement)) {
    var repStr = replacement;
Severity: Minor
Found in src/helpers.js - About 1 hr to fix

Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (config) {
  config.set({
    client: {
      captureConsole: true
    },
Severity: Minor
Found in karma.conf.js - About 1 hr to fix

Function rgxFindMatchPos has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var rgxFindMatchPos = function (str, left, right, flags) {
  'use strict';
  var f = flags || '',
      g = f.indexOf('g') > -1,
      x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
Severity: Minor
Found in src/helpers.js - About 1 hr to fix
Severity
Category
Status
Source
Language