dvinciguerra/business-br

View on GitHub

Showing 123 of 123 total issues

Business::BR::CEP#format doesn't depend on instance state (maybe move it to another class?)
Open

    def format(cep)
Severity: Minor
Found in lib/business-br/cep.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

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

    def type(cep)
      cep = normalize(cep)
      suffix = cep.slice(5, 3).to_i
      if suffix < 900 then 'LOGRADOURO'
      elsif suffix < 960 then 'ESPECIAL'
Severity: Minor
Found in lib/business-br/cep.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

Business::BR::CEP#search_by doesn't depend on instance state (maybe move it to another class?)
Open

    def search_by(cep, provider: 'Postmon')
Severity: Minor
Found in lib/business-br/cep.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Business::BR::CEP::Providers::RepublicaVirtual#search_by has the variable name 'e'
Open

          rescue Faraday::ClientError => e

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Business::BR::CNPJ#validate has the variable name 'i'
Open

      12.times do |i|
        first_num += numbers[i + 1] * cnpj[i].to_i
      end

      13.times do |i|
Severity: Minor
Found in lib/business-br/cnpj.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Business::BR::CPF#validate has the variable name 'i'
Open

      9.times do |i|
        first_num += (10 - i) * cpf[i].to_i
      end

      10.times do |i|
Severity: Minor
Found in lib/business-br/cpf.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Business::BR::CEP::Providers::Postmon#search_by has the variable name 'e'
Open

            rescue Faraday::ClientError => e

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Script file cep.rb doesn't have execute permission.
Open

#!/usr/bin/env ruby
Severity: Minor
Found in examples/cep.rb by rubocop

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

      end # Providers

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

required_ruby_version (2.7, declared in business-br.gemspec) and TargetRubyVersion (2.1, declared in .rubocop.yml) should be equal.
Open

  spec.required_ruby_version = '>= 2.7'
Severity: Minor
Found in business-br.gemspec by rubocop

Checks that required_ruby_version of gemspec and TargetRubyVersion of .rubocop.yml are equal. Thereby, RuboCop to perform static analysis working on the version required by gemspec.

Example:

# When `TargetRubyVersion` of .rubocop.yml is `2.3`.

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.2.0'
end

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.4.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
end

The name of this source file (business-br.rb) should use snake_case.
Open

# frozen_string_literal: true
Severity: Minor
Found in lib/business-br.rb by rubocop

This cop makes sure that Ruby source files have snake_case names. Ruby scripts (i.e. source files with a shebang in the first line) are ignored.

Example:

# bad
lib/layoutManager.rb

anything/usingCamelCase

# good
lib/layout_manager.rb

anything/using_snake_case.rake

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

  end # BR

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

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

end # Business

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

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

  end # BR

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

Line is too long. [125/80]
Open

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

Useless assignment to variable - cep_region.
Open

cep_region = validator.region(cep) # => ['SP']
Severity: Minor
Found in examples/cep.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

%q-literals should be delimited by ( and ).
Open

  spec.summary       = %q[
    Classes for validations and conversions to use in brazilian ruby projects.
  ]
Severity: Minor
Found in business-br.gemspec 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)

%q-literals should be delimited by ( and ).
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

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)

Missing top-level class documentation comment.
Open

  class CPF
Severity: Minor
Found in lib/business-br/cpf.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

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
Severity
Category
Status
Source
Language