Showing 8 of 10 total issues
File train_schedule.rb
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RailFeeds
module NetworkRail
module Schedule
# rubocop:disable Metrics/ClassLength
# A class for holding information about a particular train
Method path_for
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def path_for(toc, day, format)
toc = "#{toc}_TOC" unless %w[ALL FREIGHT].include?(toc)
if format.eql?(:cif)
unless toc.eql?('ALL')
- 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 to_json
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_json(**opts)
{
'JsonScheduleV1' => {
'CIF_bank_holiday_running' => bank_holiday_running,
'CIF_stp_indicator' => stp_indicator_to_cif,
Method from_json
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.from_json(json)
data = ::JSON.parse(json)['JsonScheduleV1']
locations = data.dig('schedule_segment', 'schedule_location')&.map do |location|
location_from_json location
Method ensure_correct_update_order
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ensure_correct_update_order(header)
if last_header.nil?
# No data whatsoever - this must be a full extract
unless header.full?
fail ArgumentError,
- 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 basic_to_cif
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def basic_to_cif
format('%-80.80s', [
'BSN',
format('%-6.6s', uid),
format('%-6.6s', start_date&.strftime('%y%m%d')),
Method parse_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_file(file)
@file_ended = false
@stop_parsing = false
file.each_line do |line|
- 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 parse_line
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_line(line)
if line.start_with? '{"TiplocV1":'
parse_tiploc_line line
elsif line.start_with? '{"JsonAssociationV1":'
parse_association_line line
- 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"