File vehicle_journey.rb
has 524 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Chouette
class VehicleJourney < Referential::Model
include CustomFieldsSupport
include TransportModeEnumerations
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
- Read upRead up
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 29 methods (exceeds 20 allowed). Consider refactoring. Open
class VehicleJourney < Referential::Model
include CustomFieldsSupport
include TransportModeEnumerations
has_metadata
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')
- Read upRead up
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
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]
- Read upRead up
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]}
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
- Read upRead up
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')
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]}
- Read upRead up
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_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
- Read upRead up
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)
- Read upRead up
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
- Read upRead up
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"