srveit/insteon-hub2

View on GitHub

Showing 62 of 62 total issues

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

addImParser('6A', 'Get Next ALL-Link Record', 2, (response, buffer) => {
  response.ack = buffer.substring(0, 2) === '06'
  response.responseMatcher = matchAllLinkRecordResponse
  return response
})
Severity: Major
Found in lib/parsers.js and 2 other locations - About 1 hr to fix
lib/parsers.js on lines 269..273
lib/parsers.js on lines 288..292

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

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

addImParser('6C', 'Get ALL-Link Record for Sender', 2, (response, buffer) => {
  response.ack = buffer.substring(0, 2) === '06'
  response.responseMatcher = matchAllLinkRecordResponse
  return response
})
Severity: Major
Found in lib/parsers.js and 2 other locations - About 1 hr to fix
lib/parsers.js on lines 269..273
lib/parsers.js on lines 275..279

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

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

addImParser('69', 'Get First ALL-Link Record', 2, (response, buffer) => {
  response.ack = buffer.substring(0, 2) === '06'
  response.responseMatcher = matchAllLinkRecordResponse
  return response
})
Severity: Major
Found in lib/parsers.js and 2 other locations - About 1 hr to fix
lib/parsers.js on lines 275..279
lib/parsers.js on lines 288..292

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

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

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

  const plm = createPlm({
    username: process.env.HUB_USERNAME,
    password: process.env.HUB_PASSWORD,
    host: 'insteon-hub',
    port: 25105,
Severity: Minor
Found in examples/readHubDatabase.js and 1 other location - About 55 mins to fix
examples/linkDevice.js on lines 24..30

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

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

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

  const plm = createPlm({
    username: process.env.HUB_USERNAME,
    password: process.env.HUB_PASSWORD,
    host: 'insteon-hub',
    port: 25105,
Severity: Minor
Found in examples/linkDevice.js and 1 other location - About 55 mins to fix
examples/readHubDatabase.js on lines 21..27

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

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

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

const ENGINE_VERSION_CODES = Object.entries(ENGINE_VERSION_NAMES).reduce(
  (engineVersionCodes, [code, name]) => {
    engineVersionCodes[name] = code
    return engineVersionCodes
  },
Severity: Major
Found in lib/constants.js and 3 other locations - About 40 mins to fix
lib/constants.js on lines 9..15
lib/constants.js on lines 26..32
lib/constants.js on lines 91..97

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

directAck('1F02', 'Get Signal-to-Noise Value', ({ command, response }) => {
  command.signalToNoise = parseInt(response.command2, 16)
  return command
})
Severity: Minor
Found in lib/parseInsteonCommand.js and 1 other location - About 40 mins to fix
lib/parseInsteonCommand.js on lines 390..393

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

const ALL_LINK_CODES = Object.entries(ALL_LINK_TYPES).reduce(
  (allLinkCodes, [allLinkCode, allLinkType]) => {
    allLinkCodes[allLinkType] = allLinkCode
    return allLinkCodes
  },
Severity: Major
Found in lib/constants.js and 3 other locations - About 40 mins to fix
lib/constants.js on lines 26..32
lib/constants.js on lines 91..97
lib/constants.js on lines 104..110

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

const OUTLET_CODES = Object.entries(OUTLET_NAMES).reduce(
  (outletCodes, [code, name]) => {
    outletCodes[name] = code
    return outletCodes
  },
Severity: Major
Found in lib/constants.js and 3 other locations - About 40 mins to fix
lib/constants.js on lines 9..15
lib/constants.js on lines 26..32
lib/constants.js on lines 104..110

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

directAck('1F01', 'Get ALL-Link Database Delta', ({ command, response }) => {
  command.allLinkDatabaseDelta = parseInt(response.command2, 16)
  return command
})
Severity: Minor
Found in lib/parseInsteonCommand.js and 1 other location - About 40 mins to fix
lib/parseInsteonCommand.js on lines 394..397

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

const ALL_LINK_CONTROL_CODES = Object.entries(ALL_LINK_CONTROL_NAMES).reduce(
  (allLinkControlCodes, [code, name]) => {
    allLinkControlCodes[name] = code
    return allLinkControlCodes
  },
Severity: Major
Found in lib/constants.js and 3 other locations - About 40 mins to fix
lib/constants.js on lines 9..15
lib/constants.js on lines 91..97
lib/constants.js on lines 104..110

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

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 + '  ' +
    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

    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 '[\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 }
            Severity: Major
            Found in lib/parsePlmBuffer.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language