SpontaneousCMS/spontaneous

View on GitHub
lib/spontaneous/publishing/revision.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Revision has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Revision
    class InvalidRevision < Spontaneous::Error; end

    class Generator
      attr_reader :modified_pages
Severity: Minor
Found in lib/spontaneous/publishing/revision.rb - About 5 hrs to fix

    File revision.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
    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)
    Severity: Minor
    Found in lib/spontaneous/publishing/revision.rb - About 3 hrs to fix

      Class Generator has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Generator
            attr_reader :modified_pages
      
            # Both revision & source_revision should be instances of Revision
            def initialize(revision)
      Severity: Minor
      Found in lib/spontaneous/publishing/revision.rb - About 2 hrs to fix

        Method create_content_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        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 }
        Severity: Minor
        Found in lib/spontaneous/publishing/revision.rb - About 35 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