afimb/chouette2

View on GitHub

Showing 269 of 269 total issues

Method customize_map has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def customize_map(map, page)
    layer = kml_layer([route_section_selector.itinerary.referential, route_section_selector.itinerary.route.line, route_section_selector.itinerary.route, route_section_selector.itinerary],
                      { rendererOptions: { zIndexing: true }, styleMap: Design::JourneyPatternStyleMap.new(helpers).style_map })
    page.assign 'journeyPatternLayer', layer

Severity: Major
Found in app/maps/route_section_selector_map.rb - About 2 hrs to fix

    Class RuleParameterSet has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RuleParameterSet < ActiveRecord::Base
      belongs_to :organisation
    
      #validates_presence_of :referential
      validates_presence_of :name
    Severity: Minor
    Found in app/models/rule_parameter_set.rb - About 2 hrs to fix

      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

      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

      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 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 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 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 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

              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

              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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    def select_lines(object, ids)
                      if object == "network"
                        ids.present? ? Chouette::Line.includes(:routes).where(:network_id => ids.split(",")).order(:objectid) :
                          Chouette::Line.joins(:network).includes(:routes).order(:objectid)
                      elsif object == "company"
                  Severity: Major
                  Found in app/exporters/chouette/hub/exporter.rb and 1 other location - About 2 hrs to fix
                  app/exporters/chouette/kml/exporter.rb on lines 16..27

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 81.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    def select_lines(object, ids)
                      if object == "network"
                        ids.present? ? Chouette::Line.includes(:routes).where( :network_id => ids.split(",")).order(:name) :
                                       Chouette::Line.joins(:network).includes(:routes).order(:name)
                      elsif object == "company"
                  Severity: Major
                  Found in app/exporters/chouette/kml/exporter.rb and 1 other location - About 2 hrs to fix
                  app/exporters/chouette/hub/exporter.rb on lines 30..41

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 81.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                        def compliance_check
                          @job = IevkitJob.new(@referential, resource)
                          @job.search = params[:q][:search] if params[:q]
                          @transport_datas_selected = params[:type_td]
                          @default_view = params[:default_view] ? params[:default_view].to_sym : :tests
                      Severity: Major
                      Found in app/controllers/exports_controller.rb and 1 other location - About 1 hr to fix
                      app/controllers/imports_controller.rb on lines 90..101

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 74.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language