TypedStructures/typed-structures

View on GitHub

Showing 15 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

    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

        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

        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

        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

            Function hashCode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                hashCode(): number {
                    let key: string = typeof this._key === 'object' ? typeof (<any>this._key).hashCode === 'function' ? (<any>this._key).hashCode() : flattenObject(this._key) : this._key;
                    let value: string = typeof this._value === 'object' ? typeof (<any>this._value).hashCode === 'function' ? (<any>this._value).hashCode() : flattenObject(this._value) : this._value;
            
                    return hash( <string>key + <string>value);
            Severity: Minor
            Found in src/collections/map/utils/map-entry/map-entry.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