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);
        };
Severity: Minor
Found in src/lexer.js - About 1 day to fix

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);
        };
Severity: Major
Found in src/lexer.js - About 4 hrs to fix

    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'),
    Severity: Major
    Found in Gruntfile.js - About 2 hrs to fix

      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;
      
      
      Severity: Minor
      Found in src/lexer.js - About 1 hr to fix

        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;
        Severity: Minor
        Found in src/trie.js - About 1 hr to fix

        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();
        Severity: Minor
        Found in src/main.js - About 1 hr to fix

          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;
          Severity: Minor
          Found in src/lexer.js - About 1 hr to fix

            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;
            Severity: Minor
            Found in src/trie.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      switch (Object.prototype.toString.call(token)) {
                                          case "[object Array]":
                                              tokens = token.slice(1);
                                              token = token[0];
                                              break;
              Severity: Major
              Found in src/lexer.js - About 45 mins to fix

                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;
                                        }
                Severity: Major
                Found in src/lexer.js - About 45 mins to fix

                  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;
                  Severity: Major
                  Found in src/lexer.js - About 45 mins to fix

                    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 = [];
                    
                    
                    Severity: Minor
                    Found in src/trie.js - About 35 mins to fix

                    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) {
                    Severity: Minor
                    Found in src/main.js - About 25 mins to fix

                    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)) {
                    Severity: Minor
                    Found in src/bayes.js - About 25 mins to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language