af83/chouette-core

View on GitHub
app/models/chouette/journey_pattern.rb

Summary

Maintainability
C
1 day
Test Coverage

Method state_update has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def self.state_update route, state
      transaction do
        state.each do |item|
          item.delete('errors')
          jp = find_by(objectid: item['object_id']) || state_create_instance(route, item)
Severity: Minor
Found in app/models/chouette/journey_pattern.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

Class JourneyPattern has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

  class JourneyPattern < Chouette::TridentActiveRecord
    has_metadata
    include ChecksumSupport
    include CustomFieldsSupport
    include ObjectidSupport
Severity: Minor
Found in app/models/chouette/journey_pattern.rb - About 3 hrs to fix

    File journey_pattern.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Chouette
      class JourneyPattern < Chouette::TridentActiveRecord
        has_metadata
        include ChecksumSupport
        include CustomFieldsSupport
    Severity: Minor
    Found in app/models/chouette/journey_pattern.rb - About 2 hrs to fix

      Method full_schedule? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def full_schedule?
            full = true
            stop_points.sort_by(&:position).inject(nil) do |start, finish|
              next finish unless start.present?
              costs = costs_between(start, finish)
      Severity: Minor
      Found in app/models/chouette/journey_pattern.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 all_costs_values_must_be_positive has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          validate def all_costs_values_must_be_positive
            unless costs.empty?
              invalid_distances = false
              invalid_times = false
              costs.values.each do |val|
      Severity: Minor
      Found in app/models/chouette/journey_pattern.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 shortcuts_update_for_add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def shortcuts_update_for_add( stop_point)
            return if skip_save_shortcuts?
      
            stop_points << stop_point unless stop_points.include?( stop_point)
      
      
      Severity: Minor
      Found in app/models/chouette/journey_pattern.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