eloqjs/collection

View on GitHub

Showing 7 of 8 total issues

Function getValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function getValue(holder: Record<Key, unknown>, propParts: Key[]): unknown {
  let result: unknown = holder

  while (propParts.length && (isObject(result) || isArray(result))) {
    const propPart = propParts.shift() as Key
Severity: Minor
Found in src/helpers/getProp.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 resolveLikeOperation has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function resolveLikeOperation(value: string): RegExp {
  switch (true) {
    case value.startsWith('%') && value.endsWith('%'): {
      const _value = extractValue('%(.*)%', value, 1)
      return new RegExp(`^.*${_value}.*$`, 'i')
Severity: Minor
Found in src/helpers/where.ts - About 1 hr to fix

    Function compareValues has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function compareValues(
      property: unknown,
      value: unknown,
      operator: Operator
    ): boolean {
    Severity: Minor
    Found in src/helpers/where.ts - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

            return new RegExp(`^${_value}.*$`, 'i')
      Severity: Major
      Found in src/helpers/where.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return new RegExp(`^.*${_value}$`, 'i')
        Severity: Major
        Found in src/helpers/where.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return new RegExp(`^${start}.*${end}$`, 'i')
          Severity: Major
          Found in src/helpers/where.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return new RegExp(`^.*${value}.*$`, 'i')
            Severity: Major
            Found in src/helpers/where.ts - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language