siemens/ngx-datatable

View on GitHub
projects/ngx-datatable/src/lib/components/datatable.component.ts

Summary

Maintainability
F
3 days
Test Coverage

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

import {
  AfterContentInit,
  AfterViewInit,
  ChangeDetectionStrategy,
  ChangeDetectorRef,
Severity: Major
Found in projects/ngx-datatable/src/lib/components/datatable.component.ts - About 1 day to fix

    DatatableComponent has 58 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'ngx-datatable',
      templateUrl: './datatable.component.html',
      changeDetection: ChangeDetectionStrategy.OnPush,
      // eslint-disable-next-line @angular-eslint/use-component-view-encapsulation
    Severity: Major
    Found in projects/ngx-datatable/src/lib/components/datatable.component.ts - About 1 day to fix

      Function recalculateColumns has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        recalculateColumns(
          columns: any[] = this._internalColumns,
          forceIdx: number = -1,
          allowBleed: boolean = this.scrollbarH
        ): any[] | undefined {
      Severity: Minor
      Found in projects/ngx-datatable/src/lib/components/datatable.component.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 onColumnReorder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        onColumnReorder({ column, newValue, prevValue }: any): void {
          const cols = this._internalColumns.map(c => ({ ...c }));
      
          if (this.swapColumns) {
            const prevCol = cols[newValue];
      Severity: Minor
      Found in projects/ngx-datatable/src/lib/components/datatable.component.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 onColumnReorder has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        onColumnReorder({ column, newValue, prevValue }: any): void {
          const cols = this._internalColumns.map(c => ({ ...c }));
      
          if (this.swapColumns) {
            const prevCol = cols[newValue];
      Severity: Minor
      Found in projects/ngx-datatable/src/lib/components/datatable.component.ts - About 1 hr to fix

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

          onHeaderSelect(event: any): void {
            if (this.bodyComponent && this.selectAllRowsOnPage) {
              // before we splice, chk if we currently have all selected
              const first = this.bodyComponent.indexes.first;
              const last = this.bodyComponent.indexes.last;
        Severity: Minor
        Found in projects/ngx-datatable/src/lib/components/datatable.component.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

        Function calcRowCount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          calcRowCount(val: any[] = this.rows): number {
            if (!this.externalPaging) {
              if (!val) {return 0;}
        
              if (this.groupedRows) {
        Severity: Minor
        Found in projects/ngx-datatable/src/lib/components/datatable.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

        Avoid too many return statements within this function.
        Open

            return this.count;
        Severity: Major
        Found in projects/ngx-datatable/src/lib/components/datatable.component.ts - About 30 mins to fix

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

            translateColumns(val: any) {
              if (val) {
                const arr = val.toArray();
                if (arr.length) {
                  this._internalColumns = translateTemplates(arr);
          Severity: Minor
          Found in projects/ngx-datatable/src/lib/components/datatable.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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor(
              @SkipSelf() private scrollbarHelper: ScrollbarHelper,
              @SkipSelf() private dimensionsHelper: DimensionsHelper,
              private cd: ChangeDetectorRef,
              element: ElementRef,
          Severity: Minor
          Found in projects/ngx-datatable/src/lib/components/datatable.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