showdownjs/showdown

View on GitHub

Showing 54 of 103 total issues

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

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

Function Messenger has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function Messenger (writeMode, supress, mute) {
  'use strict';
  writeMode = writeMode || 'stderr';
  supress = (!!supress || !!mute);
  mute = !!mute;
Severity: Minor
Found in src/cli/cli.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 a Cognitive Complexity of 11 (exceeds 5 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

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 Messenger has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Messenger (writeMode, supress, mute) {
  'use strict';
  writeMode = writeMode || 'stderr';
  supress = (!!supress || !!mute);
  mute = !!mute;
Severity: Minor
Found in src/cli/cli.js - About 1 hr to fix

Function createEvent has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function createEvent (rgx, evtName, wholeMatch, text, id, url, title, options, globals) {
Severity: Major
Found in src/subParsers/makehtml/links.js - About 1 hr to fix

Function substitutePreCodeTags has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function substitutePreCodeTags (doc) {

      var pres = doc.querySelectorAll('pre'),
          presPH = [];

Severity: Minor
Found in src/converter.js - About 1 hr to fix

Function writeImageTag has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
Severity: Major
Found in src/subParsers/makehtml/images.js - About 1 hr to fix

Function writeImageTagBase64 has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
Severity: Major
Found in src/subParsers/makehtml/images.js - About 1 hr to fix

Function writeImageTagBaseUrl has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function writeImageTagBaseUrl (wholeMatch, altText, linkId, url, width, height, m5, title) {
Severity: Major
Found in src/subParsers/makehtml/images.js - About 1 hr to fix

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

showdown.subParser = function (name, func) {
  'use strict';
  if (showdown.helper.isString(name)) {
    if (typeof func !== 'undefined') {
      parsers[name] = func;
Severity: Minor
Found in src/showdown.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 replaceFunc has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
Severity: Major
Found in src/subParsers/makehtml/stripLinkDefinitions.js - About 50 mins to fix

Avoid deeply nested control flow statements.
Open

        if (!--t) {
          end = m.index + m[0].length;
          var obj = {
            left: {start: start, end: s},
            match: {start: s, end: m.index},
Severity: Major
Found in src/helpers.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if (matches !== null) {
                language = matches[1];
                break;
              }
Severity: Major
Found in src/converter.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          if (typeof ext.listeners[ln] !== 'function') {
            ret.valid = false;
            ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
              ' must be a function but ' + typeof ext.listeners[ln] + ' given';
            return ret;
Severity: Major
Found in src/showdown.js - About 45 mins to fix

Function replaceAnchorTagReference has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function replaceAnchorTagReference (rgx, evtRootName, options, globals, emptyCase) {
Severity: Minor
Found in src/subParsers/makehtml/links.js - About 35 mins to fix

Function replaceRecursiveRegExp has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
Severity: Minor
Found in src/helpers.js - About 35 mins to fix
Severity
Category
Status
Source
Language