Showing 177 of 219 total issues
Function highlightLine
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function highlightLine(cm, line, state) {
// A styles array always starts with a number identifying the
// mode/overlays that it is based on (for easy invalidation).
var st = [cm.view.modeGen];
// Compute the base array of styles
Function addChange
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) {
Function CodeMirror
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
this.options = options = options || {};
// Determine effective options based on given values and defaults.
Method read_template_file
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def read_template_file template_path, context
source = case template_type(template_path)
when :snippet then
template_path = template_path.gsub(/^snippets\//, '')
snippet = snippet(template_path)
Function addWidget
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
addWidget: function(pos, node, scroll, vert, horiz) {
var display = this.display;
pos = cursorCoords(this, clipPos(this.view.doc, pos));
var top = pos.top, left = pos.left;
node.style.position = "absolute";
Function findMatchingBracket
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function findMatchingBracket(cm) {
var cur = cm.getCursor(), line = cm.getLineHandle(cur.line), pos = cur.ch - 1;
var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
if (!match) return null;
var forward = match.charAt(1) == ">", d = forward ? 1 : -1;
Function select
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
select: function() {
if (this.dogPiling(arguments)) { return this; }
var result = old_select.apply(this, arguments);
var url = R(this.link.get('href'));
Consider simplifying this complex logical expression. Open
Open
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) &&
!posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
var dragEnd = operation(cm, function(e2) {
if (webkit) display.scroller.draggable = false;
view.draggingText = false;
Method expires_in
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def expires_in expiration
fragments = expiration.to_s.split(' ').map(&:strip)
times = fragments.map do |fragment|
TIME_FORMATS.inject(nil) do |result, (format, multiplier)|
break result if result
- Read upRead up
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 updateDoc
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function updateDoc(cm, from, to, newText, selUpdate, origin) {
Function updateDocNoUndo
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function updateDocNoUndo(cm, from, to, lines, selUpdate, origin) {
Avoid deeply nested control flow statements. Open
Open
if (posEq(newPos, curPos)) {
newPos.ch += dir;
if (newPos.ch < 0) {
if (newPos.line) newPos = clipPos(doc, {line: newPos.line - 1});
else newPos = null;
Avoid deeply nested control flow statements. Open
Open
if (m.className) spanStyle += " " + m.className;
Avoid deeply nested control flow statements. Open
Open
if (pos < j) order.splice(at, 0, {from: pos, to: j, level: 1});
Avoid deeply nested control flow statements. Open
Open
if (sameLine) (first || (first = [])).push(span);
Avoid deeply nested control flow statements. Open
Open
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
Avoid deeply nested control flow statements. Open
Open
if (mayClear && m.clearOnEnter) {
(toClear || (toClear = [])).push(m);
continue;
} else if (!m.atomic) continue;
Avoid deeply nested control flow statements. Open
Open
if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
Avoid deeply nested control flow statements. Open
Open
if (widgets) for (var i = 0; i < widgets.length; ++i)
widgets[i].height = widgets[i].node.offsetHeight;
Avoid deeply nested control flow statements. Open
Open
if (prev.nodeType == "pre") {
var wrap = elt("div", null, null, "position: relative");
prev.parentNode.replaceChild(wrap, prev);
wrap.appendChild(prev);
prev = wrap;