maxmilhas-org/nodejs-trie

View on GitHub

Showing 9 of 9 total issues

Function getStringList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export function* getStringList(
    strings: Iterable<string>,
    transform: (s: string) => string,
) {
    for (const str of strings) {
Severity: Minor
Found in src/get-string-list.ts - 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 addWord has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function addWord(trie: Trie, word: string, value?: unknown) {
    let current = trie;
    const context = { i: 0, char: '' };
    const synonymTrie = trie.s;
    const transform = getTrieTransform(trie);
Severity: Minor
Found in src/trie.ts - About 1 hr to fix

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

    function getLastPerfectMatch(
        processedSynonyms: TrieParameters | undefined,
        word: string,
        context: { i: number; char: string },
    ) {
    Severity: Minor
    Found in src/trie.ts - 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 addWord has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export function addWord(trie: Trie, word: string, value?: unknown) {
        let current = trie;
        const context = { i: 0, char: '' };
        const synonymTrie = trie.s;
        const transform = getTrieTransform(trie);
    Severity: Minor
    Found in src/trie.ts - 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 getQueue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getQueue<T>(): Queue<T> {
        let first: QueueNode<T> | undefined;
        let last: QueueNode<T> | undefined;
        return {
            hasItems() {
    Severity: Minor
    Found in src/utils.ts - 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 resolveValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function* resolveValue<TValue>(
        value: TValue,
        transform: (s: string) => string,
        callback: typeof iterate,
    ): Iterable<string> {
    Severity: Minor
    Found in src/object-to-string-list.ts - 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 processCharSynonyms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export function processCharSynonyms(
        synonymChars: string[][],
        options?: TrieOptions,
    ): TrieParameters {
        const set = new Set<string>();
    Severity: Minor
    Found in src/trie.ts - 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 createArrTrie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export function createArrTrie(list: string[]) {
        const trie: ArrayTrie = Array(TOTAL_LETTERS);
    
        for (const item of list) {
            let current = trie;
    Severity: Minor
    Found in src/arr-trie.ts - 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 treatOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function treatOptions<TValue>(
        options: IteratingOptions<TValue>,
        trie: Trie<TValue>,
    ) {
        const [prefixes, count] = getPrefixTrie(options.prefixes, trie);
    Severity: Minor
    Found in src/iterate-trie-values.ts - 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