Showing 419 of 503 total issues
Method /
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def /(other)
if ::Complex === other
if (::Number === @real && @real.nan?) || (::Number === @imag && @imag.nan?) ||
(::Number === other.real && other.real.nan?) || (::Number === other.imag && other.imag.nan?)
::Complex.new(::Float::NAN, ::Float::NAN)
- 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 initialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(range, step = undefined, creation_method = :step)
@creation_method = creation_method
if range.is_a? ::Array
@step_arg1, @step_arg2, @topfx, @bypfx = *range
@receiver_num = step
- 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 cycle
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def cycle(n = nil, &block)
unless block_given?
return enum_for(:cycle, n) do
if n.nil?
::Float::INFINITY
- 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 compile_to_directory
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def compile_to_directory(dir = nil, single_file: nil, with_source_map: true)
raise ArgumentError, 'no directory provided' if dir.nil? && single_file.nil?
catch(:file) do
index = []
- 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 compile_body_or_shortcut
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def compile_body_or_shortcut
# The shortcuts don't check arity. If we want to check arity,
# we can't use them.
return compile_body if compiler.arity_check?
- 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 fork_entrypoint
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def fork_entrypoint(io)
# Ensure we can work with our forks async...
Fiber.set_scheduler(nil) if Fiber.respond_to? :set_scheduler
@in_fork = io
- 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 compile
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def compile
is_lambda! if scope.lambda_definition?
compile_body_or_shortcut
- 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 DelegateClass
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def DelegateClass(superclass, &block)
klass = Class.new(Delegator)
ignores = [*::Delegator.public_api, :to_s, :inspect, :=~, :!~, :===]
protected_instance_methods = superclass.protected_instance_methods
protected_instance_methods -= ignores
- 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 relative_path_from
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def relative_path_from(base_directory)
dest_directory = cleanpath.to_s
base_directory = base_directory.cleanpath.to_s
dest_prefix = dest_directory
dest_names = []
- 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
Function hash
has 44 lines of code (exceeds 30 allowed). Consider refactoring. Open
Opal.hash = function () {
var arguments_length = arguments.length,
args,
hash,
i,
Method ==
has 43 lines of code (exceeds 30 allowed). Consider refactoring. Open
def ==(other)
%x{
var recursed = {};
function _eqeq(array, other) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (Opal.is_method(prop)) {
var method = proto[prop];
if (!method.$$stub) {
var method_name = prop.slice(1);
- 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 65.
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
if (Opal.is_method(prop)) {
var method = proto[prop];
if (!method.$$stub) {
var method_name = prop.slice(1);
- 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 65.
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
Method pack
has 42 lines of code (exceeds 30 allowed). Consider refactoring. Open
def pack(format)
format = ::Opal.coerce_to!(format, ::String, :to_str).gsub(/\s/, '').delete("\000")
%x{
var output = '';
Method initialize
has 42 lines of code (exceeds 30 allowed). Consider refactoring. Open
def initialize a
raise TypeError, "Expected Matrix but got #{a.class}" unless a.is_a?(Matrix)
# Use a "left-looking", dot-product, Crout/Doolittle algorithm.
@lu = a.to_a
@row_count = a.row_count
Method cycle
has 41 lines of code (exceeds 30 allowed). Consider refactoring. Open
def cycle(n = nil, &block)
unless block_given?
return enum_for(:cycle, n) do
if n.nil?
respond_to?(:size) ? ::Float::INFINITY : nil
Method gets
has 41 lines of code (exceeds 30 allowed). Consider refactoring. Open
def gets(sep = false, limit = nil, opts = {})
if `sep.$$is_number` && !limit
sep, limit, opts = false, sep, limit
end
if `sep.$$is_hash` && !limit && opts == {}
Method product
has 41 lines of code (exceeds 30 allowed). Consider refactoring. Open
def product(*args, &block)
%x{
var result = #{block_given?} ? null : [],
n = args.length + 1,
counters = new Array(n),
Method include?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def include?(val)
if `self.begin.$$is_number || self.end.$$is_number` ||
@begin.is_a?(::Time) || @end.is_a?(::Time) ||
::Integer.try_convert(@begin) || ::Integer.try_convert(@end)
return cover?(val)
- 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 any?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def any?(pattern = undefined, &block)
if `pattern !== undefined`
each do |*value|
comparable = `comparableForPattern(value)`
- 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"