File helpers.js
has 2173 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* showdownjs helper functions
*/
if (!showdown.hasOwnProperty('helper')) {
- Create a ticketCreate a ticket
Function rgxFindMatchPos
has a Cognitive Complexity of 22 (exceeds 5 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, '')),
- Read upRead up
- Create a ticketCreate a ticket
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 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');
- Read upRead up
- Create a ticketCreate a ticket
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 || {};
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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, '')),
- Create a ticketCreate a ticket
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;
- Read upRead up
- Create a ticketCreate a ticket
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
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},
- Create a ticketCreate a ticket
Function replaceRecursiveRegExp
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
- Create a ticketCreate a ticket
Function repeat
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
showdown.helper.repeat = function (str, count) {
'use strict';
// use built-in method if it's available
if (!showdown.helper.isUndefined(String.prototype.repeat)) {
return str.repeat(count);
- Read upRead up
- Create a ticketCreate a ticket
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"