lib/spontaneous/publishing/revision.rb
Class Revision
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Revision
class InvalidRevision < Spontaneous::Error; end
class Generator
attr_reader :modified_pages
File revision.rb
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module Spontaneous::Publishing
def self.create_content_table(db, source_table, dest_table_name)
# sqlite doesn't like it if you create a table with no columns
# so hard-code the id column (but don't make it a pk because the
# unique constraint isn't useful at this stage)
Class Generator
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Generator
attr_reader :modified_pages
# Both revision & source_revision should be instances of Revision
def initialize(revision)
Method create_content_table
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.create_content_table(db, source_table, dest_table_name)
# sqlite doesn't like it if you create a table with no columns
# so hard-code the id column (but don't make it a pk because the
# unique constraint isn't useful at this stage)
schema = db.schema(source_table).dup.delete_if { |col, opts| col == :id }
- 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"