afimb/chouette2

View on GitHub

Showing 269 of 269 total issues

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

      progress = content_tag :div, :class => "progress" do
        concat(content_tag(:div, :class => div_class, role: "progressbar", :'aria-valuenow' => "#{report.level_progress}", :'aria-valuemin' => "0", :'aria-valuemax' => "100", :style => "width: #{report.level_progress}%;") do               
             end)
        concat( content_tag(:span, t("progress_bar.level"), :class => "progress-type") )
        concat( content_tag(:span, "#{report.progression.current_step}/#{report.progression.steps_count}", :class => "progress-completed") )
Severity: Major
Found in app/helpers/progress_bar_helper.rb and 1 other location - About 1 hr to fix
app/helpers/progress_bar_helper.rb on lines 25..29

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

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 select_lines has a Cognitive Complexity of 11 (exceeds 5 allowed). 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: Minor
Found in app/exporters/chouette/hub/exporter.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 special_vehicle_journey_icon has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def special_vehicle_journey_icon(field, vehicle_journey)
    fa_class = { mobility_restricted_suitability: 'fa-wheelchair', flexible_service: 'fa-phone' }.map{ |k, v| v if k == field }.compact

    if vehicle_journey.send(field).to_s.present?
      fa_class << 'fa-line-through' unless vehicle_journey.send(field)
Severity: Minor
Found in app/helpers/vehicle_journeys_helper.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 available_imports has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def available_imports
    import_task_parameters = params[:import_task]

    if import_task_parameters.present?
      @available_imports = [
Severity: Minor
Found in app/controllers/import_tasks_controller.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 load has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def load
    self.content = File.read(filename)
    self.data ||= {}

    if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
Severity: Minor
Found in app/models/help_page.rb - About 1 hr to fix

    Method hover_control_display_name has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def hover_control_display_name(layer)
        OpenLayers::Control::SelectFeature.new( layer, {
                                                  :autoActivate => true,
                                                  :hover => true,
                                                  :renderIntent => "temporary",
    Severity: Minor
    Found in app/maps/application_map.rb - About 1 hr to fix

      Method customize_map has 29 lines of code (exceeds 25 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 1 hr to fix

        Method default_style has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def default_style
        
            {
              :fontColor => "black",
              :fontSize => "11px",
        Severity: Minor
        Found in app/maps/design/route_section_style_map.rb - About 1 hr to fix

          Method detail_access_link_matrix has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Similar blocks of code found in 2 locations. 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: Major
            Found in app/models/chouette/time_table.rb and 1 other location - About 1 hr to fix
            app/models/chouette/time_table.rb on lines 128..143

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

            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 request(method, path, data, options = {})
                  if data.is_a?(Hash)
                    options[:query]   = data.delete(:query) || {}
                    options[:headers] = data.delete(:headers) || {}
                    if accept = data.delete(:accept)
            Severity: Major
            Found in lib/ievkitdeprecated/client.rb and 1 other location - About 1 hr to fix
            lib/ievkitdeprecated/client.rb on lines 286..296

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

            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 multipart_request(method, path, data, options = {})
                  if data.is_a?(Hash)
                    options[:query]   = data.delete(:query) || {}
                    options[:headers] = data.delete(:headers) || {}
                    if accept = data.delete(:accept)
            Severity: Major
            Found in lib/ievkitdeprecated/client.rb and 1 other location - About 1 hr to fix
            lib/ievkitdeprecated/client.rb on lines 299..309

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

            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 periods_max_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: Major
            Found in app/models/chouette/time_table.rb and 1 other location - About 1 hr to fix
            app/models/chouette/time_table.rb on lines 145..160

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

            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 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 validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate(record)
                  timeband = record.timeband
                  if timeband
                    first_departure_time = record.first_departure_time.utc.strftime( "%H%M%S%N" )
                    last_departure_time  = record.last_departure_time.utc.strftime( "%H%M%S%N" )
            Severity: Minor
            Found in app/models/chouette/journey_frequency.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

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

                def access_links_pairs(access_links)
                  hpairs = Hash.new
                  pairs = Array.new
                  access_links.each do |link|
                    key = pair_key(link)
              Severity: Major
              Found in app/helpers/stop_areas_helper.rb and 1 other location - About 1 hr to fix
              app/helpers/access_points_helper.rb on lines 2..21

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

              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 show
                  @job = IevkitJob.new(@referential, resource)
                  if @job.is_terminated?
                    redirect_to compliance_check_referential_export_path(@referential.id, resource.id)
                  else
              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 26..39

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

              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

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

                def access_links_pairs(access_links)
                  hpairs = Hash.new
                  pairs = Array.new
                  access_links.each do |link|
                    key = pair_key(link)
              Severity: Major
              Found in app/helpers/access_points_helper.rb and 1 other location - About 1 hr to fix
              app/helpers/stop_areas_helper.rb on lines 36..55

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

              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 show
                  @job = IevkitJob.new(@referential, resource)
                  if @job.is_terminated?
                    redirect_to compliance_check_referential_import_path(@referential.id, resource.id)
                  else
              Severity: Major
              Found in app/controllers/imports_controller.rb and 1 other location - About 1 hr to fix
              app/controllers/exports_controller.rb on lines 25..38

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

              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