SysMO-DB/seek

View on GitHub
lib/explicit_versioning.rb

Summary

Maintainability
D
1 day
Test Coverage

File explicit_versioning.rb has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Jits
  module Acts
    # Based heavily on the acts_as_versioned plugin
    module ExplicitVersioning
      CALLBACKS = [:sync_latest_version]
Severity: Minor
Found in lib/explicit_versioning.rb - About 3 hrs to fix

    Method clone_versioned_model has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

              def clone_versioned_model(orig_model, new_model, process_file_columns=true)
                self.versioned_attributes.each do |key|
                  # Make sure to ignore file columns, white list columns, timestamp columns and any other ignore columns
                  unless self.file_columns.include?(key) ||
                         self.white_list_columns.include?(key) ||
    Severity: Minor
    Found in lib/explicit_versioning.rb - About 3 hrs 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 explicit_versioning has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def explicit_versioning(options = {}, &extension)
              # don't allow multiple calls
              return if self.included_modules.include?(Jits::Acts::ExplicitVersioning::ActMethods)
    
              send :include, Jits::Acts::ExplicitVersioning::ActMethods
    Severity: Minor
    Found in lib/explicit_versioning.rb - About 2 hrs to fix

      Method destroy_version has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              def destroy_version(version_number)
                if (ver = find_version(version_number))
                  without_update_callbacks do
                    # For fault tolerance (ie: to prevent data loss through premature deletion), first...
                    # Check to see if the current (aka latest) version has to be deleted,
      Severity: Minor
      Found in lib/explicit_versioning.rb - About 1 hr 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 clone_versioned_model has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def clone_versioned_model(orig_model, new_model, process_file_columns=true)
                  self.versioned_attributes.each do |key|
                    # Make sure to ignore file columns, white list columns, timestamp columns and any other ignore columns
                    unless self.file_columns.include?(key) ||
                           self.white_list_columns.include?(key) ||
      Severity: Minor
      Found in lib/explicit_versioning.rb - About 1 hr to fix

        Method update_version has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def update_version(version_number_to_update, attributes)
                  return false if version_number_to_update.nil? or version_number_to_update.to_i < 1
                  return false if attributes.nil? or attributes.empty?
                  return false unless (ver = find_version(version_number_to_update))
        
        
        Severity: Minor
        Found in lib/explicit_versioning.rb - About 1 hr 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 update_timestamps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def update_timestamps(from, to)
                    begin
                      ["updated_at"].each do |key|
                        if to.has_attribute?(key)
                          logger.debug("explicit_versioning - update_timestamps method - setting timestamp_column '#{key}'")
        Severity: Minor
        Found in lib/explicit_versioning.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

        Avoid too many return statements within this method.
        Open

                    return false
        Severity: Major
        Found in lib/explicit_versioning.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                        return true
          Severity: Major
          Found in lib/explicit_versioning.rb - About 30 mins to fix

            Method create_versioned_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                      def create_versioned_table(create_table_options = {})
                        # create version column in main table if it does not exist
                        if !self.content_columns.find { |c| %w(version lock_version).include? c.name }
                          self.connection.add_column table_name, :version, :integer, :default=>1
                        end
            Severity: Minor
            Found in lib/explicit_versioning.rb - About 25 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