File datastorage.js
has 621 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as utils from "base/utils";
import Class from "base/class";
function _getQueryId(query, path, lastModified, readerName) {
Function framesQueue
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
framesQueue(framesArray, whatId) {
const _context = this;
return new function() {
this.defaultCallbacks = [];
this.callbacks = {};
Function queryQueue
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
queryQueue(readerObject, queryMergeId) {
const _context = this;
const _parsersCompare = function(readerParsers, queryParcers) {
return Object.keys(queryParcers).filter(p => queryParcers[p] !== readerParsers[p]).length == 0 &&
(Object.keys(readerParsers).length == 0 || Object.keys(queryParcers).length != 0);
Function _getFrames
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getFrames(dataId, whatId, framesArray, keys, indicatorsDB) {
const _this = this;
if (!_this._collection[dataId]["frames"][whatId]) {
_this._collection[dataId]["frames"][whatId] = {};
}
Function buildFrame
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildFrame = function(frameName, keys, dataId, callback) {
const frame = {};
if (query.from !== "datapoints") {
// we populate the regular set with a single value (unpack properties into constant time series)
const dataset = _this._collection[dataId].data;
Function reader
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.reader = function(query, parsers, defer) {
const _queue = this;
// && !(_queue.readerObject.compatibility || {}).aggregateValues
const _query = query.grouping ? utils.clone(query, null, ["grouping"]) : query;
return new function() {
Function aggregateData
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
aggregateData(dataId, query, readerObject, conceptProps) {
if (Object.keys(query.grouping).every(key => query.grouping[key]["grouping"] === 1)) {
return Promise.resolve(dataId);
}
Function _getLimits
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
_getLimits(dataId, attr) {
const items = this._collection[dataId].data;
// get only column attr and only rows with number or date
const filtered = items.reduce((filtered, d) => {
- 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 forceFrame
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.forceFrame = function(frameName, cb) {
const objIndexOf = function(obj, need) {
const search = need.toString();
let index = -1;
for (let i = 0, len = obj.length; i < len; i++) {
Function getData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
getData(dataId, what, whatId, args) {
// if they want data, return the data
if (!what || what == "data") {
return this._collection[dataId]["data"];
}
Function _getLimits
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getLimits(dataId, attr) {
const items = this._collection[dataId].data;
// get only column attr and only rows with number or date
const filtered = items.reduce((filtered, d) => {
Function aggregateData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
aggregateData(dataId, query, readerObject, conceptProps) {
if (Object.keys(query.grouping).every(key => query.grouping[key]["grouping"] === 1)) {
return Promise.resolve(dataId);
}
- 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 deeply nested control flow statements. Open
if (items && items.length > 0) {
next = null;
frame[column][key] = utils.interpolatePoint(items, use, column, next, TIME, frameName, method);
}
Avoid deeply nested control flow statements. Open
if (items === null) {
const givenFrames = Object.keys(nested[nestedKey]);
items = new Array(givenFrames.length);
itemsIndex = 0;
Function getData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getData(dataId, what, whatId, args) {
// if they want data, return the data
if (!what || what == "data") {
return this._collection[dataId]["data"];
}
- 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._collection[dataId][what][id];
Similar blocks of code found in 2 locations. Consider refactoring. Open
const filtered = items.reduce((filtered, d) => {
// check for dates
const f = (utils.isDate(d[attr])) ? d[attr] : parseFloat(d[attr]);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 97.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (query.select.value.filter(x => reader.query.select.value.indexOf(x) == -1).length == 0 &&
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ((!query.select.value || query.select.value.filter(x => reader.query.select.value.indexOf(x) == -1).length == 0)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76