jonshaffer/angular-data-table

View on GitHub
src/components/body/BodyController.js

Summary

Maintainability
F
3 days
Test Coverage

Showing 14 of 14 total issues

File BodyController.js has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isOldAngular } from '../../utils/utils';
 
const TREE_TYPES = {
GROUP: 'refreshGroups',
TREE: 'refreshTree',
Severity: Minor
Found in src/components/body/BodyController.js - About 5 hrs to fix

Function buildRowsByGroup has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

buildRowsByGroup() {
this.index = {};
this.rowsByGroup = {};
 
const parentProp = this.treeColumn ?
Severity: Minor
Found in src/components/body/BodyController.js - About 5 hrs to fix

Function rowsUpdated has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

rowsUpdated(newVal, oldVal) {
if (!newVal) {
this.getRows(true);
} else {
if (this.options.paging.mode !== 'external') {
Severity: Minor
Found in src/components/body/BodyController.js - About 3 hrs to fix

BodyController has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class BodyController {
/**
* A body controller
* @param {$scope}
* @return {BodyController}
Severity: Minor
Found in src/components/body/BodyController.js - About 3 hrs to fix

Function getRows has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

getRows(refresh) {
// only proceed when we have pre-aggregated the values
if ((this.treeColumn || this.groupColumn) && !this.rowsByGroup) {
return false;
}
Severity: Minor
Found in src/components/body/BodyController.js - About 2 hrs to fix

Function buildRowsByGroup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

buildRowsByGroup() {
this.index = {};
this.rowsByGroup = {};
 
const parentProp = this.treeColumn ?
Severity: Minor
Found in src/components/body/BodyController.js - About 1 hr to fix

Function getRows has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

getRows(refresh) {
// only proceed when we have pre-aggregated the values
if ((this.treeColumn || this.groupColumn) && !this.rowsByGroup) {
return false;
}
Severity: Minor
Found in src/components/body/BodyController.js - About 1 hr to fix

Function rowsUpdated has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

rowsUpdated(newVal, oldVal) {
if (!newVal) {
this.getRows(true);
} else {
if (this.options.paging.mode !== 'external') {
Severity: Minor
Found in src/components/body/BodyController.js - About 1 hr to fix

Function setConditionalWatches has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

setConditionalWatches() {
for (let i = this.watchListeners.length - 1; i >= 0; i -= 1) {
this.watchListeners[i]();
 
this.watchListeners.splice(i, 1);
Severity: Minor
Found in src/components/body/BodyController.js - About 1 hr to fix

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

calculateDepth(row, depth = 0) {
const parentProp = this.treeColumn ? this.treeColumn.relationProp : this.groupColumn.prop;
const prop = this.treeColumn.prop;
 
if (!row[parentProp]) {
Severity: Minor
Found in src/components/body/BodyController.js - About 55 mins to fix

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

buildTree() {
const temp = [];
const self = this;
 
const addChildren = (fromArray, toArray, level) => {
Severity: Minor
Found in src/components/body/BodyController.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

for (let j = 0; j < len; j += 1) {
if (this.rows[j][prop] === relVal) {
parent = this.rows[j];
break;
}
Severity: Major
Found in src/components/body/BodyController.js - About 45 mins to fix

Avoid too many return statements within this function.
Open

return depth;
Severity: Major
Found in src/components/body/BodyController.js - About 30 mins to fix

Similar blocks of code found in 3 locations. Consider refactoring.
Open

constructor($scope) {
Object.assign(this, {
$scope,
});
 
 
Severity: Major
Found in src/components/body/BodyController.js and 2 other locations - About 45 mins to fix
src/components/footer/FooterController.js on lines 11..19
src/components/footer/PagerController.js on lines 10..18

There are no issues that match your filters.

Category
Status