afimb/chouette2

View on GitHub

Showing 269 of 269 total issues

Method export has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
Open

  def export(zip_file_path, options = {})
    begin
      referential.switch
      if referential_exportable? && options[:start_date] && options[:end_date]
        FileUtils.rm(zip_file_path) if File.exists? zip_file_path
Severity: Minor
Found in app/exporters/chouette/hub/exporter.rb - About 1 day 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 TimeTable has 51 methods (exceeds 20 allowed). Consider refactoring.
Open

class Chouette::TimeTable < Chouette::TridentActiveRecord
  include TimeTableRestrictions
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
  self.primary_key = "id"

Severity: Major
Found in app/models/chouette/time_table.rb - About 7 hrs to fix

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

        $.datepicker.regional['fr'] = {
            closeText: 'Fermer',
            prevText: '&#x3c;Préc',
            nextText: 'Suiv&#x3e;',
            currentText: 'Courant',
    Severity: Major
    Found in app/assets/javascripts/plugins/jquery.ui.datepicker-i18n.js and 1 other location - About 5 hrs to fix
    app/assets/javascripts/plugins/jquery.ui.datepicker-i18n.js on lines 24..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 145.

    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

        $.datepicker.regional['en'] = {
            closeText: 'Done',
            prevText: 'Prev',
            nextText: 'Next',
            currentText: 'Today',
    Severity: Major
    Found in app/assets/javascripts/plugins/jquery.ui.datepicker-i18n.js and 1 other location - About 5 hrs to fix
    app/assets/javascripts/plugins/jquery.ui.datepicker-i18n.js on lines 5..22

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

    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

    Class StopArea has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Chouette::StopArea < Chouette::TridentActiveRecord
      # FIXME http://jira.codehaus.org/browse/JRUBY-6358
      self.primary_key = "id"
      include Geokit::Mappable
      include ProjectionFields
    Severity: Minor
    Found in app/models/chouette/stop_area.rb - About 5 hrs to fix

      Class VehicleJourneyExport has 40 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class VehicleJourneyExport   
        include ActiveModel::Validations
        include ActiveModel::Conversion
        extend  ActiveModel::Naming
      
      
      Severity: Minor
      Found in app/models/vehicle_journey_export.rb - About 5 hrs to fix

        Method clean has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

          def clean
            # as foreign keys are presents , delete method can be used for faster performance
            result = CleanUpResult.new
            # find and remove time_tables
            tms = Chouette::TimeTable.validity_out_from_on?(Date.parse(expected_date))
        Severity: Minor
        Found in app/models/clean_up.rb - About 5 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 mode_default_params has 128 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.mode_default_params
            {
            :coach => {
              :allowed_transport_mode_coach => false,
              :inter_stop_area_distance_min_mode_coach => 500,
        Severity: Major
        Found in app/models/rule_parameter_set.rb - About 5 hrs to fix

          File time_table.rb has 369 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class Chouette::TimeTable < Chouette::TridentActiveRecord
            include TimeTableRestrictions
            # FIXME http://jira.codehaus.org/browse/JRUBY-6358
            self.primary_key = "id"
          
          
          Severity: Minor
          Found in app/models/chouette/time_table.rb - About 4 hrs to fix

            Method creation_tag has a Cognitive Complexity of 32 (exceeds 5 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 4 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 118 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def export(zip_file_path, options = {})
                begin
                  referential.switch
                  if referential_exportable? && options[:start_date] && options[:end_date]
                    FileUtils.rm(zip_file_path) if File.exists? zip_file_path
            Severity: Major
            Found in app/exporters/chouette/hub/exporter.rb - About 4 hrs to fix

              Method merge! has a Cognitive Complexity of 29 (exceeds 5 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 4 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 103 lines of code (exceeds 25 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: Major
              Found in app/maps/stop_area_map.rb - About 4 hrs to fix

                Class Referential has 31 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Referential < ActiveRecord::Base
                  include DataFormatEnumerations
                
                  validates_presence_of :name
                  validates_presence_of :prefix
                Severity: Minor
                Found in app/models/referential.rb - About 3 hrs to fix

                  File rule_parameter_set.rb has 312 lines of code (exceeds 250 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 3 hrs to fix

                    Method export has a Cognitive Complexity of 24 (exceeds 5 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 3 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 Client has 28 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                      class Client
                    
                        include Ievkitdeprecated::Configurable
                        include Ievkitdeprecated::Authentication
                        include Ievkitdeprecated::Client::Jobs
                    Severity: Minor
                    Found in lib/ievkitdeprecated/client.rb - About 3 hrs to fix

                      Method clean has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def clean
                          # as foreign keys are presents , delete method can be used for faster performance
                          result = CleanUpResult.new
                          # find and remove time_tables
                          tms = Chouette::TimeTable.validity_out_from_on?(Date.parse(expected_date))
                      Severity: Major
                      Found in app/models/clean_up.rb - About 3 hrs to fix

                        Method load_imported_vehicle_journeys has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def load_imported_vehicle_journeys
                            
                            spreadsheet = open_spreadsheet(file)
                            
                            vehicle_journeys = []
                        Severity: Minor
                        Found in app/models/vehicle_journey_import.rb - About 3 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 execute_geometry has a Cognitive Complexity of 23 (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_5_route_section_processor.rb - About 3 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

                        Severity
                        Category
                        Status
                        Source
                        Language