Function ObisMeasurement
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Wontfix
function ObisMeasurement(medium, channel, measurement, measureType, tariffRate, previousMeasurement) {
this.medium = medium;
this.channel = channel;
this.measurement = measurement;
this.measureType = measureType;
- 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 addValue
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Wontfix
ObisMeasurement.prototype.addValue = function addValue(value, unit) {
if (typeof value === 'string') {
var valueFloat = parseFloat(value);
if (valueFloat.toString() === value) { // it is a float
value = valueFloat;
- 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 ObisMeasurement
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
function ObisMeasurement(medium, channel, measurement, measureType, tariffRate, previousMeasurement) {
this.medium = medium;
this.channel = channel;
this.measurement = measurement;
this.measureType = measureType;
Function idToString
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Wontfix
ObisMeasurement.prototype.idToString = function idToString(content) {
var fullContent = (content === undefined || content === 'full');
var extendedContent = (content === undefined || content === 'full' || content === 'extended');
var obisStr = '';
- 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 addValue
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
ObisMeasurement.prototype.addValue = function addValue(value, unit) {
if (typeof value === 'string') {
var valueFloat = parseFloat(value);
if (valueFloat.toString() === value) { // it is a float
value = valueFloat;
Avoid deeply nested control flow statements. Wontfix
if (obisArr[1] !== '') this.setMeasurement(obisArr[1]);
Function ObisMeasurement
has 6 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
function ObisMeasurement(medium, channel, measurement, measureType, tariffRate, previousMeasurement) {
Avoid deeply nested control flow statements. Wontfix
if (obisArr[2] !== '') this.setMeasureType(obisArr[2]);
Avoid deeply nested control flow statements. Wontfix
if (obisArr[4] !== '') this.setPreviousMeasurement(obisArr[4]);
Avoid deeply nested control flow statements. Wontfix
if (obisArr[3] !== '') this.setTariffRate(obisArr[3]);