srveit/insteon-hub2

View on GitHub

Showing 62 of 62 total issues

Function createAllLinkDatabase has 39 lines of code (exceeds 25 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

    Function parseInsteonCommand has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const parseInsteonCommand = (response, previousCommand) => {
      let messageType = response.messageType
      let command1 = response.command1
      let command2 = response.command2
    
    
    Severity: Minor
    Found in lib/parseInsteonCommand.js - About 1 hr to fix

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

      addImParser('68', 'Set INSTEON ACK Message Byte', 4, (response, buffer) => {
        response.command2Data = buffer.substring(0, 2)
        response.ack = buffer.substring(2, 4) === '06'
        return response
      })
      Severity: Major
      Found in lib/parsers.js and 4 other locations - About 1 hr to fix
      lib/parsers.js on lines 314..318
      lib/parsers.js on lines 345..349
      lib/parsers.js on lines 365..369
      lib/parsers.js on lines 371..375

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

      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 5 locations. Consider refactoring.
      Open

      addImParser('70', 'Set INSTEON NAK Message Byte', 4, (response, buffer) => {
        response.command2Data = buffer.substring(0, 2)
        response.ack = buffer.substring(2, 4) === '06'
        return response
      })
      Severity: Major
      Found in lib/parsers.js and 4 other locations - About 1 hr to fix
      lib/parsers.js on lines 263..267
      lib/parsers.js on lines 345..349
      lib/parsers.js on lines 365..369
      lib/parsers.js on lines 371..375

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

      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 5 locations. Consider refactoring.
      Open

      addImParser('75', 'Read 8 bytes from Database', 6, (response, buffer) => {
        response.address = buffer.substring(0, 4)
        response.ack = buffer.substring(4, 6) === '06'
        return response
      })
      Severity: Major
      Found in lib/parsers.js and 4 other locations - About 1 hr to fix
      lib/parsers.js on lines 263..267
      lib/parsers.js on lines 314..318
      lib/parsers.js on lines 365..369
      lib/parsers.js on lines 371..375

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

      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 5 locations. Consider refactoring.
      Open

      addImParser('79', 'Set Database Link Data for next Link', 8, (response, buffer) => {
        response.data = buffer.substring(0, 6)
        response.ack = buffer.substring(6, 8) === '06'
        return response
      })
      Severity: Major
      Found in lib/parsers.js and 4 other locations - About 1 hr to fix
      lib/parsers.js on lines 263..267
      lib/parsers.js on lines 314..318
      lib/parsers.js on lines 345..349
      lib/parsers.js on lines 365..369

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

      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 5 locations. Consider refactoring.
      Open

      addImParser('78', 'Set Status', 4, (response, buffer) => {
        response.status = buffer.substring(0, 2)
        response.ack = buffer.substring(2, 4) === '06'
        return response
      })
      Severity: Major
      Found in lib/parsers.js and 4 other locations - About 1 hr to fix
      lib/parsers.js on lines 263..267
      lib/parsers.js on lines 314..318
      lib/parsers.js on lines 345..349
      lib/parsers.js on lines 371..375

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

      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 parseInsteonCommand has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      const parseInsteonCommand = (response, previousCommand) => {
        let messageType = response.messageType
        let command1 = response.command1
        let command2 = response.command2
      
      
      Severity: Minor
      Found in lib/parseInsteonCommand.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 createCommandAnnotator has a Cognitive Complexity of 12 (exceeds 5 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

      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 a Cognitive Complexity of 12 (exceeds 5 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

      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 update has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const update = command => {
          const propertyNames = [
            'deviceCategory',
            'deviceSubcategory',
            'firmware',
      Severity: Minor
      Found in lib/device.js - About 1 hr to fix

        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

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

            extendedData('0302', 'Device Text String', ({ command, response }) => {
              const data = response.data
              command.textString = data.substring(0, 28)
              return command
            })
            Severity: Major
            Found in lib/parseInsteonCommand.js and 1 other location - About 1 hr to fix
            lib/parseInsteonCommand.js on lines 498..502

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

            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

            extendedData('0303', 'Set Device Text String', ({ command, response }) => {
              const data = response.data
              command.textString = data.substring(0, 28)
              return command
            })
            Severity: Major
            Found in lib/parseInsteonCommand.js and 1 other location - About 1 hr to fix
            lib/parseInsteonCommand.js on lines 493..497

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

            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 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
                    Severity
                    Category
                    Status
                    Source
                    Language