openaustralia/morph

View on GitHub
app/lib/morph/database.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class Database has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Database
    extend T::Sig
    CORRUPT_DATABASE_EXCEPTIONS = T.let([
      SQLite3::NotADatabaseException,
      SQLite3::CorruptException,
Severity: Minor
Found in app/lib/morph/database.rb - About 3 hrs to fix

    Method add_database_type_translations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in app/lib/morph/database.rb - About 45 mins to fix

    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

        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
    Severity: Minor
    Found in app/lib/morph/database.rb - About 45 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status