TypedStructures/typed-structures

View on GitHub

Showing 23 of 23 total issues

Map has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

export class Map<K, V> implements IMap<K, V> {

    private _entries: IMapEntry<K, V>[];

    constructor() {
Severity: Minor
Found in src/collections/map/map.ts - About 2 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        @TsQ()
        public toArray(): T[] {
            let res: T[] = [];
            this.forEach((item: Node<T>) => res.push(item.data));
            return res;
    src/collections/linked-list/singly-linked-list/singly-linked-list.ts on lines 205..210

    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 81.

    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

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        @TsQ()
        public toArray(): T[] {
            let res: T[] = [];
            this.forEach((item: Node<T>) => res.push(item.data));
            return res;
    src/collections/linked-list/doubly-linked-list/doubly-linked-list.ts on lines 209..214

    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 81.

    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

    Further Reading

    Function remove has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public remove(parent: BNode<T>, item: T): boolean {
            if (item < this.data) {
                if (this._left !== undefined)
                    return this._left.remove(this, item);
                else
    Severity: Minor
    Found in src/collections/binary-tree/utils/node/b-node.ts - 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 exports has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function(config) {
        config.set({
            basePath: '.',
            frameworks: ['jasmine', 'karma-typescript'],
            files: [
    Severity: Minor
    Found in karma.config.js - About 1 hr to fix

      Function replace has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          replace(key: K, value: V, newValue?: V): any {
              if (newValue)
                  if (this.containsKey(key) && this.get(key) === value) {
                      this.put(key, newValue);
                      return true;
      Severity: Minor
      Found in src/collections/map/map.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 orderBy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function orderBy(from: any, orderby: Stack<OrderClause>) {
      
          while (!orderby.empty()) {
              let c: OrderClause = orderby.unstack();
              from = from.sort((a: any, b: any) => {
      Severity: Minor
      Found in src/tsQ/order-by/order-by.ts - About 1 hr to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            public forEach(callback: Function) {
                let current = this._head;
                let index = 0;
                while (current) {
                    callback.call(current, current, index++, this);
        src/collections/linked-list/singly-linked-list/singly-linked-list.ts on lines 58..65

        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 56.

        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

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            forEach(callback: Function): void {
                let current = this._head;
                let index = 0;
                while (current) {
                    callback.call(current, current, index++, this);
        src/collections/linked-list/doubly-linked-list/doubly-linked-list.ts on lines 129..136

        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 56.

        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

        Further Reading

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

            public add(item: T): boolean {
                if (item < this.data) {
                    if(this._left === undefined) {
                        this._left = new BNode<T>(item);
                        return true;
        Severity: Minor
        Found in src/collections/binary-tree/utils/node/b-node.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 remove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            remove(key: K, value?: V): any {
                if (value)
                    if (this.containsKey(key) && this.get(key) === value) {
                        this.remove(key);
                        return true;
        Severity: Minor
        Found in src/collections/map/map.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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            find(root: BNode<T>, item: T): T {
                if (root === undefined) {
                    return undefined;
                } else {
                    if (item < root.data) {
        Severity: Minor
        Found in src/collections/binary-tree/bts/binary-tree-search.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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                else if (this.length() === 1) {
                    let current = this._head;
                    this._head = this._tail = undefined;
                    --this._size;
                    return current.data;
        src/collections/linked-list/doubly-linked-list/doubly-linked-list.ts on lines 82..94

        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 50.

        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

        Further Reading

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

            remove(item: T): T {
                if (this.empty())
                    return undefined;
        
                else if (this.length() === 1) {
        Severity: Minor
        Found in src/collections/linked-list/singly-linked-list/singly-linked-list.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 remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public remove(item: T): T {
                if (this.empty())
                    return undefined;
        
                else if (this.length() === 1) {
        Severity: Minor
        Found in src/collections/linked-list/doubly-linked-list/doubly-linked-list.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 compute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            compute(key: K, remappingFunction: IBiFunction<K, V, V>): V {
        
                let oldValue: V = this.get(key);
                let newValue: V = remappingFunction.apply(key, oldValue);
                if (oldValue !== null) {
        Severity: Minor
        Found in src/collections/map/map.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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if (this.length() === 1) {
                    let current = this._head;
                    this._head = this._tail = undefined;
                    --this._size;
                    return current.data;
        src/collections/linked-list/doubly-linked-list/doubly-linked-list.ts on lines 102..126

        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 50.

        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

        Further Reading

        Function getObjectMap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getObjectMap(o: object, path: string) {
        
            let res: Map<string, number | string> = new Map<string, number | string>();
        
            if (o) {
        Severity: Minor
        Found in src/tsQ/util/reflect.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

        Avoid too many return statements within this function.
        Open

                    return true;
        Severity: Major
        Found in src/collections/binary-tree/utils/node/b-node.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return false;
          Severity: Major
          Found in src/collections/binary-tree/utils/node/b-node.ts - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language