Showing 17 of 17 total issues
Function exports
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(grunt, serverDirs) {
if (!grunt.task.exists('textFree')) {
throw new Error('Gruntfile no textFree task');
}
Function goTo
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
Tag.prototype.goTo = function(toIndex, expect, rAllowed) {
var content = this.ctrl.content;
if (toIndex >= this.startIndex && toIndex < this.endIndex) {
return null;
}
- 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 documentClickHandler
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
var documentClickHandler = function (e) {
if (e.target.classList.contains(tfInjectClassName)) {
var tfObj = tf(e.target.innerHTML), width, dom;
var handler = function (e) {
if (!e.target.classList.contains(prefix + 'btn')) {
Function set
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
set: function(key, val, force, obj) {
if (typeof key !== 'string') {
return false;
}
- 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
File inject.js
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global __textFreeOptions */
/**
* NOTE: 工具程序,不考虑性能
*/
Function tf
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function tf(html) {
var data = {origin: html};
// 去除首尾换行
html = html.trim();
File tag-ctrl.js
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
var KV = require('./kv.js');
var CONST = require('./variable.js');
var util = require('util');
function Tag(ctrl, raw, key, index) {
Function goTo
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Tag.prototype.goTo = function(toIndex, expect, rAllowed) {
var content = this.ctrl.content;
if (toIndex >= this.startIndex && toIndex < this.endIndex) {
return null;
}
Function handler
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
var handler = function (e) {
if (!e.target.classList.contains(prefix + 'btn')) {
return false;
}
query('.control', dom).removeEventListener('click', handler, false);
Function exec
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
TagCtrl.prototype.exec = function(data, options) {
var self = this;
data = data || {};
options = options || {};
Function runGruntTask
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function runGruntTask(grunt, task, taskTarget, fn, cb) {
if (typeof taskTarget === 'function') {
cb = fn;
fn = taskTarget;
taskTarget = null;
Function set
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
set: function(key, val, force, obj) {
if (typeof key !== 'string') {
return false;
}
Function getNewestFile
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getNewestFile(grunt, file) {
var dir = path.dirname(file),
base = path.basename(file);
// 找到一个最新的文件 file
Function get
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
get: function(key, defaultVal, obj) {
if (arguments.length === 2) {
obj = defaultVal;
defaultVal = undefined;
}
- 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
Avoid deeply nested control flow statements. Open
if (data.status === 0) {
dom.parentNode.removeChild(dom);
} else {
window.alert(data.msg);
e.target.classList.remove(prefix + 'disabled');
Function runGruntTask
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function runGruntTask(grunt, task, taskTarget, fn, cb) {
Function runGruntTask
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function runGruntTask(grunt, task, taskTarget, fn, cb) {
if (typeof taskTarget === 'function') {
cb = fn;
fn = taskTarget;
taskTarget = null;
- 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"