srveit/insteon-hub2

View on GitHub

Showing 62 of 62 total issues

File deviceCategories.js has 2191 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'
/* eslint quote-props: "off" */module.exports = {
  '00': {
    categoryId: '00',
    categoryName: 'Generalized Controllers',
Severity: Major
Found in lib/deviceCategories.js - About 6 days to fix

    File parseInsteonCommand.js has 510 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict'
    const { createAllLinkRecord } = require('./allLinkRecord')
    const { ENGINE_VERSION_NAMES, OUTLET_CODES, OUTLET_NAMES, X10_HOUSE_CODES, X10_UNIT_CODES, NAK_ERRORS } =
      require('./constants')
    const allLinkParsers = {}
    Severity: Major
    Found in lib/parseInsteonCommand.js - About 1 day to fix

      File parsers.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict'
      const { parseInsteonCommand } = require('./parseInsteonCommand')
      const {
        X10_COMMANDS, X10_HOUSE_CODES, X10_UNIT_CODES, INSTEON_MESSAGE_TYPES,
        ALL_LINK_TYPES, BUTTON_EVENTS, ALL_LINK_CONTROL_NAMES,
      Severity: Minor
      Found in lib/parsers.js - About 3 hrs to fix

        File encodeCommand.js has 314 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict'
        
        // Also look at
        //   2475SDBdev-112011-en.pdf
        //   2477Sdev-072012-en.pdf
        Severity: Minor
        Found in lib/encodeCommand.js - About 3 hrs to fix

          Function combineCategories has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          function combineCategories (categories, categories2) {
            for (const category2 of Object.values(categories2)) {
              for (const device2 of Object.values(category2.subcategories)) {
                const subcategories = categories[device2.categoryId] &&
                  categories[device2.categoryId].subcategories
          Severity: Minor
          Found in tools/createDeviceCategories.js - About 2 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          direct('2E', 'Light ON at Ramp Rate', ({ command, response }) => {
            const command2 = response.command2
            command.onLevel = decodeOnLevel(command2.substring(0, 1))
            command.rampRate = decodeRampRate(command2.substring(1, 2))
            return command
          Severity: Major
          Found in lib/parseInsteonCommand.js and 1 other location - About 2 hrs to fix
          lib/parseInsteonCommand.js on lines 431..436

          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 87.

          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

          directAck('2E', 'Light ON at Ramp Rate', ({ command, response }) => {
            const command2 = response.command2
            command.onLevel = decodeOnLevel(command2.substring(0, 1))
            command.rampRate = decodeRampRate(command2.substring(1, 2))
            return command
          Severity: Major
          Found in lib/parseInsteonCommand.js and 1 other location - About 2 hrs to fix
          lib/parseInsteonCommand.js on lines 264..269

          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 87.

          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

          Function createPlmBase has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          const createPlmBase = ({ username, password, host, port }) => {
            let hubInfo
          
            const authHeader = () => {
              const data = Buffer.from(`${username}:${password}`)
          Severity: Minor
          Found in lib/plmBase.js - About 2 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 createPlmCommandQueue has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const createPlmCommandQueue = (
            sendCommandBuffer,
            setTimeoutFn = setTimeout
          ) => {
            /* eslint no-use-before-define: "off" */
          Severity: Major
          Found in lib/plmCommandQueue.js - About 2 hrs to fix

            Function createPlmStream has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const createPlmStream = (plmBase, pollingInterval = 50) => {
              let log = []
              let monitoring
              /* eslint prefer-const: "off" */
              let monitor
            Severity: Major
            Found in lib/plmStream.js - About 2 hrs to fix

              Function createPlmBufferProcessor has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              const createPlmBufferProcessor = () => {
                let previousBuffer = ''
              
                const processPlmBuffer = buffer => {
                  const previousBufferLength = previousBuffer.length > 2
              Severity: Minor
              Found in lib/plmBufferProcessor.js - About 2 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 createPlmStream has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              const createPlmStream = (plmBase, pollingInterval = 50) => {
                let log = []
                let monitoring
                /* eslint prefer-const: "off" */
                let monitor
              Severity: Minor
              Found in lib/plmStream.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 createDevice has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function createDevice ({ id, name }) {
                const properties = {
                  id,
                  name,
                }
              Severity: Minor
              Found in lib/device.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 createPlmCommandStream has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const createPlmCommandStream = (parsingLogger = defaultLogger) => {
                let currentBuffer = ''
                let previousParsedCommand
              
                const transform = (chunk, encoding, callback) => {
              Severity: Minor
              Found in lib/plmCommandStream.js - About 1 hr to fix

                Function parsePlmBuffer has 43 lines of code (exceeds 25 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 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  directAck('33', 'Outlet OFF', ({ command, previousCommand }) => {
                    const previousCommand2 = previousCommand ? previousCommand.command2 : '--'
                    command.command = `Outlet OFF (${OUTLET_NAMES[previousCommand2]})`
                    return command
                  })
                  Severity: Major
                  Found in lib/parseInsteonCommand.js and 1 other location - About 1 hr to fix
                  lib/parseInsteonCommand.js on lines 461..465

                  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 69.

                  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

                  directAck('32', 'Outlet ON', ({ command, previousCommand }) => {
                    const previousCommand2 = previousCommand ? previousCommand.command2 : '--'
                    command.command = `Outlet ON (${OUTLET_NAMES[previousCommand2]})`
                    return command
                  })
                  Severity: Major
                  Found in lib/parseInsteonCommand.js and 1 other location - About 1 hr to fix
                  lib/parseInsteonCommand.js on lines 466..470

                  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 69.

                  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

                  addImParser('6B', 'Set IM Configuration', 4, (response, buffer) => {
                    response.imConfigurationFlags =
                      parseImConfigurationFlags(buffer.substring(0, 2))
                    response.ack = buffer.substring(2, 4) === '06'
                    return response
                  Severity: Major
                  Found in lib/parsers.js and 1 other location - About 1 hr to fix
                  lib/parsers.js on lines 383..387

                  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 68.

                  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

                  addImParser('7B', 'Set RF Frequency Offset', 4, (response, buffer) => {
                    response.refFrequencyOffset = parseSignedInt(buffer.substring(0, 2))
                    response.ack = buffer.substring(2, 4) === '06'
                    return response
                  })
                  Severity: Major
                  Found in lib/parsers.js and 1 other location - About 1 hr to fix
                  lib/parsers.js on lines 281..286

                  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 68.

                  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

                  Function createPlmCommandQueue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const createPlmCommandQueue = (
                    sendCommandBuffer,
                    setTimeoutFn = setTimeout
                  ) => {
                    /* eslint no-use-before-define: "off" */
                  Severity: Minor
                  Found in lib/plmCommandQueue.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

                  Severity
                  Category
                  Status
                  Source
                  Language