SergiuToporjinschi/node-red-contrib-heater-controller

View on GitHub

Showing 8 of 12 total issues

Function onUserConfig has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    onUserConfig(msg) {
        if (typeof (msg.payload) !== 'object' ||
            !(Object.hasOwnProperty.call(msg.payload, 'isLocked') || Object.hasOwnProperty.call(msg.payload, 'userTargetValue') || Object.hasOwnProperty.call(msg.payload, 'isUserCustom')) ||
            !(['undefined', 'boolean'].includes(typeof (msg.payload.isLocked)) &&
                ['undefined', 'number'].includes(typeof (msg.payload.userTargetValue)) &&
Severity: Minor
Found in nodes/heater/heater.js - About 1 hr to fix

    Function validateTiming has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function validateTiming(timing, errorMsg, day) {
        for (var time in timing) {
            var value = timing[time];
            var valueMsg = (typeof (value) !== 'number') ? 'temperature needs to be a number' : undefined;
            if (!time.match(/^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/g)) {
    Severity: Minor
    Found in nodes/heater/calendarValidation.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 onUserConfig has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        onUserConfig(msg) {
            if (typeof (msg.payload) !== 'object' ||
                !(Object.hasOwnProperty.call(msg.payload, 'isLocked') || Object.hasOwnProperty.call(msg.payload, 'userTargetValue') || Object.hasOwnProperty.call(msg.payload, 'isUserCustom')) ||
                !(['undefined', 'boolean'].includes(typeof (msg.payload.isLocked)) &&
                    ['undefined', 'number'].includes(typeof (msg.payload.userTargetValue)) &&
    Severity: Minor
    Found in nodes/heater/heater.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 connectToWS has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            $scope.connectToWS = function () {
                var url = new URL($scope.serverURL, window.location.href);
                url.protocol = 'ws:';
                $scope.socket = new WebSocket(url.href);
                $scope.socketEvents = {
    Severity: Minor
    Found in nodes/heater/frontEnd.js - About 1 hr to fix

      Function recalculate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          recalculate() {
              if (typeof (this.status) === 'undefined' || typeof (this.status.currentTemp) !== 'number') {
                  this.debug('Recalculate: no current temperature!!!');
                  return;
              }
      Severity: Minor
      Found in nodes/heater/heater.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if (typeof (msg.payload) !== 'object' ||
                    !(Object.hasOwnProperty.call(msg.payload, 'isLocked') || Object.hasOwnProperty.call(msg.payload, 'userTargetValue') || Object.hasOwnProperty.call(msg.payload, 'isUserCustom')) ||
                    !(['undefined', 'boolean'].includes(typeof (msg.payload.isLocked)) &&
                        ['undefined', 'number'].includes(typeof (msg.payload.userTargetValue)) &&
                        ['undefined', 'boolean'].includes(typeof (msg.payload.isUserCustom)))) {
        Severity: Major
        Found in nodes/heater/heater.js - About 1 hr to fix

          Function recalculate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              recalculate() {
                  if (typeof (this.status) === 'undefined' || typeof (this.status.currentTemp) !== 'number') {
                      this.debug('Recalculate: no current temperature!!!');
                      return;
                  }
          Severity: Minor
          Found in nodes/heater/heater.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

          Function getSearchedInterval has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              getSearchedInterval(offSet) {
                  var intervalList = [];
                  for (var i in this.config.calendar) {
                      var dayId = weekDays.indexOf(i);
                      for (var j in this.config.calendar[i]) {
          Severity: Minor
          Found in nodes/heater/heater.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