Showing 70 of 70 total issues
Module has too many lines. [268/250] Open
module Constants
URL = {
DEFAULT: {
production: "https://api.gerencianet.com.br/v1",
sandbox: "https://sandbox.gerencianet.com.br/v1"
- Read upRead up
- Exclude checks
This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for authenticate is too high. [34.66/15] Open
def authenticate
if (@options.has_key?(:pix_cert))
url = get_url({}, @endpoints[:PIX][:authorize][:route])
else
url = get_url({}, @endpoints[:DEFAULT][:authorize][:route])
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for make_request is too high. [28.44/15] Open
def make_request(params, body, settings)
url = get_url(params, settings[:route])
headers = {
"accept" => "application/json",
"api-sdk" => "ruby-#{Gerencianet::VERSION}"
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [32/20] Open
def authenticate
if (@options.has_key?(:pix_cert))
url = get_url({}, @endpoints[:PIX][:authorize][:route])
else
url = get_url({}, @endpoints[:DEFAULT][:authorize][:route])
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [29/20] Open
def make_request(params, body, settings)
url = get_url(params, settings[:route])
headers = {
"accept" => "application/json",
"api-sdk" => "ruby-#{Gerencianet::VERSION}"
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
File constants.rb
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Gerencianet
# Endpoints signatures
module Constants
URL = {
DEFAULT: {
Assignment Branch Condition size for create_methods is too high. [15.03/15] Open
def create_methods
if (@options.has_key?(:pix_cert))
@endpoints[:PIX].each do |key, settings|
self.class.send(:define_method, key) do |args = {}|
create(args[:params], args[:body], settings)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method authenticate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate
if (@options.has_key?(:pix_cert))
url = get_url({}, @endpoints[:PIX][:authorize][:route])
else
url = get_url({}, @endpoints[:DEFAULT][:authorize][:route])
Method make_request
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def make_request(params, body, settings)
url = get_url(params, settings[:route])
headers = {
"accept" => "application/json",
"api-sdk" => "ruby-#{Gerencianet::VERSION}"
Method current_base_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def current_base_url
if (@options.has_key?(:pix_cert))
@options[:sandbox] ? @urls[:PIX][:sandbox] : @urls[:PIX][:production]
else
@options[:sandbox] ? @urls[:DEFAULT][:sandbox] : @urls[:DEFAULT][:production]
- Read upRead up
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
Method authenticate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def authenticate
if (@options.has_key?(:pix_cert))
url = get_url({}, @endpoints[:PIX][:authorize][:route])
else
url = get_url({}, @endpoints[:DEFAULT][:authorize][:route])
- Read upRead up
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
.post(url, json: auth_body, ssl_context: OpenSSL::SSL::SSLContext.new.tap do |ctx|
ctx.set_params(
cert: OpenSSL::X509::Certificate.new(File.read(@options[:pix_cert])),
key: OpenSSL::PKey::RSA.new(File.read(@options[:pix_cert]))
)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
.call(url, json: body, ssl_context: OpenSSL::SSL::SSLContext.new.tap do |ctx|
ctx.set_params(
cert: OpenSSL::X509::Certificate.new(File.read(@options[:pix_cert])),
key: OpenSSL::PKey::RSA.new(File.read(@options[:pix_cert]))
)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Trailing whitespace detected. Open
create(args[:params], args[:body], settings)
- Exclude checks
Trailing whitespace detected. Open
create(args[:params], args[:body], settings)
- Exclude checks
Freeze mutable objects assigned to constants. Open
URL = {
DEFAULT: {
production: "https://api.gerencianet.com.br/v1",
sandbox: "https://sandbox.gerencianet.com.br/v1"
},
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Freeze mutable objects assigned to constants. Open
VERSION = "1.1.2"
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Use 2 (not 0) spaces for indenting an expression spanning multiple lines. Open
.method(settings[:method])
- Read upRead up
- Exclude checks
This cop checks the indentation of the method name part in method calls that span more than one line.
Example: EnforcedStyle: aligned
# bad
while myvariable
.b
# do something
end
# good
while myvariable
.b
# do something
end
# good
Thing.a
.b
.c
Example: EnforcedStyle: indented
# good
while myvariable
.b
# do something
end
Example: EnforcedStyle: indentedrelativeto_receiver
# good
while myvariable
.a
.b
# do something
end
# good
myvariable = Thing
.a
.b
.c
Don't use parentheses around a method call. Open
if (@options.has_key?(:pix_cert))
- Read upRead up
- Exclude checks
This cop checks for redundant parentheses.
Example:
# bad
(x) if ((y.z).nil?)
# good
x if y.z.nil?
Trailing whitespace detected. Open
- Exclude checks