Showing 18 of 18 total issues
File luxtronik.js
has 681 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @module luxtronik2
* @copyright Sebastian B. <coolchip@gmx.de>
*/
Function processValues
has 168 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processValues(heatpumpValues, heatpumpVisibility) {
let additionalValues = {};
if (this.options && typeof this.options.onProcessValues === 'function') {
additionalValues = this.options.onProcessValues(heatpumpValues, heatpumpVisibility);
}
Function _processData
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
Luxtronik.prototype._processData = function () {
// break if one of the data packages is missing or has no payload
const requiredDataFields = ['3003', '3004', '3005'];
for (const element of requiredDataFields) {
if (!Object.prototype.hasOwnProperty.call(this.receivy, element)) {
- 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 _handleWriteCommand
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
Luxtronik.prototype._handleWriteCommand = function (parameterName, realValue, callback) {
const writeParameters = Object.freeze({
heating_target_temperature: {
setParameter: 1,
setValue: utils.value2LuxtronikSetTemperatureValue(utils.limitRange(realValue, -10, 10)),
Function processValues
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function processValues(heatpumpValues, heatpumpVisibility) {
let additionalValues = {};
if (this.options && typeof this.options.onProcessValues === 'function') {
additionalValues = this.options.onProcessValues(heatpumpValues, heatpumpVisibility);
}
- 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 processParameters
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processParameters(heatpumpParameters, heatpumpVisibility) {
let additionalParameters = {};
if (this.options && typeof this.options.onProcessParameters === 'function') {
additionalParameters = this.options.onProcessParameters(heatpumpParameters, heatpumpVisibility);
}
Function _startRead
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
Luxtronik.prototype._startRead = function (rawdata, callback) {
this.receivy = {
jobs: [3003, 3004, 3005],
activeCommand: 0,
readingStartTime: Date.now(),
Function _processData
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
Luxtronik.prototype._processData = function () {
// break if one of the data packages is missing or has no payload
const requiredDataFields = ['3003', '3004', '3005'];
for (const element of requiredDataFields) {
if (!Object.prototype.hasOwnProperty.call(this.receivy, element)) {
Function _startWrite
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Luxtronik.prototype._startWrite = function (setParameter, setValue, callback) {
this.writeClient = net.createConnection(
{
host: this._host,
port: this._port,
Function processParameters
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function processParameters(heatpumpParameters, heatpumpVisibility) {
let additionalParameters = {};
if (this.options && typeof this.options.onProcessParameters === 'function') {
additionalParameters = this.options.onProcessParameters(heatpumpParameters, heatpumpVisibility);
}
- 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 createExtendedStateString
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function createExtendedStateString(values) {
let stateStr = '';
const defrostValve = values[37];
const heatSourceMotor = values[43];
const compressor1 = values[44];
- 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 createStateString
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function createStateString(values) {
let stateStr = '';
const state1 = values[117];
const state2 = values[118];
const duration = values[120];
- 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 (this.client) this.client.end();
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (this.options && typeof this.options.onProcessValues === 'function') {
additionalValues = this.options.onProcessValues(heatpumpValues, heatpumpVisibility);
}
- 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 49.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (this.options && typeof this.options.onProcessParameters === 'function') {
additionalParameters = this.options.onProcessParameters(heatpumpParameters, heatpumpVisibility);
}
- 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 49.
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
Consider simplifying this complex logical expression. Open
if (
parameters.heating_operation_mode === 0 &&
parameters.heatingLimit === 1 &&
values.temperature_outside_avg >= parameters.thresholdHeatingLimit &&
(values.temperature_target_return === parameters.returnTemperatureTargetMin ||
Avoid too many return
statements within this function. Open
return this.receivy.callback(null, {
values,
parameters,
additional,
});
Function createFirmwareString
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function createFirmwareString(buf) {
let firmware = '';
for (const key in buf) {
if ({}.hasOwnProperty.call(buf, key)) {
firmware += buf[key] === 0 ? '' : String.fromCharCode(buf[key]);
- 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"