stevenhaddox/dnc

View on GitHub
lib/dnc/dn.rb

Summary

Maintainability
A
35 mins
Test Coverage

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

  def to_s
    return_string = ''
    @string_order.each do |string_name|
      unless send(string_name.to_sym).blank?
        return_string += ',' unless return_string.empty?
Severity: Minor
Found in lib/dnc/dn.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

When using method_missing, define respond_to_missing?.
Open

  def method_missing(method_name)
    # Catch methods that end with _string
    method_match = method_name.to_s.match(/(.+)_string\z/)
    unless method_match.blank?
      method = method_match[1]
Severity: Minor
Found in lib/dnc/dn.rb by rubocop

This cop checks for the presence of method_missing without also defining respond_to_missing? and falling back on super.

Example:

#bad
def method_missing(name, *args)
  # ...
end

#good
def respond_to_missing?(name, include_private)
  # ...
end

def method_missing(name, *args)
  # ...
  super
end

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

    if dn_begins_properly?(formatted_dn)
Severity: Minor
Found in lib/dnc/dn.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Re-enable Metrics/ClassLength cop with # rubocop:enable after disabling it.
Open

# rubocop:disable ClassLength
Severity: Minor
Found in lib/dnc/dn.rb by rubocop

Avoid rescuing without specifying an error class.
Open

  rescue
Severity: Minor
Found in lib/dnc/dn.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

%w-literals should be delimited by [ and ].
Open

    @string_order   = opts[:string_order] || %w(cn l st o ou c street dc uid)
Severity: Minor
Found in lib/dnc/dn.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

There are no issues that match your filters.

Category
Status