Showing 48 of 48 total issues
Method go
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def go(s, args = ARGV, defaults: {})
d = defaults || {}
b, v = s.scan(/(.)(:?)/).inject([ {}, {} ]) { |t, (o, a)|
a = a == ?:
t[a ? 1 : 0][o] = a ? nil : false
- 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
File dslkit.rb
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'thread'
require 'sync'
require 'tins/thread_local'
Method find
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def find(*paths)
block_given? or return enum_for(__method__, *paths)
paths.collect! { |d| d.dup }
while path = paths.shift
path = prepare_path(path)
- 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 dsl_accessor
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def dsl_accessor(name, *default, &block)
variable = "@#{name}"
define_method(name) do |*args|
if args.empty?
result =
- 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 attempt
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def attempt(opts = {}, &block)
sleep = nil
exception_class = StandardError
prev_exception = nil
if Numeric === opts
- 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 go
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def go(s, args = ARGV, defaults: {})
d = defaults || {}
b, v = s.scan(/(.)(:?)/).inject([ {}, {} ]) { |t, (o, a)|
a = a == ?:
t[a ? 1 : 0][o] = a ? nil : false
Method subhash
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def subhash(*patterns)
patterns.map! do |pat|
pat = pat.to_sym.to_s if pat.respond_to?(:to_sym)
pat.respond_to?(:match) ? pat : pat.to_s
end
- 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 dsl_reader
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def dsl_reader(name, *default, &block)
variable = "@#{name}"
define_method(name) do |*args|
if args.empty?
result =
- 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
File turing.rb
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'term/ansicolor'
require 'tins'
module Turing
class Tape
Method included
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(modul)
class << modul
alias really_new new
alias really_now now
Method memoize_function
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def memoize_function(*function_ids)
function_ids.extend(ExtractLastArgumentOptions)
function_ids, opts = function_ids.extract_last_argument_options
mc = __memoize_cache__
function_ids.each do |function_id|
- 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 description
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def description(style: :namespace)
valid_styles = %i[ namespace name parameters ]
valid_styles.include?(style) or
raise ArgumentError,
"style has to be one of #{valid_styles * ', '}"
- 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 memoize_method
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def memoize_method(*method_ids)
method_ids.extend(ExtractLastArgumentOptions)
method_ids, opts = method_ids.extract_last_argument_options
include CacheMethods
method_ids.each do |method_id|
- 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 attempt
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attempt(opts = {}, &block)
sleep = nil
exception_class = StandardError
prev_exception = nil
if Numeric === opts
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Tins
module DateTimeDummy
def self.included(modul)
class << modul
alias really_now now
- 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 72.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Tins
module DateDummy
def self.included(modul)
class << modul
alias really_today today
- 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 72.
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 included
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(modul)
class << modul
alias really_today today
remove_method :today rescue nil
Method included
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(modul)
class << modul
alias really_now now
remove_method :now rescue nil
Method with
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.with(*ids)
opts = Hash === ids.last ? ids.pop : {}
ids = ids.map { |id| Regexp === id ? id : id.to_s }
klass = opts[:superclass] ? Class.new(opts[:superclass]) : Class.new
klass.instance_eval do
- 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 deep_const_get
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.deep_const_get(path, start_module = Object)
path.to_s.split('::').inject(start_module) do |p, c|
case
when c.empty?
if start_module == Object
- 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"