src/filters.js
Function exports
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function (service) {
return {
filter: filter,
filterAll: filterAll,
applyFilters: applyFilters,
- 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 exports
has 299 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function (service) {
return {
filter: filter,
filterAll: filterAll,
applyFilters: applyFilters,
File filters.js
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict'
var _ = require('./lodash')
var expressions = require('./expressions')
Function makeFunction
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function makeFunction(obj, isAggregation) {
var subGetters
// Detect raw $data reference
if (_.isString(obj)) {
Function applyFilters
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function applyFilters(newFilters) {
var ds = _.map(newFilters, function (fil, i) {
var existing = service.filters[i]
// Filters are the same, so no change is needed on this column
if (fil === existing) {
Function buildFilterObject
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function buildFilterObject(fil, isRange, replace) {
if (_.isUndefined(fil)) {
return false
}
if (_.isFunction(fil)) {
Function ds
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var ds = _.map(newFilters, function (fil, i) {
var existing = service.filters[i]
// Filters are the same, so no change is needed on this column
if (fil === existing) {
return Promise.resolve()
Avoid too many return
statements within this function. Open
Open
return Promise.resolve(column.dimension.filterAll())
Avoid too many return
statements within this function. Open
Open
return function (d) {
return expressions.$and(d, function (d) {
return _.map(subGetters, function (getSub) {
return getSub(d)
})
Avoid too many return
statements within this function. Open
Open
return false
Avoid too many return
statements within this function. Open
Open
return {
value: fil,
replace: replace,
type: 'exact',
}
Avoid too many return
statements within this function. Open
Open
return Promise.resolve(column.dimension.filterFunction(function (d) {
return fil.value.indexOf(d) > -1
}))
Avoid too many return
statements within this function. Open
Open
return Promise.resolve(column.dimension.filterFunction(fil.function))
Avoid too many return
statements within this function. Open
Open
return function (d) {
return _.map(subGetters, function (getSub) {
return getSub(d)
})
}