Showing 278 of 361 total issues
Function drawForLine
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function drawForLine(line, fromArg, toArg) {
var lineObj = getLine(doc, line);
var lineLen = lineObj.text.length;
var start, end;
function coords(ch, bias) {
Function searchOverlay
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function searchOverlay(query) {
if (query.source.charAt(0) == '^') {
var matchSol = true;
}
return {
Function findMatchingBracket
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function findMatchingBracket(cm, where, strict) {
var state = cm.state.matchBrackets;
var maxScanLen = (state && state.maxScanLineLength) || 10000;
var maxScanLines = (state && state.maxScanLines) || 100;
Function update
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function update(cm) {
var from = cm.getCursor("start"), to = cm.getCursor("end");
if (cmp(from, to) == 0) return clear(cm);
var array = cm.state.markedSelection;
Function dispatch
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function dispatch(stream, state) {
var isPHP = state.curMode == phpMode;
if (stream.sol() && state.pending != '"') state.pending = null;
if (!isPHP) {
if (stream.match(/^<\?\w*/)) {
Function applyPlacement
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
, applyPlacement: function(offset, placement){
var $tip = this.tip()
, width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight
, actualWidth
Function tokenStringFactory
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function tokenStringFactory(delimiter) {
while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
delimiter = delimiter.substr(1);
}
var singleline = delimiter.length == 1;
Function replace
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
replace: function(cm, actionArgs, vim) {
var replaceWith = actionArgs.selectedCharacter;
var curStart = cm.getCursor();
var replaceTo;
var curEnd;
Function makeChangeFromHistory
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function makeChangeFromHistory(doc, type) {
if (doc.cm && doc.cm.state.suppressEdits) return;
var hist = doc.history;
var event = (type == "undo" ? hist.done : hist.undone).pop();
Function dedent
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function dedent(stream, state, type) {
type = type || 'py';
if (state.scopes.length == 1) return;
if (state.scopes[0].type === 'py') {
var _indent = stream.indentation();
Function jumpToMark
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
jumpToMark: function(cm, motionArgs, vim) {
var best = cm.getCursor();
for (var i = 0; i < motionArgs.repeat; i++) {
var cursor = best;
for (var key in vim.marks) {
Function addWidget
has 29 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.doc, pos));
var top = pos.bottom, left = pos.left;
node.style.position = "absolute";
Function map
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
map: function(lhs, rhs) {
if (lhs != ':' && lhs.charAt(0) == ':') {
var commandName = lhs.substring(1);
if (rhs != ':' && rhs.charAt(0) == ':') {
// Ex to Ex mapping
Function highlightLine
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function highlightLine(cm, line, state, forceToEnd) {
// A styles array always starts with a number identifying the
// mode/overlays that it is based on (for easy invalidation).
var st = [cm.state.modeGen];
// Compute the base array of styles
Function addToHistory
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function addToHistory(doc, change, selAfter, opId) {
var hist = doc.history;
hist.undone.length = 0;
var time = +new Date, cur = lst(hist.done);
Function openModalBox
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function openModalBox(element, type) {
var buttons = {};
if (type == 'modal-box') {
var label_save = $('#modal-box').data('label-save');
Function runMode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
- 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 cursorCoords
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function cursorCoords(cm, pos, context, lineObj, measurement) {
lineObj = lineObj || getLine(cm.doc, pos.line);
if (!measurement) measurement = measureLine(cm, lineObj);
function get(ch, right) {
var m = measureChar(cm, lineObj, ch, measurement, right ? "right" : "left");
Function updateDisplay
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateDisplay(cm, changes, viewPort, forced) {
var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo, updated;
var visible = visibleLines(cm.display, cm.doc, viewPort);
for (var first = true;; first = false) {
var oldWidth = cm.display.scroller.clientWidth;
Function enterInsertMode
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
enterInsertMode: function(cm, actionArgs, vim) {
if (cm.getOption('readOnly')) { return; }
vim.insertMode = true;
vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1;
var insertAt = (actionArgs) ? actionArgs.insertAt : null;