afimb/chouette2

View on GitHub

Showing 117 of 269 total issues

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

  def period_validation
    st_date = start_date.present? && start_date.is_a?(String) ? Date.parse(start_date) : start_date
    ed_date = end_date.present? && end_date.is_a?(String) ? Date.parse(end_date) : end_date

    unless  Chouette::TimeTable.start_validity_period.nil? || st_date.nil?
Severity: Minor
Found in app/models/export_task.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 recalculate_day_offset has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def recalculate_day_offset
      return unless recalculate_offset

      vjass = self.vehicle_journey_at_stops
      return unless vjass.present?
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

Class Route has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

class Chouette::Route < Chouette::TridentActiveRecord
  include RouteRestrictions

  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
  self.primary_key = "id"
Severity: Minor
Found in app/models/chouette/route.rb - About 2 hrs to fix

    Method load_imported_vehicle_journeys has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def load_imported_vehicle_journeys
        
        spreadsheet = open_spreadsheet(file)
        
        vehicle_journeys = []
    Severity: Major
    Found in app/models/vehicle_journey_import.rb - About 2 hrs to fix

      Method initialize has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(vehicle_journey, directory, index)
          @vehicle_journey = vehicle_journey
          @number = index
          @directory = directory
          @template = File.open('app/views/api/hub/courses_operations.hub.erb' ) { |f| f.read }
      Severity: Major
      Found in app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb - About 2 hrs to fix

        Method customize_map has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def customize_map(map, page)
              if stop_area.parents.present?
                page.assign "parents_layer", kml_layer(stop_area, { :parents => true }, :style_map => Design::StopAreasStyleMap.new(helpers).style_map)
                page << map.add_layer(:parents_layer)
                page << map.add_control( hover_control_display_name(:parents_layer) )
        Severity: Minor
        Found in app/maps/stop_area_map.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 object_labels_hash has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def object_labels_hash (error)
            ### THE error HASH STRUCTURE
            # 1. error[:source]
            #      0..1 file
            #           1 filename
        Severity: Minor
        Found in app/helpers/compliance_checks_helper.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 build_breadcrumb has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def build_breadcrumb(action)
            action = action.to_sym
            case resource_class.to_s
            when "Chouette::Network"
              network_breadcrumb action
        Severity: Major
        Found in app/helpers/breadcrumb_helper.rb - About 2 hrs to fix

          Method initialize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(vehicle_journey, directory, index)
              @vehicle_journey = vehicle_journey
              @directory = directory
              @template = File.open('app/views/api/hub/courses.hub.erb' ) { |f| f.read }
              @numero = index
          Severity: Minor
          Found in app/exporters/chouette/hub/vehicle_journey_exporter.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 available_exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def available_exports
              export_task_parameters = params[:export_task]
              if export_task_parameters.present?
                @available_exports = [
                  export_task_parameters[:data_format] == "neptune" ? build_resource : NeptuneExport.new(:referential_id => @referential.id ),
          Severity: Minor
          Found in app/controllers/export_tasks_controller.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

          File stop_area.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'geokit'
          require 'geo_ruby'
          
          class Chouette::StopArea < Chouette::TridentActiveRecord
            # FIXME http://jira.codehaus.org/browse/JRUBY-6358
          Severity: Minor
          Found in app/models/chouette/stop_area.rb - About 2 hrs to fix

            Class ApplicationMap has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class ApplicationMap
            
              include MapLayers
              include MapLayers::ViewHelpers
            
            
            Severity: Minor
            Found in app/maps/application_map.rb - About 2 hrs to fix

              Method execute_geometry has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                def execute_geometry(secondary = false)
                  if secondary && Rails.application.secrets.osrm_secondary_endpoint.present?
                    @osrm_endpoint = Rails.application.secrets.osrm_secondary_endpoint
                  end
              
              
              Severity: Minor
              Found in lib/osrm_route_section_processor.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 export has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def export(zip_file_path, options = {})
                  begin
                    referential.switch
              
                    FileUtils.rm(zip_file_path) if File.exists? zip_file_path
              Severity: Minor
              Found in app/exporters/chouette/kml/exporter.rb - About 1 hr to fix

                Method help_path has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def help_path
                    path = request.env['PATH_INFO']
                    target = case
                    when path.include?("/help")
                      ""
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 1 hr to fix

                  Method merge! has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def merge!(another_tt)
                      transaction do
                      # if one tt has no period, just merge lists
                      if self.periods.empty? || another_tt.periods.empty?
                        if !another_tt.periods.empty?
                  Severity: Minor
                  Found in app/models/chouette/time_table.rb - About 1 hr to fix

                    Method initialize has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def initialize(vehicle_journey, directory, index)
                        @vehicle_journey = vehicle_journey
                        @directory = directory
                        @template = File.open('app/views/api/hub/courses.hub.erb' ) { |f| f.read }
                        @numero = index
                    Severity: Minor
                    Found in app/exporters/chouette/hub/vehicle_journey_exporter.rb - About 1 hr to fix

                      Method search has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def search
                          if options[:json]
                            tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null"
                            template.content_tag( :script,
                             ("$(document).ready(function() {
                      Severity: Minor
                      Found in app/inputs/search_stop_area_input.rb - About 1 hr to fix

                        Method tt_day_types has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def tt_day_types(tt)
                            type = tt.monday ? label("monday") : ".."
                            type += tt.tuesday ? label("tuesday") : ".."
                            type += tt.wednesday ? label("wednesday") : ".."
                            type += tt.thursday ? label("thursday") : ".."
                        Severity: Minor
                        Found in app/models/vehicle_journey_export.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 valid_days has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def valid_days
                            # Build an array with day of calendar week (1-7, Monday is 1).
                            [].tap do |valid_days|
                              valid_days << 1  if monday
                              valid_days << 2  if tuesday
                        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

                        Severity
                        Category
                        Status
                        Source
                        Language