locaweb/cassette

View on GitHub
lib/cassette/authentication/authorities.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Use tr instead of gsub.
Open

        has_raw_role?("#{base}_#{role.to_s.upcase.gsub('_', '-')}")

This cop identifies places where gsub can be replaced by tr or delete.

Example:

# bad
'abc'.gsub('b', 'd')
'abc'.gsub('a', '')
'abc'.gsub(/a/, 'd')
'abc'.gsub!('a', 'd')

# good
'abc'.gsub(/.*/, 'a')
'abc'.gsub(/a+/, 'd')
'abc'.tr('b', 'd')
'a b c'.delete(' ')

Unnecessary utf-8 encoding comment.
Open

# encoding: UTF-8

Rename has_raw_role? to raw_role?.
Open

      def has_raw_role?(role)

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Rename has_role? to role?.
Open

      def has_role?(role)

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Use the return of the conditional for variable assignment and comparison.
Open

        if authorities.is_a?(String)
          @authorities = authorities.gsub(/^\[(.*)\]$/, '\\1').split(',').map(&:strip)
        else
          @authorities = Array(authorities).map(&:strip)
        end

There are no issues that match your filters.

Category
Status