Showing 177 of 219 total issues
Function updateSelectionRange
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateSelectionRange(cm) {
var display = cm.display, doc = cm.view.doc, sel = cm.view.sel;
var fragment = document.createDocumentFragment();
var clientWidth = display.lineSpace.offsetWidth, pl = paddingLeft(cm.display);
Method read_template_file
has a Cognitive Complexity of 18 (exceeds 5 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)
- 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 tokenBase
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function tokenBase(stream, state) {
var ch = stream.next();
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
else if (ch == "/" && stream.eat("*")) {
state.tokenize = tokenCComment;
Function insertLineContent
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function insertLineContent(line, builder, styles) {
var spans = line.markedSpans;
if (!spans) {
for (var i = 1; i < styles.length; i+=2)
builder.addToken(builder, styles[i], styleToClass(styles[i+1]));
Function token
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
token: function(stream, state) {
var ch = stream.peek();
var esc = state.escaped;
state.escaped = false;
/* comments */
Function inText
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function inText(stream, state) {
function chain(parser) {
state.tokenize = parser;
return parser(stream, state);
}
Function onScrollWheel
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function onScrollWheel(cm, e) {
var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
else if (dy == null) dy = e.wheelDelta;
Function jsTokenBase
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function jsTokenBase(stream, state) {
var ch = stream.next();
if (ch == '"' || ch == "'")
return chain(stream, state, jsTokenString(ch));
else if (/[\[\]{}\(\),;\:\.]/.test(ch))
Function makeDisplay
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function makeDisplay(place) {
var d = {};
var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");
if (webkit) input.style.width = "1000px";
else input.setAttribute("wrap", "off");
Function patchDisplay
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
var dims = getDimensions(cm);
var display = cm.display, lineNumbers = cm.options.lineNumbers;
if (!intact.length && (!webkit || !cm.display.currentWheelTarget))
removeChildren(display.lineDiv);
Function markText
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function markText(cm, from, to, options, type) {
var doc = cm.view.doc;
var marker = new TextMarker(cm, type);
if (type == "range" && !posLess(from, to)) return marker;
if (options) for (var opt in options) if (options.hasOwnProperty(opt))
Method render
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def render *args
source, context = normalize_render_options *args
context = merge_context context, additional_render_options
source ||= inherited_layout
- 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 updateMarkedSpans
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateMarkedSpans(oldFirst, oldLast, startCh, endCh, newText) {
if (!oldFirst && !oldLast) return newText;
// Get the spans that 'stick out' on both sides
var first = markedSpansBefore(oldFirst, startCh);
var last = markedSpansAfter(oldLast, startCh, endCh);
Function onDrop
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function onDrop(e) {
var cm = this;
if (eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))))
return;
e_preventDefault(e);
Function onContextMenu
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function onContextMenu(cm, e) {
var display = cm.display;
if (eventInWidget(display, e)) return;
var sel = cm.view.sel;
Function skipAtomic
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function skipAtomic(cm, pos, bias, mayClear) {
var doc = cm.view.doc, flipped = false, curPos = pos;
var dir = bias || 1;
cm.view.cantEdit = false;
search: for (;;) {
Function fromTextArea
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
CodeMirror.fromTextArea = function(textarea, options) {
if (!options) options = {};
options.value = textarea.value;
if (!options.tabindex && textarea.tabindex)
options.tabindex = textarea.tabindex;
Function measureLineInner
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function measureLineInner(cm, line) {
var display = cm.display, measure = emptyArray(line.text.length);
var pre = lineContent(cm, line, measure);
// IE does not cache element positions of inline elements between
Function Widget
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Widget(tag_name, methods) {
if (!methods) {
methods = tag_name;
tag_name = 'DIV';
}
Function tokenize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var tokenize = function(stream, state) {
var token = null;
if (stream.peek() == '\'' || stream.peek() == '"') {
token = inString(stream, state);