af83/chouette-core

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

Summary

Maintainability
F
3 days
Test Coverage

File vehicle_journey.rb has 545 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Chouette
  class VehicleJourney < Chouette::TridentActiveRecord
    has_metadata
    include ChecksumSupport
    include CustomFieldsSupport
Severity: Major
Found in app/models/chouette/vehicle_journey.rb - About 1 day to fix

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

        def fill_passing_times!
          encountered_empty_vjas = []
          previous_stop = nil
          vehicle_journey_at_stops.each do |vjas|
            sp = vjas.stop_point
    Severity: Minor
    Found in app/models/chouette/vehicle_journey.rb - About 4 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 VehicleJourney has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

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

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

          def self.state_update route, state
            objects = []
            transaction do
              state.each do |item|
                item.delete('errors')
      Severity: Minor
      Found in app/models/chouette/vehicle_journey.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 fill_passing_times! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def fill_passing_times!
            encountered_empty_vjas = []
            previous_stop = nil
            vehicle_journey_at_stops.each do |vjas|
              sp = vjas.stop_point
      Severity: Minor
      Found in app/models/chouette/vehicle_journey.rb - About 1 hr to fix

        Method merge_flattened_periods has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def merge_flattened_periods periods
              return [trim_period(periods.last)].compact unless periods.size > 1
        
              merged = []
              current = periods[0]
        Severity: Minor
        Found in app/models/chouette/vehicle_journey.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 flattened_circulation_periods has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def flattened_circulation_periods
              periods = time_tables.map(&:periods).flatten
              out = []
              dates = periods.map {|p| [p.period_start, p.period_end + 1.day]}
        
        
        Severity: Minor
        Found in app/models/chouette/vehicle_journey.rb - About 1 hr to fix

          Method checksum_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def checksum_attributes(db_lookup = true)
                [].tap do |attrs|
                  attrs << self.published_journey_name
                  attrs << self.published_journey_identifier
                  loaded_company = association(:company).loaded? ? company : company_light
          Severity: Minor
          Found in app/models/chouette/vehicle_journey.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 state_update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.state_update route, state
                objects = []
                transaction do
                  state.each do |item|
                    item.delete('errors')
          Severity: Minor
          Found in app/models/chouette/vehicle_journey.rb - About 1 hr to fix

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

                def update_vjas_from_state state
                  state.each do |vjas|
                    next if vjas["dummy"]
                    stop_point = Chouette::StopPoint.find_by(objectid: vjas['stop_point_objectid'])
                    stop_area = stop_point&.stop_area
            Severity: Minor
            Found in app/models/chouette/vehicle_journey.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 flattened_circulation_periods has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def flattened_circulation_periods
                  periods = time_tables.map(&:periods).flatten
                  out = []
                  dates = periods.map {|p| [p.period_start, p.period_end + 1.day]}
            
            
            Severity: Minor
            Found in app/models/chouette/vehicle_journey.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 update_has_and_belongs_to_many_from_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_has_and_belongs_to_many_from_state item
                  ['time_tables', 'footnotes', 'line_notices'].each do |assos|
                    next unless item[assos]
            
                    saved = self.send(assos).map(&:id)
            Severity: Minor
            Found in app/models/chouette/vehicle_journey.rb - About 45 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 bounding_dates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def bounding_dates
                  dates = []
            
                  time_tables.each do |tm|
                    dates << tm.start_date if tm.start_date
            Severity: Minor
            Found in app/models/chouette/vehicle_journey.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