robertgauld/rail_feeds

View on GitHub
lib/rail_feeds/network_rail/schedule/train_schedule.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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
Severity: Minor
Found in lib/rail_feeds/network_rail/schedule/train_schedule.rb - About 2 hrs to fix

    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,
    Severity: Minor
    Found in lib/rail_feeds/network_rail/schedule/train_schedule.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in lib/rail_feeds/network_rail/schedule/train_schedule.rb - About 1 hr to fix

        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')),
        Severity: Minor
        Found in lib/rail_feeds/network_rail/schedule/train_schedule.rb - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status