siemens/ngx-datatable

View on GitHub

Showing 89 of 89 total issues

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

  checkValueUpdates(): void {
    let value = '';

    if (!this.row || !this.column) {
      value = '';

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

  focusCell(cellElement: any, rowElement: any, keyCode: number, cellIndex: number): void {
    let nextCellElement: HTMLElement;

    if (keyCode === Keys.left) {
      nextCellElement = cellElement.previousElementSibling;

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 onActivate has a Cognitive Complexity of 10 (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 exports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
Severity: Minor
Found in karma.conf.js - About 1 hr to fix

    Function cssClass has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @HostBinding('class')
      get cssClass() {
        let cls = 'datatable-body-row';
        if (this.isSelected) {
          cls += ' active';

      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 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);
        Severity: Minor
        Found in projects/ngx-datatable/src/lib/components/body/body.component.ts - About 1 hr to fix

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

              onKeyboardFocus(model: Model): void {
                const { keyCode } = model.event as KeyboardEvent;
                const shouldFocus = keyCode === Keys.up || keyCode === Keys.down || keyCode === Keys.right || keyCode === Keys.left;
            
                if (shouldFocus) {
            Severity: Minor
            Found in projects/ngx-datatable/src/lib/components/body/selection.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 offset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              @Input() set offset(val: number) {
                if (val !== this._offset) {
                  this._offset = val;
                  if (!this.scrollbarV || (this.scrollbarV && !this.virtualization)) {
                    if (!isNaN(this._offset) && this.ghostLoadingIndicator) {
            Severity: Minor
            Found in projects/ngx-datatable/src/lib/components/body/body.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 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/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

            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;
            Severity: Minor
            Found in projects/ngx-datatable/src/lib/components/header/header.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 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

            Avoid deeply nested control flow statements.
            Open

                        if (res[k] === true) {
                          cls += ` ${k}`;
                        }
            Severity: Major
            Found in projects/ngx-datatable/src/lib/components/body/body-cell.component.ts - About 45 mins to fix

              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 = [];
              Severity: Minor
              Found in projects/ngx-datatable/src/lib/components/header/header.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

              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

                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

                  Avoid deeply nested control flow statements.
                  Open

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

                    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/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

                    Severity
                    Category
                    Status
                    Source
                    Language