Showing 56 of 56 total issues
Method parse_one
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_one(char, for_array: false)
res = nil
case char
when "a"
res = Type.new(ARRAY)
Method <<
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def <<(item)
raise ArgumentError unless item.is_a?(Type)
if ![STRUCT, ARRAY, DICT_ENTRY].member?(@sigtype)
raise SignatureException
- 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
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse
# Using a Hash instead of a list helps merge split-up interfaces,
# a quirk observed in ModemManager (I#41).
interfaces = Hash.new do |hash, missing_key|
hash[missing_key] = Interface.new(missing_key)
Method unmarshall_buffer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def unmarshall_buffer(buf)
pu = PacketUnmarshaller.new(buf, RawMessage.endianness(buf[0]))
mdata = pu.unmarshall(MESSAGE_SIGNATURE)
_, @message_type, @flags, @protocol, @body_length, @serial,
headers = mdata
Method dispatch
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dispatch(msg)
case msg.message_type
when Message::METHOD_CALL
reply = nil
begin
Method define_method_from_descriptor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def define_method_from_descriptor(method)
method.params.each do |fpar|
par = fpar.type
# This is the signature validity check
Type::Parser.new(par).parse
Method read_line
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def read_line
# TODO: probably can simply call @socket.readline
data = ""
crlf = "\r\n"
left = 1024 # 1024 byte, no idea if it's ever getting bigger
- 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 pop
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def pop(blocking: true)
# FIXME: this is not enough, the R/W test deadlocks on shared connections
@mutex.synchronize do
buffer_from_socket_nonblock
message = message_from_buffer_nonblock
- 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 request_name
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def request_name(name,
allow_replacement: false,
replace_existing: false,
queue: false,
flags: nil)
- 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 call
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(challenge)
if challenge.nil?
require "etc"
# number of retries we have for auth
@retries = 1
Method marshall
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def marshall
if @path == RESERVED_PATH
# the bus would disconnect us, better explain why
raise "Cannot send a message with the reserved path #{RESERVED_PATH}: #{inspect}"
end
Method send_sync_or_async
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def send_sync_or_async(message, &reply_handler)
ret = nil
if reply_handler.nil?
send_sync(message) do |rmsg|
raise rmsg if rmsg.is_a?(Error)
- 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 define_method_from_descriptor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def define_method_from_descriptor(method)
method.params.each do |fpar|
par = fpar.type
# This is the signature validity check
Type::Parser.new(par).parse
- 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 next_state
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def next_state(received_words)
msg = received_words
case @state
when :WaitingForData
- 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 marshall
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def marshall
if @path == RESERVED_PATH
# the bus would disconnect us, better explain why
raise "Cannot send a message with the reserved path #{RESERVED_PATH}: #{inspect}"
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 unexport
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def unexport(obj_or_path)
path = self.class.path_of(obj_or_path)
parent_path, _separator, node_name = path.rpartition("/")
parent_node = get_node(parent_path, create: 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.dbus_accessor(ruby_name, type, dbus_name: nil, emits_changed_signal: nil)
raise UndefinedInterface, ruby_name if @@cur_intf.nil?
dbus_name = make_dbus_name(ruby_name, dbus_name: dbus_name)
property = Property.new(dbus_name, type, :readwrite, ruby_name: ruby_name)
- 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 38.
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 self.dbus_writer(ruby_name, type, dbus_name: nil, emits_changed_signal: nil)
raise UndefinedInterface, ruby_name if @@cur_intf.nil?
dbus_name = make_dbus_name(ruby_name, dbus_name: dbus_name)
property = Property.new(dbus_name, type, :write, ruby_name: ruby_name)
- 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 38.
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 emit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def emit(_service, obj, intf, sig, *args)
Method validate_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_name(name)
raise InvalidIntrospectionData if name.bytesize > 255
raise InvalidIntrospectionData if name =~ /^\./ || name =~ /\.$/
raise InvalidIntrospectionData if name =~ /\.\./
raise InvalidIntrospectionData 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"