lib/frecli/settings.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method setting_filenames has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.setting_filenames(root_path: '/')
      setting_paths(root_path: root_path).map do |path|
        filename = join_paths(path, '.frecli')

        next unless File.exist?(filename)
Severity: Minor
Found in lib/frecli/settings.rb - 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

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
Open

            Hash[YAML.load(File.open name).map { |(k, v)| [k.to_sym, v] }])
Severity: Minor
Found in lib/frecli/settings.rb by rubocop

This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

When using the symmetrical (default) style:

If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

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

When using the new_line style:

The closing brace of a multi-line method call must be on the line after the last argument of the call.

When using the same_line style:

The closing brace of a multi-line method call must be on the same line as the last argument of the call.

Example:

# symmetrical: bad
  # new_line: good
  # same_line: bad
  foo(a,
    b
  )

  # symmetrical: bad
  # new_line: bad
  # same_line: good
  foo(
    a,
    b)

  # symmetrical: good
  # new_line: bad
  # same_line: good
  foo(a,
    b)

  # symmetrical: good
  # new_line: good
  # same_line: bad
  foo(
    a,
    b
  )

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

      if reload || !@settings
Severity: Minor
Found in lib/frecli/settings.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Prefer using YAML.safe_load over YAML.load.
Open

            Hash[YAML.load(File.open name).map { |(k, v)| [k.to_sym, v] }])
Severity: Minor
Found in lib/frecli/settings.rb by rubocop

This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

Example:

# bad
YAML.load("--- foo")

# good
YAML.safe_load("--- foo")
YAML.dump("foo")

Add parentheses to nested method call File.open name.
Open

            Hash[YAML.load(File.open name).map { |(k, v)| [k.to_sym, v] }])
Severity: Minor
Found in lib/frecli/settings.rb by rubocop

This cop checks for unparenthesized method calls in the argument list of a parenthesized method call.

Example:

# good
method1(method2(arg), method3(arg))

# bad
method1(method2 arg, method3, arg)

There are no issues that match your filters.

Category
Status