srveit/insteon-hub2

View on GitHub

Showing 38 of 62 total issues

Function createPlmBufferProcessor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createPlmBufferProcessor = () => {
  let previousBuffer = ''

  const processPlmBuffer = buffer => {
    const previousBufferLength = previousBuffer.length > 2
Severity: Minor
Found in lib/plmBufferProcessor.js - About 1 hr to fix

    Function objectToString has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function objectToString (object, indent = '') {
      if (object === undefined) {
        return 'undefined'
      }
      if (object === null) {
    Severity: Minor
    Found in tools/objectToString.js - About 1 hr to fix

      Function addAllLinkRecord has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const addAllLinkRecord = record => {
          if (record.insteonCommand && record.insteonCommand.type === 'Record Response') {
            addAllLinkRecord(record.insteonCommand)
            return
          }
      Severity: Minor
      Found in lib/allLinkDatabase.js - About 1 hr to fix

        Function createAllLinkRecord has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const createAllLinkRecord = buffer => {
          const flags = parseInt(buffer.substring(0, 2), 16)
          const response = {
            inUse: (0x80 & flags) !== 0,
            isController: (0x40 & flags) !== 0,
        Severity: Minor
        Found in lib/allLinkRecord.js - About 1 hr to fix

          Function createCommandAnnotator has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const createCommandAnnotator = (deviceNames) => {
            const addDeviceName = command => {
              if (command.fromAddress) {
                command.fromDevice = deviceNames[command.fromAddress]
              }
          Severity: Minor
          Found in lib/commandAnnotator.js - About 1 hr to fix

            Function createAllLinkDatabase has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            const createAllLinkDatabase = () => {
              const entries = {}
            
              const addAllLinkRecord = record => {
                if (record.insteonCommand && record.insteonCommand.type === 'Record Response') {
            Severity: Minor
            Found in lib/allLinkDatabase.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 processPlmBuffer has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const processPlmBuffer = buffer => {
                const previousBufferLength = previousBuffer.length > 2
                  ? parseInt(previousBuffer.slice(-2), 16)
                  : 0
                const bufferLength = buffer && buffer.length > 2
            Severity: Minor
            Found in lib/plmBufferProcessor.js - About 1 hr to fix

              Function objectToString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function objectToString (object, indent = '') {
                if (object === undefined) {
                  return 'undefined'
                }
                if (object === null) {
              Severity: Minor
              Found in tools/objectToString.js - About 45 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 standard has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              const standard = (
                messageType,
                command1And2,
                commandName,
                command2PropertyOrParser
              Severity: Minor
              Found in lib/parseInsteonCommand.js - About 45 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 parsePlmBuffer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              const parsePlmBuffer = (inputBuffer, previousCommand) => {
                let command
                const startOfText = inputBuffer.indexOf('02')
                const buffer = inputBuffer.substring(startOfText)
                if (startOfText < 0) {
              Severity: Minor
              Found in lib/parsePlmBuffer.js - About 35 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 too many return statements within this function.
              Open

                  return '[\n' +
                    indent + '  ' +
                    object.map(element => objectToString(element, indent + '  '))
                      .join(',\n  ' + indent) +
                    '\n' + indent + ']'
              Severity: Major
              Found in tools/objectToString.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return '{}'
                Severity: Major
                Found in tools/objectToString.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return {
                        buffer: buffer.substring(4 + command.length),
                        command,
                      }
                  Severity: Major
                  Found in lib/parsePlmBuffer.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return { buffer }
                    Severity: Major
                    Found in lib/parsePlmBuffer.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return '[]'
                      Severity: Major
                      Found in tools/objectToString.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                          return '{\n' +
                            indent + '  ' +
                            keys.map(key => keyValueToString(key, object[key], indent))
                              .join(',\n  ' + indent) +
                            ',\n' + indent + '}'
                        Severity: Major
                        Found in tools/objectToString.js - About 30 mins to fix

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

                          const sd = (name, command1, command2 = '00') => {
                            const encoder = command =>
                            /* eslint no-nested-ternary: "off" */
                              encoders['Send INSTEON Standard-length Message']({
                                messageType: 'direct',
                          Severity: Minor
                          Found in lib/encodeCommand.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

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

                          const ed = (name, command1, command2 = '00', userData = '', matcher) => {
                            const encoder = command => {
                              return encoders['Send INSTEON Extended-length Message']({
                                messageType: 'direct',
                                toAddress: command.toAddress,
                          Severity: Minor
                          Found in lib/encodeCommand.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