Reduce complexity by extracting validation to a function
This commit is contained in:
parent
f0c82f21d2
commit
fecedfdc68
@ -7,7 +7,7 @@ const AggregationMapConfig = require('../models/aggregation/aggregation-mapconfi
|
||||
|
||||
module.exports = class ClusterBackend {
|
||||
// TODO: reduce complexity
|
||||
// jshint maxcomplexity: 16
|
||||
// jshint maxcomplexity: 15
|
||||
getClusterFeatures (mapConfigProvider, params, callback) {
|
||||
mapConfigProvider.getMapConfig((err, _mapConfig) => {
|
||||
if (err) {
|
||||
@ -61,7 +61,7 @@ module.exports = class ClusterBackend {
|
||||
|
||||
const { columns, expressions } = aggregation;
|
||||
|
||||
if (!Array.isArray(columns) || !columns.length) {
|
||||
if (!hasColumns(columns)) {
|
||||
const error = new Error(
|
||||
`Invalid aggregation input, columns should be and array of column names`
|
||||
);
|
||||
@ -261,3 +261,7 @@ function hasAggregationLayer (mapConfig, layerIndex) {
|
||||
|
||||
return mapConfig.isAggregationLayer(layerIndex);
|
||||
}
|
||||
|
||||
function hasColumns (columns) {
|
||||
return Array.isArray(columns) && columns.length;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user