cibernox/ember-power-select

View on GitHub
ember-power-select/src/utils/group-utils.ts

Summary

Maintainability
F
5 days
Test Coverage

File group-utils.ts has 1083 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isEqual } from '@ember/utils';

export type MatcherFn = (option: any, text: string) => number;
export function isGroup(entry: any): boolean {
  return !!entry && !!entry.groupName && !!entry.options;
Severity: Major
Found in ember-power-select/src/utils/group-utils.ts - About 2 days to fix

    Function findOptionWithOffset has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    export function findOptionWithOffset(
      options: any,
      text: string,
      matcher: MatcherFn,
      offset: number,
    Severity: Minor
    Found in ember-power-select/src/utils/group-utils.ts - About 5 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 optionAtIndex has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export function optionAtIndex(
      originalCollection: any,
      index: number,
    ): { disabled: boolean; option: any } {
      let counter = 0;
    Severity: Minor
    Found in ember-power-select/src/utils/group-utils.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 indexOfOption has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    export function indexOfOption(collection: any, option: any): number {
      let index = 0;
      return (function walk(collection): number {
        if (!collection) {
          return -1;
    Severity: Minor
    Found in ember-power-select/src/utils/group-utils.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 pathForOption has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export function pathForOption(collection: any, option: any): string {
      return (function walk(collection): string {
        if (!collection) {
          return '';
        }
    Severity: Minor
    Found in ember-power-select/src/utils/group-utils.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 filterOptions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    export function filterOptions(
      options: any,
      text: string,
      matcher: MatcherFn,
      skipDisabled = false,
    Severity: Minor
    Found in ember-power-select/src/utils/group-utils.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 optionAtIndex has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function optionAtIndex(
      originalCollection: any,
      index: number,
    ): { disabled: boolean; option: any } {
      let counter = 0;
    Severity: Minor
    Found in ember-power-select/src/utils/group-utils.ts - About 1 hr to fix

      Function findOptionWithOffset has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function findOptionWithOffset(
        options: any,
        text: string,
        matcher: MatcherFn,
        offset: number,
      Severity: Minor
      Found in ember-power-select/src/utils/group-utils.ts - About 1 hr to fix

        Function countOptions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export function countOptions(collection: any): number {
          let counter = 0;
          (function walk(collection): void {
            if (!collection) {
              return;
        Severity: Minor
        Found in ember-power-select/src/utils/group-utils.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 walk has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            (function walk(
              collection,
              ancestorIsDisabled,
            ): { disabled: boolean; option: any } | void {
              if (!collection || index < 0) {
        Severity: Minor
        Found in ember-power-select/src/utils/group-utils.ts - About 1 hr to fix

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

            (function walk(options: any, ancestorIsDisabled: boolean): any {
              const length = options.length;
          
              for (let i = 0; i < length; i++) {
                const entry = options.objectAt ? options.objectAt(i) : options[i];
          Severity: Minor
          Found in ember-power-select/src/utils/group-utils.ts - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (counter < offset) {
                        if (!foundBeforeOffset) {
                          foundBeforeOffset = entry;
                        }
                      } else {
            Severity: Major
            Found in ember-power-select/src/utils/group-utils.ts - About 45 mins to fix

              Function findOptionWithOffset has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                options: any,
                text: string,
                matcher: MatcherFn,
                offset: number,
                skipDisabled = false,
              Severity: Minor
              Found in ember-power-select/src/utils/group-utils.ts - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status