bloomberg/collectd-cookbook

View on GitHub
libraries/collectd_config.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method write_elements has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def write_elements(directives, indent = 0)
        tabs = ("\t" * indent)
        directives.dup.map do |key, value|
          next if value.nil?
          key = snake_to_camel(key)
Severity: Minor
Found in libraries/collectd_config.rb - 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

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.
Open

            ].join("\n")
Severity: Minor
Found in libraries/collectd_config.rb by rubocop

This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

When using the symmetrical (default) style:

If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

When using the new_line style:

The closing brace of a multi-line array literal must be on the line after the last element of the array.

When using the same_line style:

The closing brace of a multi-line array literal must be on the same line as the last element of the array.

Example: EnforcedStyle: symmetrical (default)

# bad
  [ :a,
    :b
  ]

  # bad
  [
    :a,
    :b ]

  # good
  [ :a,
    :b ]

  # good
  [
    :a,
    :b
  ]

Example: EnforcedStyle: new_line

# bad
  [
    :a,
    :b ]

  # bad
  [ :a,
    :b ]

  # good
  [ :a,
    :b
  ]

  # good
  [
    :a,
    :b
  ]

Example: EnforcedStyle: same_line

# bad
  [ :a,
    :b
  ]

  # bad
  [
    :a,
    :b
  ]

  # good
  [
    :a,
    :b ]

  # good
  [ :a,
    :b ]

There are no issues that match your filters.

Category
Status