Showing 14 of 14 total issues
Function Lexer
has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring. Open
function Lexer(defunct) {
if (typeof defunct !== "function"){
defunct = function (char) {
throw new TypeError("Unexpected character at index " + (this.index - 1) + ": " + char);
};
- 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 Lexer
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Lexer(defunct) {
if (typeof defunct !== "function"){
defunct = function (char) {
throw new TypeError("Unexpected character at index " + (this.index - 1) + ": " + char);
};
Function exports
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
Function lex
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.lex = function () {
if (tokens.length) return tokens.shift();
this.reject = true;
Function search
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
search: function (bytes) {
var node = this.root, len = bytes.length, result = [];
var word = [], j = 0;
for (var i = 0; i < len; i++) {
var c = bytes[i], childs = node.childs;
- 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 convert
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Geng.convert = function () {
var results = {},
result,
trieTree = new Geng.trie(),
lexer = new Geng.lexer();
Function scan
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function scan() {
/*jshint validthis: true */
var that = this;
var matches = [];
var index = 0;
Function search
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
search: function (bytes) {
var node = this.root, len = bytes.length, result = [];
var word = [], j = 0;
for (var i = 0; i < len; i++) {
var c = bytes[i], childs = node.childs;
Avoid deeply nested control flow statements. Open
switch (Object.prototype.toString.call(token)) {
case "[object Array]":
tokens = token.slice(1);
token = token[0];
break;
Avoid deeply nested control flow statements. Open
if (matches[j].length > matches[k].length) {
var temple = matches[j];
matches[j] = matches[k];
matches[k] = temple;
}
Avoid deeply nested control flow statements. Open
if (Object.prototype.toString.call(token2) === "[object Array]") {
tokens = token2.slice(1);
return token2[0];
} else return token2;
Function splitWords
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
splitWords: function (words) {
// 转换成单字节进行搜索
var bytes = this.toBytes(words);
var start = 0, end = bytes.length - 1, 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 extend
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Utils.extend = function (object) {
var source, prop;
for (var i = 1, length = arguments.length; i < length; i++) {
source = arguments[i];
for (prop in source) {
- 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 Bayes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function Bayes(options) {
// set options object
this.options = {};
if (typeof options !== 'undefined') {
if (!options || typeof options !== 'object' || Array.isArray(options)) {
- 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"