mseemann/angular2-mdl

View on GitHub
projects/select/src/lib/select.component.ts

Summary

Maintainability
C
1 day
Test Coverage

File select.component.ts has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  AfterContentInit,
  AfterViewInit,
  ChangeDetectorRef,
  Component,
Severity: Minor
Found in projects/select/src/lib/select.component.ts - About 5 hrs to fix

    MdlSelectComponent has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: "mdl-select",
      templateUrl: "select.component.html",
      encapsulation: ViewEncapsulation.None,
      providers: [MDL_SELECT_VALUE_ACCESSOR],
    Severity: Minor
    Found in projects/select/src/lib/select.component.ts - About 4 hrs to fix

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

        public writeValue(value: string | string[] | undefined): void {
          if (this.multiple) {
            this.model = this.model || [];
            if (!value || this.model === value) {
              // skip ngModel update when undefined value or multiple selects initialized with same array
      Severity: Minor
      Found in projects/select/src/lib/select.component.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 renderValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        private renderValue(value: string | string[] | undefined) {
          if (this.multiple) {
            this.text = ((value as string[]) || [])
              .map((valueItem: string) => this.textByValue[stringifyValue(valueItem)])
              .join(", ");
      Severity: Minor
      Found in projects/select/src/lib/select.component.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 onArrow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        private onArrow($event: KeyboardEvent, offset: number) {
          const arr = this.optionComponents
            ?.toArray()
            .filter(({ disabled }) => !disabled);
          if (!arr) {
      Severity: Minor
      Found in projects/select/src/lib/select.component.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

      Function onKeyDown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        @HostListener("keydown", ["$event"])
        public onKeyDown($event: KeyboardEvent): void {
          if (!this.disabled && this.popoverComponent?.isVisible && !this.multiple) {
            if (isKey($event, KEYS.upArrow)) {
              this.onArrow($event, -1);
      Severity: Minor
      Found in projects/select/src/lib/select.component.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

      There are no issues that match your filters.

      Category
      Status