File datatable.component.ts
has 634 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
AfterContentInit,
AfterViewInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
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
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 {
- Read upRead up
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];
- Read upRead up
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];
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;
- Read upRead up
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) {
- Read upRead up
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 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);
- Read upRead up
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,
- Read upRead up
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"