ManageIQ/linux_admin

View on GitHub
lib/linux_admin/registration_system/subscription_manager.rb

Summary

Maintainability
A
1 hr
Test Coverage
A
98%

Method parse_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_content(content)
      # Break into content groupings by "\n\n" then process each grouping
      content.split("\n\n").each_with_object([]) do |group, group_array|
        group = group.split("\n").each_with_object({}) do |line, hash|
          next if line.blank?
Severity: Minor
Found in lib/linux_admin/registration_system/subscription_manager.rb - 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

Method register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def register(options)
      raise ArgumentError, "username and password are required" unless options[:username] && options[:password]

      install_server_certificate(options[:server_url], SATELLITE6_SERVER_CERT_PATH) if options[:server_url]

Severity: Minor
Found in lib/linux_admin/registration_system/subscription_manager.rb - About 25 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

Use params["--auto"] = nil instead of params.merge!({"--auto" => nil}).
Open

        params.merge!({"--auto" => nil})

This cop identifies places where Hash#merge! can be replaced by Hash#[]=.

Example:

hash.merge!(a: 1)
hash.merge!({'key' => 'value'})
hash.merge!(a: 1, b: 2)

Unused method argument - options. If it's necessary, use _ or _options as an argument name to indicate that it won't be used. If it's unnecessary, remove it. You can also write as all_repos(*) if you want the method to accept any arguments but don't care about them.
Open

    def all_repos(options = nil)

Checks for unused method arguments.

Example:

# bad
def some_method(used, unused, _unused_but_allowed)
  puts used
end

# good
def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Example: AllowUnusedKeywordArguments: false (default)

# bad
def do_something(used, unused: 42)
  used
end

Example: AllowUnusedKeywordArguments: true

# good
def do_something(used, unused: 42)
  used
end

Example: IgnoreEmptyMethods: true (default)

# good
def do_something(unused)
end

Example: IgnoreEmptyMethods: false

# bad
def do_something(unused)
end

Example: IgnoreNotImplementedMethods: true (default)

# good
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Example: IgnoreNotImplementedMethods: false

# bad
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Unused method argument - options. If it's necessary, use _ or _options as an argument name to indicate that it won't be used. If it's unnecessary, remove it.
Open

    def enable_repo(repo, options = nil)

Checks for unused method arguments.

Example:

# bad
def some_method(used, unused, _unused_but_allowed)
  puts used
end

# good
def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Example: AllowUnusedKeywordArguments: false (default)

# bad
def do_something(used, unused: 42)
  used
end

Example: AllowUnusedKeywordArguments: true

# good
def do_something(used, unused: 42)
  used
end

Example: IgnoreEmptyMethods: true (default)

# good
def do_something(unused)
end

Example: IgnoreEmptyMethods: false

# bad
def do_something(unused)
end

Example: IgnoreNotImplementedMethods: true (default)

# good
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Example: IgnoreNotImplementedMethods: false

# bad
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Unused method argument - options. If it's necessary, use _ or _options as an argument name to indicate that it won't be used. If it's unnecessary, remove it.
Open

    def disable_repo(repo, options = nil)

Checks for unused method arguments.

Example:

# bad
def some_method(used, unused, _unused_but_allowed)
  puts used
end

# good
def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Example: AllowUnusedKeywordArguments: false (default)

# bad
def do_something(used, unused: 42)
  used
end

Example: AllowUnusedKeywordArguments: true

# good
def do_something(used, unused: 42)
  used
end

Example: IgnoreEmptyMethods: true (default)

# good
def do_something(unused)
end

Example: IgnoreEmptyMethods: false

# bad
def do_something(unused)
end

Example: IgnoreNotImplementedMethods: true (default)

# good
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Example: IgnoreNotImplementedMethods: false

# bad
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

There are no issues that match your filters.

Category
Status