af83/chouette-core

View on GitHub
app/models/referential.rb

Summary

Maintainability
F
3 days
Test Coverage

Class Referential has 92 methods (exceeds 20 allowed). Consider refactoring.
Open

class Referential < ApplicationModel
  prepend ReferentialSaveWithLock

  include DataFormatEnumerations
  include ObjectidFormatterSupport
Severity: Major
Found in app/models/referential.rb - About 1 day to fix

    File referential.rb has 647 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ReferentialSaveWithLock
      def save(options = {})
        super(options)
      rescue ActiveRecord::StatementInvalid => e
        Chouette::Safe.capture "Referential #{name} with slug #{slug} save failed", e
    Severity: Major
    Found in app/models/referential.rb - About 1 day to fix

      Method force_register_models_with_checksum has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.force_register_models_with_checksum
          paths = Rails.application.paths['app/models'].to_a
          Rails.application.railties.each do |tie|
            next unless tie.respond_to? :paths
            paths += tie.paths['app/models'].to_a
      Severity: Minor
      Found in app/models/referential.rb - About 2 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 switch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def switch(verbose: true, &block)
          raise "Referential not created" if new_record?
      
          unless block_given?
            Rails.logger.debug "Referential switch to #{slug}" if verbose
      Severity: Minor
      Found in app/models/referential.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 range_to_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.range_to_string(object)
          from = object.begin.respond_to?(:infinite?) && object.begin.infinite? ? '' : object.begin
          to   = object.end.respond_to?(:infinite?) && object.end.infinite? ? '' : object.end
          "[#{from},#{to}#{object.exclude_end? ? ')' : ']'}"
        end
      Severity: Minor
      Found in app/models/referential.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 overlapped_referential_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def overlapped_referential_ids
          return [] unless metadatas.present?
      
          line_ids = metadatas.first.line_ids
          periodes = metadatas.first.periodes
      Severity: Minor
      Found in app/models/referential.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