dvinciguerra/business-br

View on GitHub

Showing 123 of 123 total issues

Business::BR::CPF#validate calls 'cpf.length' 2 times
Open

      return false unless cpf.length == 11 || cpf.length == 14
Severity: Minor
Found in lib/business-br/cpf.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Business::BR::CEP::Providers has no descriptive comment
Open

      class Providers
Severity: Minor
Found in lib/business-br/cep/providers.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

Business::BR::CPF declares the class variable '@@black_list'
Open

    @@black_list = %w[
      00000000000
      11111111111
      22222222222
      33333333333
Severity: Minor
Found in lib/business-br/cpf.rb by reek

Class variables form part of the global runtime state, and as such make it easy for one part of the system to accidentally or inadvertently depend on another part of the system. So the system becomes more prone to problems where changing something over here breaks something over there. In particular, class variables can make it hard to set up tests (because the context of the test includes all global state).

For a detailed explanation, check out this article

Example

Given

class Dummy
  @@class_variable = :whatever
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Dummy declares the class variable @@class_variable (ClassVariable)

Getting rid of the smell

You can use class-instance variable to mitigate the problem (as also suggested in the linked article above):

class Dummy
  @class_variable = :whatever
end

Business::BR::CNPJ#validate calls 'cnpj.length' 2 times
Open

      return false unless cnpj.length == 14 || cnpj.length == 18
Severity: Minor
Found in lib/business-br/cnpj.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Business::BR::CPF#validate calls 'cpf[i]' 2 times
Open

        first_num += (10 - i) * cpf[i].to_i
      end

      10.times do |i|
        second_num += (11 - i) * cpf[i].to_i
Severity: Minor
Found in lib/business-br/cpf.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Business::BR::CNPJ#validate calls 'cnpj[i].to_i' 2 times
Open

        first_num += numbers[i + 1] * cnpj[i].to_i
      end

      13.times do |i|
        second_num += numbers[i] * cnpj[i].to_i
Severity: Minor
Found in lib/business-br/cnpj.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Business::BR::CEP::Providers::Base has no descriptive comment
Open

        class Base
Severity: Minor
Found in lib/business-br/cep/providers/base.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

Business::BR::CEP#validate calls 'cep.length' 2 times
Open

      return false unless cep.length == 8 || cep.length == 9
Severity: Minor
Found in lib/business-br/cep.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Business::BR::CEP::Providers::Postmon has no descriptive comment
Open

        class Postmon < Base

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

Business::BR::CNPJ has no descriptive comment
Open

  class CNPJ
Severity: Minor
Found in lib/business-br/cnpj.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

Avoid too many return statements within this method.
Open

      return false unless cpf[9..10] == "#{first_num}#{second_num}"
Severity: Major
Found in lib/business-br/cpf.rb - About 30 mins to fix

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

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

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

    Block has too many lines. [26/25]
    Open

    Gem::Specification.new do |spec|
      spec.name          = 'business-br'
      spec.license       = 'MIT'
      spec.version       = Business::BR::VERSION
      spec.authors       = ['Daniel Vinciguerra']
    Severity: Minor
    Found in business-br.gemspec by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Business::BR::CEP::Providers::Base#zipcode is a writable attribute
    Open

              attr_accessor :zipcode
    Severity: Minor
    Found in lib/business-br/cep/providers/base.rb by reek

    A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

    The same holds to a lesser extent for getters, but Reek doesn't flag those.

    Example

    Given:

    class Klass
      attr_accessor :dummy
    end

    Reek would emit the following warning:

    reek test.rb
    
    test.rb -- 1 warning:
      [2]:Klass declares the writable attribute dummy (Attribute)

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

        def normalize(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.

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

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

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

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

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

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

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

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

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

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

              def decode_json(str)
    Severity: Minor
    Found in lib/business-br/cep/providers/base.rb by reek

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

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

        def validate(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.

    Severity
    Category
    Status
    Source
    Language