Showing 27 of 27 total issues
Method help
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.help(what)
case what
when :list
puts "midb v1.1.1 has several commands that you can use. For detailed information, see `midb help command`."
puts " "
- Create a ticketCreate a ticket
Method get_all_entries
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_all_entries()
jso = Hash.new()
# Connect to database
dbe = MIDB::API::Dbengine.new(@engine.config, @db)
- Create a ticketCreate a ticket
Method do_start
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def do_start()
# Check syntax
MIDB::Interface::Errors.die(:syntax) if @args.length < 2
MMIDB::Interface::Errors.die(:syntax) if @args[1].split(":")[0] != "db"
# Is the server already started?
- 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
Avoid deeply nested control flow statements. 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
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
Method do_bootstrap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def do_bootstrap()
if File.file?(".midb.yaml")
MIDB::Interface::Errors.die(:already_project)
else
# If the file doesn't exist it, create it with the default stuff
- 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 do_serve
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def do_serve()
# Check if there's a second argument
MIDB::Interface::Errors.die(:syntax) if @args.length < 2
# Is the server running? It shouldn't
MIDB::Interface::Errors.die(:server_already_started) if @config["status"] == :running
- 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"