Showing 10 of 10 total issues
Method build_dsl_element
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
def self.build_dsl_element(klass, name, type)
if @@types.has_key?(type)
klass.class_eval do
define_method(name.to_sym) do |*args|
instance_exec('@' + name.to_s, *args, &@@types[type])
- 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 build_dsl_element
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.build_dsl_element(klass, name, type)
if @@types.has_key?(type)
klass.class_eval do
define_method(name.to_sym) do |*args|
instance_exec('@' + name.to_s, *args, &@@types[type])
File maker.rb
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'dsl/maker/version'
require 'docile'
# Children of DSL::Maker are the "control class". All of the classes that inherit
Class Maker
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class DSL::Maker
# This is the base class for all DSL-parsing classes.
class Base
# 21 character method names are obscene. Make it easier to read.
alias :___set :instance_variable_set
Method add_entrypoint
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.add_entrypoint(name, args={}, &defn_block)
symname = name.to_sym
if is_entrypoint?(symname)
raise "'#{name.to_s}' is already an entrypoint"
- 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 deeply nested control flow statements. Open
elsif !args.empty?
rv.concat(
args.flatten.map do |item|
klass.new.instance_exec('@__________', item, &@@types[type.base_type])
end
Avoid deeply nested control flow statements. Open
raise failure if failure
Avoid deeply nested control flow statements. Open
if v = type.base_type.instance_variable_get(:@verifications)
v.each do |verify|
failure = verify.call(dsl_value)
raise failure if failure
end
Method []
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.[](type)
raise "Cannot make an array of an alias" if DSL::Maker.is_alias?(type)
raise "Unknown type provided to ArrayOf" unless @@types.has_key?(type) || DSL::Maker.is_dsl?(type)
@@arrays[type] ||= ArrayType.new(type)
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 base_class
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.base_class
# This is the only time we *know* that the :default helper doesn't exist yet.
unless @base_class
@base_class = Class.new(DSL::Maker::Base)
add_helper(:default) do |method_name, args, position=0|
- 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"