File field_extract.rb
has 890 lines of code (exceeds 250 allowed). Consider refactoring. Open
class BasicPrimitive
attr_accessor :pass_state
attr_accessor :pass_self
attr_accessor :pass_call_frame
attr_accessor :pass_message
Method parse_stream
has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring. Open
def parse_stream(f)
class_pattern = /class\s+([^\s]+)\s*:\s*public\s+([^\s]+)/
slot_pattern = %r!^\s*(\w+)\*?\s+\*?_(\w+)_\s*;\s*//\s*slot(.*)!
accessor_pattern = %r!^\s*attr_(accessor|reader|writer)\((\w+),\s*(\w+)\)!
primitive_pattern = %r%^\s*//\s+Rubinius.primitive([?!\+])?\s+:(.*)\s*$%
- 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 parse_stream
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_stream(f)
class_pattern = /class\s+([^\s]+)\s*:\s*public\s+([^\s]+)/
slot_pattern = %r!^\s*(\w+)\*?\s+\*?_(\w+)_\s*;\s*//\s*slot(.*)!
accessor_pattern = %r!^\s*attr_(accessor|reader|writer)\((\w+),\s*(\w+)\)!
primitive_pattern = %r%^\s*//\s+Rubinius.primitive([?!\+])?\s+:(.*)\s*$%
Method generate_invoke_stub
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_invoke_stub
return if @raw or @pass_arguments
str = ""
if arg_types.empty?
Class CPPClass
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class CPPClass
def initialize(name)
@name = name
@super = nil
@fields = []
Method generate_invoke_stub
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_invoke_stub
return if @raw or @pass_arguments
str = ""
if arg_types.empty?
Method generate_glue
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_glue
str = ""
output_header str
str << " #{@type}* recv = try_as<#{@type}>(args.recv());\n"
Method generate_glue
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_glue
str = ""
if @raw
arg_count = nil
else
Method add_primitive
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_primitive(name, cpp_name, ret, args, overload=false)
prim = CPPPrimitive.new(name, @name)
prim.cpp_name = cpp_name
prim.return_type = ret
prim.arg_types = args
- 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 generate_accessors
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_accessors
str = ""
all_fields.each do |name, type, idx, flags|
str << "Object* Primitives::access_#{@name}_#{name}(STATE, Executable* exec, Module* mod,
Arguments& args) {\n"
Method generate_invoke_stub
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def generate_invoke_stub
return if @raw or @pass_arguments
str = ""
if arg_types.empty?
- 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 output_args
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def output_args(str, arg_types)
unless @pass_arguments
str << " if(unlikely(args.total() != #{arg_types.size}))\n"
str << " goto fail;\n\n"
end
Avoid deeply nested control flow statements. Open
if args.first == "STATE"
args.shift and pass_state = true
# If the second argument is +Object* self+, we will automatically pass
# in the receiver of the primitive message in +output_call+
Avoid deeply nested control flow statements. Open
if m[1]
if overload
raise "Unable to overload static primitives."
end
obj = cpp.add_static_primitive prim, m[3], @type_map[m[2]], arg_types
Avoid deeply nested control flow statements. Open
if raw then
arg_types = []
else
arg_types = args.map do |a|
case a
Avoid deeply nested control flow statements. Open
unless m
raise "Unable to parse: '#{prototype}'"
end
Avoid deeply nested control flow statements. Open
if i = args.index("Arguments& args")
pass_arguments = true
args[i] = :arguments
end
Avoid deeply nested control flow statements. Open
elsif object_size_pattern.match(l)
cpp.class_has_object_size
Method add_primitive
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_primitive(name, cpp_name, ret, args, overload=false)
Method output_args
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def output_args(str, arg_types)
unless @pass_arguments
str << " if(unlikely(args.total() != #{arg_types.size}))\n"
str << " goto fail;\n\n"
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 invoke_primitives
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def invoke_primitives
write_if_new "machine/invoke_primitives.hpp" do |f|
@primitives.each do |n, p|
if p.respond_to? :generate_invoke_stub
code = p.generate_invoke_stub
- 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 generate_invoke_stub
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def generate_invoke_stub
return if @raw or @pass_arguments
str = ""
if arg_types.empty?
- 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 "(#{what}->reference_p() && #{what}->type_id() == #{@name}Type)"
Avoid too many return
statements within this method. Open
return "#{what}->nil_p()"
Method generate_glue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_glue
str = ""
if @raw
arg_count = nil
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def generate_mark
marks = generate_marks(self).rstrip
str = ''
- 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 27.
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
def generate_visit
visits = generate_visits(self).rstrip
str = ''
- 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 27.
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