app/lib/morph/database.rb
Class Database
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Database
extend T::Sig
CORRUPT_DATABASE_EXCEPTIONS = T.let([
SQLite3::NotADatabaseException,
SQLite3::CorruptException,
Method add_database_type_translations
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def add_database_type_translations(db)
# Don't error on dates that are FixNum and that don't parse
%w[date datetime].each do |type|
db.translator.add_translator(type) do |t, v|
case t.downcase
- 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 clean_utf8_string
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.clean_utf8_string(string)
if string.respond_to?(:encode)
if string.valid_encoding?
# Actually try converting to utf-8 and check if that works
begin
- 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"