Showing 22 of 22 total issues
File optimism.rb
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "optimism/util"
require "optimism/parser"
require "optimism/semantics"
require "optimism/require"
Class Optimism
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Optimism
autoload :VERSION, "optimism/version"
Error = Class.new Exception
EMissingFile = Class.new Error
Method method_missing
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(name, *args, &blk)
return super if UNDEF_METHODS.include?(name)
# relative path: __
if name =~ /^__+$/
- 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 require_env
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def require_env(*args, &blk)
# e.g. OPTIMISM_A OPTIMISM_B for /OPTIMISM_(.*)/
# args => { 'A' => 'value' }
Hash === args.last ? opts = args.pop : 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 scan
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def scan(content, &blk)
return to_enum(:scan, content) unless blk
last_indent = 0
content.scan(/(.*?)(\n+|\Z)/).each { |line, newline|
- 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 find_file
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_file(name, opts={})
path = ""
# ~/.gutenrc or ./relative/path or ../relative/path
if name =~ %r!^~|^\.\.?/!
- 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 _fetch
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _fetch(*args)
if args.length == 1 then
path_s = args[0]
raise_error = true
else
- 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 scan
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scan(content, &blk)
return to_enum(:scan, content) unless blk
last_indent = 0
content.scan(/(.*?)(\n+|\Z)/).each { |line, newline|
Method evaluate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def evaluate
script = ""
indent_counts = 0
block_indent_counts = []
block_index = 0
Method method_missing
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def method_missing(name, *args, &blk)
return super if UNDEF_METHODS.include?(name)
# relative path: __
if name =~ /^__+$/
Method _fetch
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _fetch(*args)
if args.length == 1 then
path_s = args[0]
raise_error = true
else
Method require_file
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def require_file(*paths)
paths, optimism_opts = Util.extract_options(paths, merge: :replace)
opts = [:merge, :raise].each.with_object({}){|n, m|
m[n] = optimism_opts.delete(n)
}
- 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 _convert_hash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _convert_hash(hash, opts={})
o = Optimism.new(nil, opts)
hash.each { |k, v|
v = _convert_hash(v, opts.merge(name: k.to_s, parent: o)) if Hash === v
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(content=nil, options={}, &blk)
@options = {symbolize_key: true}.merge(options)
@_parser = case (p=options[:parser])
when Symbol
- 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
Avoid too many return
statements within this method. Open
return !! _data[$1.to_sym]
Avoid too many return
statements within this method. Open
return _create_child_node(name, args[0], &blk)
Avoid too many return
statements within this method. Open
return _data.__send__(name, *args, &blk)
Method _symbolize_keys!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _symbolize_keys!(hash)
hash.keys.each do |key, value|
value = hash.delete(key)
_symbolize_keys!(value) if Hash === 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"
Further reading
Method require_input
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def require_input(msg, path, o={}, &blk)
default = o[:default] ? "(#{o[:default]})" : ""
print msg+default
value = gets.strip
value = value.empty? ? o[:default] : 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"
Further reading
Method _walk_up
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _walk_up(path, opts={})
node = self
nodes = path.split(".")
nodes.reverse! if opts[:reverse]
- 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"