coolchip/luxtronik2

View on GitHub

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>
 */

Severity: Major
Found in luxtronik.js - About 1 day to fix

    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);
        }
    Severity: Major
    Found in luxtronik.js - About 6 hrs to fix

      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)) {
      Severity: Minor
      Found in luxtronik.js - About 5 hrs to fix

      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)),
      Severity: Major
      Found in luxtronik.js - About 4 hrs to fix

        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);
            }
        Severity: Minor
        Found in luxtronik.js - About 4 hrs to fix

        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);
            }
        Severity: Major
        Found in luxtronik.js - About 3 hrs to fix

          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(),
          Severity: Major
          Found in luxtronik.js - About 3 hrs to fix

            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)) {
            Severity: Major
            Found in luxtronik.js - About 2 hrs to fix

              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,
              Severity: Major
              Found in luxtronik.js - About 2 hrs to fix

                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);
                    }
                Severity: Minor
                Found in luxtronik.js - About 1 hr to fix

                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];
                Severity: Minor
                Found in utils.js - About 1 hr to fix

                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];
                Severity: Minor
                Found in utils.js - About 55 mins to fix

                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();
                Severity: Major
                Found in luxtronik.js - About 45 mins to fix

                  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);
                      }
                  Severity: Minor
                  Found in luxtronik.js and 1 other location - About 40 mins to fix
                  luxtronik.js on lines 230..232

                  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

                  Further Reading

                  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);
                      }
                  Severity: Minor
                  Found in luxtronik.js and 1 other location - About 40 mins to fix
                  luxtronik.js on lines 30..32

                  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

                  Further Reading

                  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 ||
                  Severity: Major
                  Found in luxtronik.js - About 40 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return this.receivy.callback(null, {
                            values,
                            parameters,
                            additional,
                        });
                    Severity: Major
                    Found in luxtronik.js - About 30 mins to fix

                      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]);
                      Severity: Minor
                      Found in utils.js - About 25 mins to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language