ifad/chronomodel

View on GitHub

Showing 469 of 469 total issues

Module has too many lines. [147/100]
Open

    module Migrations
      # Creates the given table, possibly creating the temporal schema
      # objects if the `:temporal` option is given and set to true.
      #
      def create_table(table_name, options = {})

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [135/100]
Open

    module DDL
      private
        # Create the public view and its INSTEAD OF triggers
        #
        def chrono_public_view_ddl(table, options = nil)
Severity: Minor
Found in lib/chrono_model/adapter/ddl.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [107/100]
Open

    module Indexes
      # Create temporal indexes for timestamp search.
      #
      # This index is used by +TimeMachine.at+, `.current` and `.past` to
      # build the temporal WHERE clauses that fetch the state of records at
Severity: Minor
Found in lib/chrono_model/adapter/indexes.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for timeline is too high. [58.83/15]
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

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [36/10]
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

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for chrono_public_view_ddl is too high. [35.67/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [30/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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 has too many lines. [22/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [20/10]
Open

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

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

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for timeline is too high. [16/6]
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

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for chrono_upgrade_from_postgres_9_0 is too high. [25.08/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for chronomodel_connection is too high. [24.78/15]
Open

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

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

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Perceived complexity for timeline is too high. [16/7]
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

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Method has too many lines. [17/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [16/10]
Open

      def change_table(table_name, options = {}, &block)
        transaction do

          # Add an empty proc to support calling change_table without a block.
          #

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [15/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for chrono_upgrade_structure! is too high. [20.2/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for pred is too high. [19.52/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [14/10]
Open

        def remove_sql_header_comments(filename)
          sql_comment_begin = '--'
          removing_comments = true
          tempfile = Tempfile.open("uncommented_structure.sql")
          begin

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Severity
Category
Status
Source
Language