afimb/chouette2

View on GitHub

Showing 117 of 269 total issues

Method bounding_dates has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def bounding_dates
    bounding_min = self.dates.select{|d| d.in_out}.map(&:date).compact.min
    bounding_max = self.dates.select{|d| d.in_out}.map(&:date).compact.max

    unless self.periods.empty?
Severity: Minor
Found in app/models/chouette/time_table.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 notice has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def notice
    a = Array.new
    a << I18n.t('clean_ups.success_tm', :count => time_table_count.to_s)
    if (vehicle_journey_count > 0) 
      a << I18n.t('clean_ups.success_vj', :count => vehicle_journey_count.to_s)
Severity: Minor
Found in app/models/clean_up_result.rb - About 1 hr to fix

    Method generic_access_link_matrix has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def generic_access_link_matrix
         matrix = Array.new
         hash = Hash.new
         access_links.each do |link|
            hash[link.link_key] = link
    Severity: Minor
    Found in app/models/chouette/access_point.rb - About 1 hr to fix

      Method creation_tag has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def creation_tag(object)
          field_set_tag t("layouts.history_tag.title"), :class => "history_tag" do
            content_tag :ul do
              [(content_tag :li do
                if object.has_attribute?(:creation_time)
      Severity: Minor
      Found in app/helpers/history_helper.rb - About 1 hr to fix

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

          def self.import_csv
            csv_file = Rails.root + "chouette_pt_links.csv"
            if File.exists?( csv_file)
              csv = CSV::Reader.parse(File.read(csv_file))
        
        
        Severity: Minor
        Found in app/models/chouette/pt_link.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 customize_map has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def customize_map(map, page)
            # layers order seems to matter for ModifyFeature control
            route_section.stop_areas.each do |stop_area|
              layer = "stop_area_#{stop_area.id}".to_sym
              page.assign layer.to_s, kml_layer(stop_area, :styleMap => Design::StopAreasStyleMap.new(helpers).style_map)
        Severity: Minor
        Found in app/maps/route_section_map.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 create_sections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_sections
            [].tap do |sections|
              stop_points.each_cons(2).each_with_index do |(departure, arrival), index|
                journey_pattern_section = Chouette::JourneyPatternSection.find_by(journey_pattern: @itinerary, rank: index)
        
        
        Severity: Minor
        Found in app/models/route_sections_selector.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 control_route_sections_by_stop_areas has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def control_route_sections_by_stop_areas(stop_area_ids)
            journey_pattern_section_all
            i = 0
            to_control = false
            stop_area_ids.each_cons(2) do |a|
        Severity: Minor
        Found in app/models/chouette/journey_pattern.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 build_error_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_error_message
              return nil if @response.nil?
        
              message =  "#{@response[:method].to_s.upcase} "
              message << redact_url(@response[:url].to_s) + ": "
        Severity: Minor
        Found in lib/ievkitdeprecated/error.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 frequency_first_departure_times_array has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def frequency_first_departure_times_array
            (vehicle_journey_frequencies.collect{ |vjf| vjf.journey_frequencies ? (vjf.journey_frequencies.collect { |jf| jf.first_departure_time ? jf.first_departure_time.strftime("%H:%M").to_s : "" } ) : "" } )
          end
        Severity: Minor
        Found in app/models/vehicle_journey_export.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 notice has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def notice
            a = Array.new
            a << I18n.t('clean_ups.success_tm', :count => time_table_count.to_s)
            if (vehicle_journey_count > 0) 
              a << I18n.t('clean_ups.success_vj', :count => vehicle_journey_count.to_s)
        Severity: Minor
        Found in app/models/clean_up_result.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

        Avoid deeply nested control flow statements.
        Open

                          if transport_modes["CAR"]
                            transport_modes["CAR"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
                          else
                            transport_modes["CAR"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
                          end
        Severity: Major
        Found in app/exporters/chouette/hub/exporter.rb - About 45 mins to fix

          Method frequency_last_departure_times_array has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def frequency_last_departure_times_array
              (vehicle_journey_frequencies.collect{ |vjf| vjf.journey_frequencies ? (vjf.journey_frequencies.collect { |jf| jf.last_departure_time ? jf.last_departure_time.strftime("%H:%M").to_s : "" } ) : "" } )
            end
          Severity: Minor
          Found in app/models/vehicle_journey_export.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 optimize_periods has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def optimize_periods
              periods = self.clone_periods
              optimized = []
              i=0
              while i < periods.length
          Severity: Minor
          Found in app/models/chouette/time_table.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

          Avoid deeply nested control flow statements.
          Open

                            if transport_modes["BUS"]
                              transport_modes["BUS"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
                            else
                              transport_modes["BUS"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
                            end
          Severity: Major
          Found in app/exporters/chouette/hub/exporter.rb - About 45 mins to fix

            Method prepare_auto_columns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def prepare_auto_columns
                  # logger.info 'calling before_validation'
                  # logger.info 'start before_validation : '+self.objectid.to_s
                  if self.objectid.nil? || self.objectid.blank?
                    # if empty, generate a pending objectid which will be completed after creation
            Severity: Minor
            Found in app/models/chouette/trident_active_record.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 frequency_scheduled_headway_intervals_array has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def frequency_scheduled_headway_intervals_array
                (vehicle_journey_frequencies.collect{ |vjf| vjf.journey_frequencies ? (vjf.journey_frequencies.collect { |jf| jf.scheduled_headway_interval ? jf.scheduled_headway_interval.strftime("%H:%M").to_s : "" } ) : "" } )
              end
            Severity: Minor
            Found in app/models/vehicle_journey_export.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 matrix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.matrix(vehicle_journeys)
                  hash = {}
                  vehicle_journeys.each do |vj|
                    vj.journey_frequencies.each do |jf|
                      next if jf.scheduled_headway_interval.hour == 0 && jf.scheduled_headway_interval.min == 0
            Severity: Minor
            Found in app/models/chouette/vehicle_journey_frequency.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def initialize(stop_point, sens, line, directory, index)
            Severity: Minor
            Found in app/exporters/chouette/hub/itl_exporter.rb - About 35 mins to fix

              Method periods_min_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def periods_min_date
                  return nil if self.periods.empty?
              
                  min_start = self.periods.map(&:period_start).compact.min
                  max_end = self.periods.map(&:period_end).compact.max
              Severity: Minor
              Found in app/models/chouette/time_table.rb - About 35 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

              Severity
              Category
              Status
              Source
              Language