dvinciguerra/business-br

View on GitHub

Showing 123 of 123 total issues

Line is too long. [87/80]
Open

      second_num = second_num < 2 ? 0 : (11 - second_num) == 10 ? 1 : (11 - second_num)
Severity: Minor
Found in lib/business-br/cnpj.rb by rubocop

Line is too long. [105/80]
Open

        "#{Regexp.last_match(1)}.#{Regexp.last_match(2)}.#{Regexp.last_match(3)}-#{Regexp.last_match(4)}"
Severity: Minor
Found in lib/business-br/cpf.rb by rubocop

Do not place comments on the same line as the end keyword.
Open

    end # CEP

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

Use nested module/class definitions instead of compact style.
Open

module Business::BR
Severity: Minor
Found in lib/business-br/cnpj.rb by rubocop

This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

Example: EnforcedStyle: nested (default)

# good
# have each child on its own line
class Foo
  class Bar
  end
end

Example: EnforcedStyle: compact

# good
# combine definitions as much as possible
class Foo::Bar
end

The compact style is only forced for classes/modules with one child.

Use nested module/class definitions instead of compact style.
Open

module Business::BR
Severity: Minor
Found in lib/business-br/cpf.rb by rubocop

This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

Example: EnforcedStyle: nested (default)

# good
# have each child on its own line
class Foo
  class Bar
  end
end

Example: EnforcedStyle: compact

# good
# combine definitions as much as possible
class Foo::Bar
end

The compact style is only forced for classes/modules with one child.

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

      if cpf =~ /^(\d{3})\.?(\d{3})\.?(\d{3})-?(\d{2})$/
Severity: Minor
Found in lib/business-br/cpf.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

Line is too long. [113/80]
Open

            response = Faraday.get("http://cep.republicavirtual.com.br/web_cep.php?cep=#{@zipcode}&formato=json")

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

      if cnpj =~ %r{^(\d{2})\.?(\d{3})\.?(\d{3})/?(\d{4})-?(\d{2})$}
Severity: Minor
Found in lib/business-br/cnpj.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

Use %q only for strings that contain both single quotes and double quotes.
Open

  spec.description = %q[
    Business::BR is a namespace to place all validations like CPF CNPJ CEP and
    some other things to be used in a brazilian ruby project.
  ]
Severity: Minor
Found in business-br.gemspec by rubocop

Do not place comments on the same line as the end keyword.
Open

      end # Providers
Severity: Minor
Found in lib/business-br/cep/providers.rb by rubocop

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

Replace class var @@regions with a class instance var.
Open

    @@regions = [
Severity: Minor
Found in lib/business-br/cep.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Missing top-level class documentation comment.
Open

  class CEP
Severity: Minor
Found in lib/business-br/cep.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Replace class var @@black_list with a class instance var.
Open

    @@black_list = %w[
Severity: Minor
Found in lib/business-br/cpf.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

      if cep_provider = Business::BR::CEP::Providers.get_provider(provider)
Severity: Minor
Found in lib/business-br/cep.rb by rubocop

This cop checks for assignments in the conditions of if/while/until.

Example:

# bad

if some_var = true
  do_something
end

Example:

# good

if some_var == true
  do_something
end

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

      if cep =~ /^(\d{5})-?(\d{3})$/
Severity: Minor
Found in lib/business-br/cep.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

Do not place comments on the same line as the end keyword.
Open

  end # BR
Severity: Minor
Found in lib/business-br/cep/providers.rb by rubocop

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

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

      if cnpj =~ %r{^(\d{2})\.?(\d{3})\.?(\d{3})/?(\d{4})-?(\d{2})$}
Severity: Minor
Found in lib/business-br/cnpj.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

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

      if cep =~ /^(\d{5})-?(\d{3})$/
Severity: Minor
Found in lib/business-br/cep.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

Ternary operators must not be nested. Prefer if or else constructs instead.
Open

      second_num = second_num < 2 ? 0 : (11 - second_num) == 10 ? 1 : (11 - second_num)
Severity: Minor
Found in lib/business-br/cnpj.rb by rubocop

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

if infor = cep.search_by('12345678')
Severity: Minor
Found in examples/cep.rb by rubocop

This cop checks for assignments in the conditions of if/while/until.

Example:

# bad

if some_var = true
  do_something
end

Example:

# good

if some_var == true
  do_something
end
Severity
Category
Status
Source
Language