siemens/ngx-datatable

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

Summary

Maintainability
B
6 hrs
Test Coverage

Function selectRow has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  selectRow(event: KeyboardEvent | MouseEvent, index: number, row: any): void {
    if (!this.selectEnabled) {return;}

    const chkbox = this.selectionType === SelectionType.checkbox;
    const multi = this.selectionType === SelectionType.multi;

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

  selectRow(event: KeyboardEvent | MouseEvent, index: number, row: any): void {
    if (!this.selectEnabled) {return;}

    const chkbox = this.selectionType === SelectionType.checkbox;
    const multi = this.selectionType === SelectionType.multi;

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

      getPrevNextRow(rowElement: any, keyCode: number): any {
        const parentElement = rowElement.parentElement;
    
        if (parentElement) {
          let focusElement: HTMLElement;
    Severity: Minor
    Found in projects/ngx-datatable/src/lib/components/body/selection.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

    There are no issues that match your filters.

    Category
    Status