ifad/chronomodel

View on GitHub

Showing 17 of 469 total issues

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

      def timeline(record = nil, options = {})
        rid = record.respond_to?(:rid) ? record.rid : record.id if record

        assocs = options.key?(:with) ?
          timeline_associations_from(options[:with]) : timeline_associations
Severity: Minor
Found in lib/chrono_model/time_machine/timeline.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 chronomodel_connection has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def chronomodel_connection(config) # :nodoc:
      conn_params = config.symbolize_keys

      conn_params.delete_if { |_, v| v.nil? }

Severity: Minor
Found in lib/active_record/connection_adapters/chronomodel_adapter.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 timeline has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def timeline(record = nil, options = {})
        rid = record.respond_to?(:rid) ? record.rid : record.id if record

        assocs = options.key?(:with) ?
          timeline_associations_from(options[:with]) : timeline_associations
Severity: Minor
Found in lib/chrono_model/time_machine/timeline.rb - About 1 hr to fix

    Method chrono_upgrade_from_postgres_9_0 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def chrono_upgrade_from_postgres_9_0(table_name)
              # roses are red
              # violets are blue
              # and this is the most boring piece of code ever
              history_table = "#{HISTORY_SCHEMA}.#{table_name}"
    Severity: Minor
    Found in lib/chrono_model/adapter/upgrade.rb - About 1 hr to fix

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

            def change_table(table_name, options = {}, &block)
              transaction do
      
                # Add an empty proc to support calling change_table without a block.
                #
      Severity: Minor
      Found in lib/chrono_model/adapter/migrations.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 chrono_create_UPDATE_trigger has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def chrono_create_UPDATE_trigger(table, pk, current, history, fields, values, options, columns)
      Severity: Major
      Found in lib/chrono_model/adapter/ddl.rb - About 1 hr to fix

        Method chrono_public_view_ddl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def chrono_public_view_ddl(table, options = nil)
                  pk      = primary_key(table)
                  current = [TEMPORAL_SCHEMA, table].join('.')
                  history = [HISTORY_SCHEMA,  table].join('.')
        
        
        Severity: Minor
        Found in lib/chrono_model/adapter/ddl.rb - About 55 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 chrono_create_INSERT_trigger has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def chrono_create_INSERT_trigger(table, pk, current, history, fields, values)
        Severity: Minor
        Found in lib/chrono_model/adapter/ddl.rb - About 45 mins to fix

          Method chrono_tables_needing_upgrade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def chrono_tables_needing_upgrade
                    tables = { }
          
                    on_temporal_schema { self.tables }.each do |table_name|
                      next unless is_chrono?(table_name)
          Severity: Minor
          Found in lib/chrono_model/adapter/upgrade.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

          Method changes_against has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def changes_against(ref)
                self.class.attribute_names_for_history_changes.inject({}) do |changes, attr|
                  old, new = ref.public_send(attr), self.public_send(attr)
          
                  changes.tap do |c|
          Severity: Minor
          Found in lib/chrono_model/time_machine.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

          Method time_query_sql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def time_query_sql(match, time, range, options)
                    case match
                    when :at
                      build_time_query_at(time, range)
          
          
          Severity: Minor
          Found in lib/chrono_model/time_machine/time_query.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

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

              def pred(options = {})
                if self.class.timeline_associations.empty?
                  history.order(Arel.sql('upper(validity) DESC')).offset(1).first
                else
                  return nil unless (ts = pred_timestamp(options))
          Severity: Minor
          Found in lib/chrono_model/time_machine.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

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

              def on_schema(schema, recurse: :follow)
                old_path = self.schema_search_path
          
                count_recursions do
                  if recurse == :follow or Thread.current['recursions'] == 1
          Severity: Minor
          Found in lib/chrono_model/adapter.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

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

                  def chrono_upgrade_structure!
                    transaction do
          
                      chrono_tables_needing_upgrade.each do |table_name, desc|
          
          
          Severity: Minor
          Found in lib/chrono_model/adapter/upgrade.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

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

                  def remove_sql_header_comments(filename)
                    sql_comment_begin = '--'
                    removing_comments = true
                    tempfile = Tempfile.open("uncommented_structure.sql")
                    begin
          Severity: Minor
          Found in lib/active_record/tasks/chronomodel_database_tasks.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

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

                  def extract_bounds(value)
                    from, to = value[1..-2].split(',')
                    {
                      from:          (value[1] == ',' || from == '-infinity') ? nil : from[1..-2],
                      to:            (value[-2] == ',' || to == 'infinity') ? nil : to[1..-2],
          Severity: Minor
          Found in lib/chrono_model/adapter/tsrange.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

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

                  def chrono_create_UPDATE_trigger(table, pk, current, history, fields, values, options, columns)
                    # Columns to be journaled. By default everything except updated_at (GH #7)
                    #
                    journal = if options[:journal]
                      options[:journal].map {|col| quote_column_name(col)}
          Severity: Minor
          Found in lib/chrono_model/adapter/ddl.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

          Severity
          Category
          Status
          Source
          Language