swimlane/ngx-datatable

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

Summary

Maintainability
D
2 days
Test Coverage

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

import {
  Component,
  Input,
  Output,
  ElementRef,

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

    @Component({
      selector: 'ngx-datatable',
      templateUrl: './datatable.component.html',
      changeDetection: ChangeDetectionStrategy.OnPush,
      encapsulation: ViewEncapsulation.None,

      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 => {
            return { ...c };
          });
      
      

      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 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        onColumnReorder({ column, newValue, prevValue }: any): void {
          const cols = this._internalColumns.map(c => {
            return { ...c };
          });
      
      

        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) {

        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;

          Function onHeaderSelect has a Cognitive Complexity of 6 (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;

          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