lib/midb/serverengine_controller.rb
Method start
has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring. Open
Open
def start(port=8081)
serv = TCPServer.new("localhost", port)
MIDB::Interface::Server.info(:start, port)
# Manage the requests
- Read upRead up
- Create a ticketCreate a ticket
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 start
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def start(port=8081)
serv = TCPServer.new("localhost", port)
MIDB::Interface::Server.info(:start, port)
# Manage the requests
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
case endpoint.length
when 2
# No ID has been specified. Return all the entries
# Pass it to the model and get the JSON
MIDB::Interface::Server.info(:fetch, "get_all_entries()")
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
elsif method == "POST"
MIDB::Interface::Server.info(:fetch, "post(#{data})")
response_json = dbop.post(data).to_json
else
if endpoint.length >= 3
- Create a ticketCreate a ticket