File markdown.js
has 727 lines of code (exceeds 250 allowed). Consider refactoring. Open
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
- Create a ticketCreate a ticket
Function inlineNormal
has 203 lines of code (exceeds 25 allowed). Consider refactoring. Open
function inlineNormal(stream, state) {
var style = state.text(stream, state);
if (typeof style !== 'undefined')
return style;
- Create a ticketCreate a ticket
Function blockNormal
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
function blockNormal(stream, state) {
var firstTokenOnLine = stream.column() === state.indentation;
var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream);
var prevLineIsIndentedCode = state.indentedCode;
var prevLineIsHr = state.prevLine.hr;
- Create a ticketCreate a ticket
Function getType
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getType(state) {
var styles = [];
if (state.formatting) {
styles.push(tokenTypes.formatting);
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
} else if (
// if setext set, indicates line after ---/===
state.setext || (
// line before ---/===
(!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false &&
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
} else if (ch === "*" || ch === "_") {
var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2)
while (len < 3 && stream.eat(ch)) len++
var after = stream.peek() || " "
// See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis
- Create a ticketCreate a ticket
Function copyState
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
copyState: function(s) {
return {
f: s.f,
prevLine: s.prevLine,
- Create a ticketCreate a ticket
Function startState
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
startState: function() {
return {
f: blockNormal,
prevLine: {stream: null},
- Create a ticketCreate a ticket
Function blankLine
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function blankLine(state) {
// Reset linkTitle state
state.linkTitle = false;
state.linkHref = false;
state.linkText = false;
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
return getType(state);
} else { // Not surrounded by spaces, back up pointer
stream.backUp(2);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
} else if (
// if setext set, indicates line after ---/===
state.setext || (
// line before ---/===
(!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false &&
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (modeCfg.highlightFormatting) state.formatting = "code-block";
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
(!inner.state.context && inner.state.tokenize.isInText)) ||
(state.md_inside && stream.current().indexOf(">") > -1)) {
state.f = inlineNormal;
state.block = blockNormal;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return type + tokenTypes.linkInline;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return tokenTypes.linkHref;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return retType;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return tokenTypes.hr;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return type ? type + " " + formattingEscape : formattingEscape;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return type;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return switchBlock(stream, state, htmlBlock);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return switchInline(stream, state, state.inline);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state)
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return "tag";
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
if (state.linkText && stream.match(/^.*?\]/)) return getType(state)
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return switchInline(stream, state, footnoteLink);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return type;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return type + tokenTypes.linkEmail;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return getType(state)
- Create a ticketCreate a ticket
Identical blocks of code found in 2 locations. Consider refactoring. Open
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
- Read upRead up
- Create a ticketCreate a ticket
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 8696.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76