NaturalCycles/js-lib

View on GitHub

Showing 25 of 83 total issues

Function _Memo has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
Open

  (opt: MemoOptions = {}): MethodDecorator =>
  (target, key, descriptor) => {
    if (typeof descriptor.value !== 'function') {
      throw new TypeError('Memoization can be applied only to methods')
    }
Severity: Minor
Found in src/decorators/memo.decorator.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 logFinished has 7 arguments (exceeds 5 allowed). Consider refactoring.
Open

  logger: CommonLogger,
  callSignature: string,
  started: number,
  sma?: SimpleMovingAverage,
  logResultFn?: LogResultFn,
Severity: Major
Found in src/decorators/logMethod.decorator.ts - About 45 mins to fix

    Function setComponents has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
    Open

      setComponents(c: Partial<LocalTimeComponents>, mutate = false): LocalTime {
        const d = mutate ? this.$date : new Date(this.$date)
    
        // Year, month and day set all-at-once, to avoid 30/31 (and 28/29) mishap
        if (c.day || c.month !== undefined || c.year !== undefined) {
    Severity: Minor
    Found in src/datetime/localTime.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 _count has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
    Open

    export function _count<T>(
      items: Iterable<T>,
      predicate: AbortablePredicate<T>,
      limit?: number,
    ): number {
    Severity: Minor
    Found in src/array/array.util.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 mergeTypes has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
    Open

    function mergeTypes(types: Type[], samples: any[]): JsonSchema | undefined {
      // skip "undefined" types
      types = types.filter(t => t !== 'undefined')
    
      if (!types.length) return undefined
    Severity: Minor
    Found in src/json-schema/from-data/generateJsonSchemaFromData.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

    Severity
    Category
    Status
    Source
    Language