thomis/sensu-plugins-oracle

View on GitHub
bin/check-oracle-alive.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method has too many lines. [19/10]
Open

  def handle_connections_from_file
    sessions = ::SensuPluginsOracle::Session.parse_from_file(config[:file])
    ::SensuPluginsOracle::Session.handle_multiple(sessions: sessions,
                                                  method: :alive?,
                                                  config: config)
Severity: Minor
Found in bin/check-oracle-alive.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for handle_connections_from_file is too high. [21.4/15]
Open

  def handle_connections_from_file
    sessions = ::SensuPluginsOracle::Session.parse_from_file(config[:file])
    ::SensuPluginsOracle::Session.handle_multiple(sessions: sessions,
                                                  method: :alive?,
                                                  config: config)
Severity: Minor
Found in bin/check-oracle-alive.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for handle_connection is too high. [15.07/15]
Open

  def handle_connection
    session = SensuPluginsOracle::Session.new(username: config[:username],
                                              password: config[:password],
                                              database: config[:database],
                                              privilege: config[:privilege])
Severity: Minor
Found in bin/check-oracle-alive.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Complex method CheckOracleAlive#handle_connections_from_file (31.8)
Open

  def handle_connections_from_file
    sessions = ::SensuPluginsOracle::Session.parse_from_file(config[:file])
    ::SensuPluginsOracle::Session.handle_multiple(sessions: sessions,
                                                  method: :alive?,
                                                  config: config)
Severity: Minor
Found in bin/check-oracle-alive.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

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

  def handle_connections_from_file
    sessions = ::SensuPluginsOracle::Session.parse_from_file(config[:file])
    ::SensuPluginsOracle::Session.handle_multiple(sessions: sessions,
                                                  method: :alive?,
                                                  config: config)
Severity: Minor
Found in bin/check-oracle-alive.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

Complex method CheckOracleAlive#handle_connection (20.3)
Open

  def handle_connection
    session = SensuPluginsOracle::Session.new(username: config[:username],
                                              password: config[:password],
                                              database: config[:database],
                                              privilege: config[:privilege])
Severity: Minor
Found in bin/check-oracle-alive.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Extra empty line detected before the rescue.
Open


  rescue => e
Severity: Minor
Found in bin/check-oracle-alive.rb by rubocop

This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

Example:

# good

begin
  do_something
rescue
  do_something2
else
  do_something3
ensure
  do_something4
end

# good

def foo
  do_something
rescue
  do_something2
end

# bad

begin
  do_something

rescue

  do_something2

else

  do_something3

ensure

  do_something4
end

# bad

def foo
  do_something

rescue

  do_something2
end

Avoid rescuing without specifying an error class.
Open

  rescue => e
Severity: Minor
Found in bin/check-oracle-alive.rb by rubocop

This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

Example: EnforcedStyle: implicit

# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.

# bad
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Example: EnforcedStyle: explicit (default)

# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.

# bad
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

There are no issues that match your filters.

Category
Status