Linqable/lib

View on GitHub
src/Base/BaseLinqable.ts

Summary

Maintainability
F
1 wk
Test Coverage

BaseLinqable has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

export class BaseLinqable<T> extends Behaviour<T> {
    /**
     * Returns the only element of a sequence,
     * and throws an exception if there is not exactly one element in the sequence.
     * @throws {InvalidOperationError} The input sequence is empty. || The input sequence contains more than one element.
Severity: Minor
Found in src/Base/BaseLinqable.ts - About 3 hrs to fix

    File BaseLinqable.ts has 288 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import aggregate, { aggregateDelegate } from '../core/aggregate';
    import { InvalidOperationError } from "../error";
    import { LinqArrayIterable } from "./iterable";
    import { Behaviour } from './behaviour';
    import where from '../core/where';
    Severity: Minor
    Found in src/Base/BaseLinqable.ts - About 2 hrs to fix

      Function Except has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public Except(arr: Array<T> | number, comparer?: (x: T, y: T) => boolean) {
              let array: Array<T>;
              let element: T = null;
              comparer = comparer || this.EqualityComparer;
              if (!(arr instanceof Array))
      Severity: Minor
      Found in src/Base/BaseLinqable.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 Except has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public Except(arr: Array<T> | number, comparer?: (x: T, y: T) => boolean) {
              let array: Array<T>;
              let element: T = null;
              comparer = comparer || this.EqualityComparer;
              if (!(arr instanceof Array))
      Severity: Minor
      Found in src/Base/BaseLinqable.ts - About 1 hr to fix

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

            public Min(selector?: (element: T) => number): number {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    return 0;
        Severity: Minor
        Found in src/Base/BaseLinqable.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 MinBy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public MinBy(selector: (element: T) => number): T {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    throw new InvalidOperationError("Array Is Empty.");
        Severity: Minor
        Found in src/Base/BaseLinqable.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 MaxBy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public MaxBy(selector: (element: T) => number): T {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    throw new InvalidOperationError("Array Is Empty.");
        Severity: Minor
        Found in src/Base/BaseLinqable.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 Max has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public Max(selector?: (element: T) => number): number {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    return 0;
        Severity: Minor
        Found in src/Base/BaseLinqable.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

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

            public MinBy(selector: (element: T) => number): T {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    throw new InvalidOperationError("Array Is Empty.");
        Severity: Major
        Found in src/Base/BaseLinqable.ts and 1 other location - About 1 day to fix
        src/Base/BaseLinqable.ts on lines 134..150

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

        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

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

            public MaxBy(selector: (element: T) => number): T {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    throw new InvalidOperationError("Array Is Empty.");
        Severity: Major
        Found in src/Base/BaseLinqable.ts and 1 other location - About 1 day to fix
        src/Base/BaseLinqable.ts on lines 151..167

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

        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

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

            public Min(selector?: (element: T) => number): number {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    return 0;
        Severity: Major
        Found in src/Base/BaseLinqable.ts and 1 other location - About 1 day to fix
        src/Base/BaseLinqable.ts on lines 108..120

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

        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

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

            public Max(selector?: (element: T) => number): number {
                this.checkArray();
                var l = this.array.length;
                if (l == 0)
                    return 0;
        Severity: Major
        Found in src/Base/BaseLinqable.ts and 1 other location - About 1 day to fix
        src/Base/BaseLinqable.ts on lines 121..133

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

        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

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

            public LastOrDefault(predicate?: (element: T, index: number) => boolean, defaultValue?: T, context?: any): T {
                this.checkArray();
                try {
                    return this.Where(predicate, context).First(null, context);
                }
        Severity: Major
        Found in src/Base/BaseLinqable.ts and 1 other location - About 3 hrs to fix
        src/Base/BaseLinqable.ts on lines 226..234

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

        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

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

            public FirstOrDefault(predicate?: (element: T, index: number) => boolean, def?: T, context?: any): T {
                this.checkArray();
                try {
                    return this.Where(predicate, context).First(null, context);
                }
        Severity: Major
        Found in src/Base/BaseLinqable.ts and 1 other location - About 3 hrs to fix
        src/Base/BaseLinqable.ts on lines 199..207

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

        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

        There are no issues that match your filters.

        Category
        Status