swimlane/angular2-data-table

View on GitHub

Showing 79 of 79 total issues

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

  ngOnInit(): void {
    if (this.rowDetail) {
      this.listener = this.rowDetail.toggle.subscribe(({ type, value }: { type: string; value: any }) => {
        if (type === 'row') {
          this.toggleRowExpansion(value);

    Consider simplifying this complex logical expression.
    Open

        if (
          group.filter(rowFilter => rowFilter.exppaypending === 1).length === 0 &&
          group.filter(rowFilter => rowFilter.exppaypending === 0 && rowFilter.exppayyes === 0 && rowFilter.exppayno === 0)
            .length === 0
        ) {
    Severity: Major
    Found in src/app/basic/row-grouping.component.ts - About 1 hr to fix

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

      export function nextSortDir(sortType: SortType, current: SortDirection): SortDirection | undefined {
        if (sortType === SortType.single) {
          if (current === SortDirection.asc) {
            return SortDirection.desc;
          } else {
      Severity: Minor
      Found in projects/swimlane/ngx-datatable/src/lib/utils/sort.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 onTargetChanged has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        onTargetChanged({ prevIndex, newIndex, initialIndex }: any): void {
          if (prevIndex || prevIndex === 0) {
            const oldColumn = this.getColumn(prevIndex);
            oldColumn.isTarget = false;
            oldColumn.targetMarkerContext = undefined;

      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 deepValueGetter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export function deepValueGetter(obj: any, path: string): any {
        if (obj == null) {
          return '';
        }
        if (!obj || !path) {
      Severity: Minor
      Found in projects/swimlane/ngx-datatable/src/lib/utils/column-prop-getters.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

      Avoid deeply nested control flow statements.
      Open

                if (column.minWidth !== undefined && newWidth < column.minWidth) {
                  remainingWidth += newWidth - column.minWidth;
                  column.width = column.minWidth;
                  hasMinWidth[column.prop] = true;
                } else {
      Severity: Major
      Found in projects/swimlane/ngx-datatable/src/lib/utils/math.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (res[k] === true) cls += ` ${k}`;

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

            onActivate(model: Model, index: number): void {
              const { type, event, row } = model;
              const chkbox = this.selectionType === SelectionType.checkbox;
              const select = (!chkbox && (type === 'click' || type === 'dblclick')) || (chkbox && type === 'checkbox');
          
          

          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 columnsByPin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export function columnsByPin(cols: any[]) {
            const ret: { left: any; center: any; right: any } = {
              left: [],
              center: [],
              right: []
          Severity: Minor
          Found in projects/swimlane/ngx-datatable/src/lib/utils/column.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 (res[k] === true) {
                        cls += ` ${k}`;
                      }

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

              calcNewSorts(column: any, prevValue: number, newValue: number): any[] {
                let idx = 0;
            
                if (!this.sorts) {
                  this.sorts = [];

            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 (group[index].source !== row.source) {
                          if (event.target.value === '0') {
                            // expected payment yes selected
                            group[index].exppayyes = 0;
                            group[index].exppaypending = 0;
            Severity: Major
            Found in src/app/basic/row-grouping.component.ts - About 45 mins to fix

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

                refreshRowHeightCache(): void {
                  if (!this.scrollbarV || (this.scrollbarV && !this.virtualization)) {
                    return;
                  }
              
              

              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 (group[index].exppayyes === 0 && group[index].exppayno === 0 && group[index].exppaypending === 0) {
                            expectedPaymentDealtWith = false;
                          }
              Severity: Major
              Found in src/app/basic/row-grouping.component.ts - About 45 mins to fix

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

                function toHaveText(): jasmine.CustomMatcher {
                  return {
                    compare(actual: any, expectedText: string, expectationFailOutput?: any): jasmine.CustomMatcherResult {
                      const actualText = elementText(actual);
                      const pass = actualText.indexOf(expectedText) > -1;
                Severity: Minor
                Found in projects/swimlane/ngx-datatable/src/lib/test/jasmine-matchers.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 getRowsStyles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  getRowsStyles(rows: any): any {
                    const styles: any = {};
                
                    // only add styles for the group if there is a group
                    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

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

                  allColumns: any[],
                  expectedWidth: number,
                  startIdx: number,
                  allowBleed: boolean,
                  defaultColWidth: number = 300
                Severity: Minor
                Found in projects/swimlane/ngx-datatable/src/lib/utils/math.ts - About 35 mins to fix

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

                    selected: any[],
                    rows: any[],
                    index: number,
                    prevIndex: number,
                    comparefn: any
                  Severity: Minor
                  Found in projects/swimlane/ngx-datatable/src/lib/utils/selection.ts - About 35 mins to fix

                    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

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

                    export function sortRows(rows: any[], columns: any[], dirs: SortPropDir[]): any[] {
                      if (!rows) return [];
                      if (!dirs || !dirs.length || !columns) return [...rows];
                    
                      /**
                    Severity: Minor
                    Found in projects/swimlane/ngx-datatable/src/lib/utils/sort.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

                    Severity
                    Category
                    Status
                    Source
                    Language