Showing 35 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;
- 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 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++) {
- 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 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;
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) {
- 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 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);
- 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 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);
- 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 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;
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);
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);
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) {
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++) {
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;
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) {
Identical blocks of code found in 3 locations. Consider refactoring. Open
async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) {
loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
if(err) {
return _callback(err);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 54.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
async.map([ "base.dat.gz", "check.dat.gz" ], function (filename, _callback) {
loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
if(err) {
return _callback(err);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 54.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
async.map([ "unk.dat.gz", "unk_pos.dat.gz", "unk_map.dat.gz", "unk_char.dat.gz", "unk_compat.dat.gz", "unk_invoke.dat.gz" ], function (filename, _callback) {
loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
if(err) {
return _callback(err);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 54.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- 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 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([
- 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 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) {
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]);
- 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"