takuyaa/kuromoji.js

View on GitHub

Showing 30 of 35 total issues

Function build has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

ViterbiBuilder.prototype.build = function (sentence_str) {
    var lattice = new ViterbiLattice();
    var sentence = new SurrogateAwareString(sentence_str);

    var key, trie_id, left_id, right_id, word_cost;
Severity: Minor
Found in src/viterbi/ViterbiBuilder.js - About 3 hrs 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 initCategoryMappings has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

CharacterDefinition.prototype.initCategoryMappings = function (category_mapping) {
    // Initialize map by DEFAULT class
    var code_point;
    if (category_mapping != null) {
        for (var i = 0; i < category_mapping.length; i++) {
Severity: Minor
Found in src/dict/CharacterDefinition.js - About 3 hrs 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 load has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

DictionaryLoader.prototype.load = function (load_callback) {
    var dic = this.dic;
    var dic_path = this.dic_path;
    var loadArrayBuffer = this.loadArrayBuffer;

Severity: Major
Found in src/loader/DictionaryLoader.js - About 3 hrs to fix

    Function forward has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    ViterbiSearcher.prototype.forward = function (lattice) {
        var i, j, k;
        for (i = 1; i <= lattice.eos_pos; i++) {
            var nodes = lattice.nodes_end_at[i];
            if (nodes == null) {
    Severity: Minor
    Found in src/viterbi/ViterbiSearcher.js - About 2 hrs 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 stringToUtf8Bytes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    var stringToUtf8Bytes = function (str) {
    
        // Max size of 1 character is 4 bytes
        var bytes = new Uint8Array(str.length * 4);
    
    
    Severity: Minor
    Found in src/util/ByteBuffer.js - About 2 hrs 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 tokenizeForSentence has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    Tokenizer.prototype.tokenizeForSentence = function (sentence, tokens) {
        if (tokens == null) {
            tokens = [];
        }
        var lattice = this.getLattice(sentence);
    Severity: Minor
    Found in src/Tokenizer.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 build has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ViterbiBuilder.prototype.build = function (sentence_str) {
        var lattice = new ViterbiLattice();
        var sentence = new SurrogateAwareString(sentence_str);
    
        var key, trie_id, left_id, right_id, word_cost;
    Severity: Minor
    Found in src/viterbi/ViterbiBuilder.js - About 1 hr to fix

      Function stringToUtf8Bytes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var stringToUtf8Bytes = function (str) {
      
          // Max size of 1 character is 4 bytes
          var bytes = new Uint8Array(str.length * 4);
      
      
      Severity: Minor
      Found in src/util/ByteBuffer.js - About 1 hr to fix

        Function tokenizeForSentence has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Tokenizer.prototype.tokenizeForSentence = function (sentence, tokens) {
            if (tokens == null) {
                tokens = [];
            }
            var lattice = this.getLattice(sentence);
        Severity: Minor
        Found in src/Tokenizer.js - About 1 hr to fix

          Function forward has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ViterbiSearcher.prototype.forward = function (lattice) {
              var i, j, k;
              for (i = 1; i <= lattice.eos_pos; i++) {
                  var nodes = lattice.nodes_end_at[i];
                  if (nodes == null) {
          Severity: Minor
          Found in src/viterbi/ViterbiSearcher.js - About 1 hr to fix

            Function initCategoryMappings has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            CharacterDefinition.prototype.initCategoryMappings = function (category_mapping) {
                // Initialize map by DEFAULT class
                var code_point;
                if (category_mapping != null) {
                    for (var i = 0; i < category_mapping.length; i++) {
            Severity: Minor
            Found in src/dict/CharacterDefinition.js - About 1 hr to fix

              Function utf8BytesToString has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var utf8BytesToString = function (bytes) {
              
                  var str = "";
                  var code, b1, b2, b3, b4, upper, lower;
                  var i = 0;
              Severity: Minor
              Found in src/util/ByteBuffer.js - About 1 hr to fix

                Function ViterbiNode has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function ViterbiNode(node_name, node_cost, start_pos, length, type, left_id, right_id, surface_form) {
                Severity: Major
                Found in src/viterbi/ViterbiNode.js - About 1 hr to fix

                  Function utf8BytesToString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var utf8BytesToString = function (bytes) {
                  
                      var str = "";
                      var code, b1, b2, b3, b4, upper, lower;
                      var i = 0;
                  Severity: Minor
                  Found in src/util/ByteBuffer.js - About 55 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 DynamicDictionaries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) {
                      if (trie != null) {
                          this.trie = trie;
                      } else {
                          this.trie = doublearray.builder(0).build([
                  Severity: Minor
                  Found in src/dict/DynamicDictionaries.js - About 45 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 loadUnknownDictionaries has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  DynamicDictionaries.prototype.loadUnknownDictionaries = function (unk_buffer, unk_pos_buffer, unk_map_buffer, cat_map_buffer, compat_cat_map_buffer, invoke_def_buffer) {
                  Severity: Minor
                  Found in src/dict/DynamicDictionaries.js - About 45 mins to fix

                    Function parseCharCategory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    CharacterDefinition.parseCharCategory = function (class_id, parsed_category_def) {
                        var category = parsed_category_def[1];
                        var invoke = parseInt(parsed_category_def[2]);
                        var grouping = parseInt(parsed_category_def[3]);
                        var max_length = parseInt(parsed_category_def[4]);
                    Severity: Minor
                    Found in src/dict/CharacterDefinition.js - About 45 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 lookupCompatibleCategory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    CharacterDefinition.prototype.lookupCompatibleCategory = function (ch) {
                        var classes = [];
                    
                        /*
                         if (SurrogateAwareString.isSurrogatePair(ch)) {
                    Severity: Minor
                    Found in src/dict/CharacterDefinition.js - About 45 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

                    Avoid deeply nested control flow statements.
                    Open

                                        if (class_id == null) {
                                            continue;
                                        }
                    Severity: Major
                    Found in src/dict/CharacterDefinition.js - About 45 mins to fix

                      Function loadUnknownDictionaries has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      UnknownDictionary.prototype.loadUnknownDictionaries = function (unk_buffer, unk_pos_buffer, unk_map_buffer, cat_map_buffer, compat_cat_map_buffer, invoke_def_buffer) {
                      Severity: Minor
                      Found in src/dict/UnknownDictionary.js - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language