cibernox/ember-power-select

View on GitHub

Showing 89 of 89 total issues

Function handleKeydown has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  @action
  handleKeydown(select: Select, e: KeyboardEvent): false | void {
    if (this.args.onKeydown && this.args.onKeydown(select, e) === false) {
      e.stopPropagation();
      return false;
Severity: Minor
Found in ember-power-select/src/components/power-select-multiple.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

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

      export default function (config) {
        let finalConfig = {
          ...config,
          models: {
            ...discoverEmberDataModels(config.store),
      Severity: Major
      Found in docs/mirage/config.js and 1 other location - About 1 hr to fix
      test-app/mirage/config.js on lines 4..15

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

      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

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

        async searchRepo(term) {
          let url = `https://api.github.com/search/repositories?q=${term}`;
      
          const response = await fetch(url);
          const json = await response.json();
      Severity: Major
      Found in docs/app/components/snippets/custom-search-action-1.js and 1 other location - About 1 hr to fix
      docs/app/controllers/public-pages/docs/custom-search-action.js on lines 10..17

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

      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

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

        async searchRepo(term) {
          let url = `https://api.github.com/search/repositories?q=${term}`;
      
          const response = await fetch(url);
          const json = await response.json();
      docs/app/components/snippets/custom-search-action-1.js on lines 4..11

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

      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

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

      export default function (config) {
        let finalConfig = {
          ...config,
          models: {
            ...discoverEmberDataModels(config.store),
      Severity: Major
      Found in test-app/mirage/config.js and 1 other location - About 1 hr to fix
      docs/mirage/config.js on lines 4..15

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

      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

      Function getDropdownItems has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function getDropdownItems(cssPathOrTrigger: string | HTMLElement) {
        let trigger: HTMLElement | null = null;
      
        if (cssPathOrTrigger instanceof HTMLElement) {
          if (cssPathOrTrigger.classList.contains('ember-power-select-trigger')) {
      Severity: Minor
      Found in ember-power-select/src/test-support.ts - About 1 hr to fix

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

        export default class UserModel extends Model {
          @attr('string') name;
          @attr('number') age;
          @hasMany('pet', { async: true, inverse: 'owner' }) pets;
        }
        Severity: Major
        Found in test-app/app/models/user.js and 3 other locations - About 1 hr to fix
        docs/app/models/pet.js on lines 3..7
        docs/app/models/user.js on lines 3..7
        test-app/app/models/pet.js on lines 3..7

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

        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 4 locations. Consider refactoring.
        Open

        export default class PetModel extends Model {
          @attr('string') name;
          @attr('number') age;
          @belongsTo('user', { async: true, inverse: 'pets' }) owner;
        }
        Severity: Major
        Found in docs/app/models/pet.js and 3 other locations - About 1 hr to fix
        docs/app/models/user.js on lines 3..7
        test-app/app/models/pet.js on lines 3..7
        test-app/app/models/user.js on lines 3..7

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

        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 4 locations. Consider refactoring.
        Open

        export default class UserModel extends Model {
          @attr('string') name;
          @attr('number') age;
          @hasMany('pet', { async: true, inverse: 'owner' }) pets;
        }
        Severity: Major
        Found in docs/app/models/user.js and 3 other locations - About 1 hr to fix
        docs/app/models/pet.js on lines 3..7
        test-app/app/models/pet.js on lines 3..7
        test-app/app/models/user.js on lines 3..7

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

        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 4 locations. Consider refactoring.
        Open

        export default class PetModel extends Model {
          @attr('string') name;
          @attr('number') age;
          @belongsTo('user', { async: true, inverse: 'pets' }) owner;
        }
        Severity: Major
        Found in test-app/app/models/pet.js and 3 other locations - About 1 hr to fix
        docs/app/models/pet.js on lines 3..7
        docs/app/models/user.js on lines 3..7
        test-app/app/models/user.js on lines 3..7

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

        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

        Function emberPowerSelectIsEqual has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function emberPowerSelectIsEqual(
          [option, selected]: [any, any] /* , hash*/,
        ): boolean {
          if (selected === undefined || selected === null) {
            return false;
        Severity: Minor
        Found in ember-power-select/src/helpers/ember-power-select-is-equal.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

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

            this.mouseUpHandler = ((e: MouseEvent): void =>
              findOptionAndPerform(
                this.args.select.actions.choose,
                e,
              )) as EventListener;
        Severity: Minor
        Found in ember-power-select/src/components/power-select/options.ts and 1 other location - About 50 mins to fix
        ember-power-select/src/components/power-select/options.ts on lines 200..204

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

        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

              this.mouseOverHandler = ((e: MouseEvent): void =>
                findOptionAndPerform(
                  this.args.select.actions.highlight,
                  e,
                )) as EventListener;
        Severity: Minor
        Found in ember-power-select/src/components/power-select/options.ts and 1 other location - About 50 mins to fix
        ember-power-select/src/components/power-select/options.ts on lines 193..197

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

        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

        Function getDropdownItems has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function getDropdownItems(cssPathOrTrigger: string | HTMLElement) {
          let trigger: HTMLElement | null = null;
        
          if (cssPathOrTrigger instanceof HTMLElement) {
            if (cssPathOrTrigger.classList.contains('ember-power-select-trigger')) {
        Severity: Minor
        Found in ember-power-select/src/test-support.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

        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

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

          export default Factory.extend({
            name(i) {
              return `Pet ${i}`;
            },
          
          
          Severity: Major
          Found in test-app/mirage/factories/pet.js and 3 other locations - About 40 mins to fix
          docs/mirage/factories/pet.js on lines 3..11
          docs/mirage/factories/user.js on lines 3..11
          test-app/mirage/factories/user.js on lines 3..11

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

          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

            let potentialTargets = Array.from(options).filter(
              (opt) => (opt.textContent ?? '').indexOf(valueOrSelector) > -1,
            );
          Severity: Minor
          Found in ember-power-select/src/test-support.ts and 1 other location - About 40 mins to fix
          ember-power-select/src/test-support.ts on lines 149..151

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

          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

            const item = Array.from(items).find(
              (el) => (el.textContent ?? '').indexOf(value) > -1,
            );
          Severity: Minor
          Found in ember-power-select/src/test-support.ts and 1 other location - About 40 mins to fix
          ember-power-select/src/test-support.ts on lines 56..58

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

          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

          Severity
          Category
          Status
          Source
          Language