afimb/chouette2

View on GitHub

Showing 269 of 269 total issues

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/imports_controller.rb and 1 other location - About 1 hr to fix
app/controllers/exports_controller.rb on lines 77..88

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

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

          def self.valid_days(int_day_types)
            # Build an array with day of calendar week (1-7, Monday is 1).
            [].tap do |valid_days|
              valid_days << 1  if day_by_mask(int_day_types,4)
              valid_days << 2  if day_by_mask(int_day_types,8)
        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 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 processAuthentification has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def processAuthentification
            @user = User.from_omniauth(request.env["omniauth.auth"])
            if @user.new_record?
              session['user_stand_by_provider'] = @user.provider
              session['user_stand_by_uid'] = @user.uid
        Severity: Minor
        Found in app/controllers/users/omniauth_callbacks_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 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

        Method decode_hash_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def decode_hash_value(key, value)
              if time_field?(key, value)
                if value.is_a?(String)
                  begin
                    Time.parse(value)
        Severity: Minor
        Found in lib/ievkitdeprecated/serializer.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

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

          def imported_file
            # WARNING : files under 10kb in size get treated as StringIO by OpenUri
            # http://stackoverflow.com/questions/10496874/why-does-openuri-treat-files-under-10kb-in-size-as-stringio
            OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
            OpenURI::Buffer.const_set 'StringMax', 0
        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 52..63

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

        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 exported_file
            # WARNING : files under 10kb in size get treated as StringIO by OpenUri
            # http://stackoverflow.com/questions/10496874/why-does-openuri-treat-files-under-10kb-in-size-as-stringio
            OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
            OpenURI::Buffer.const_set 'StringMax', 0
        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 53..64

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

        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 initialize has a Cognitive Complexity of 12 (exceeds 5 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: Minor
        Found in app/exporters/chouette/hub/vehicle_journey_operation_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 valid? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def valid?
            unless organisation.valid?
              self.errors.add( :organisation_name, organisation.errors[:name]) if organisation.errors[:name]
            end
            unless user.valid?
        Severity: Minor
        Found in app/models/subscription.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 save has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def save
            begin
              if self.valid?
                Chouette::StopArea.transaction do
                  copy.update_attributes copy_modfied_attributes
        Severity: Minor
        Found in app/models/stop_area_copy.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(attributes = {})
            attributes.each { |name, value| send("#{name}=", value) } if attributes
            if self.area_type.blank? && self.source != nil
              self.source_id = self.source.id
              if self.hierarchy == "child"
        Severity: Minor
        Found in app/models/stop_area_copy.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 search has 32 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_time_table_input.rb - About 1 hr to fix

          Method paginate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def paginate(url, options = {}, &block)
                opts = parse_query_and_convenience_headers(options.dup)
                if @auto_paginate || @per_page
                  opts[:query][:per_page] ||=  @per_page || (@auto_paginate ? 100 : nil)
                end
          Severity: Minor
          Found in lib/ievkitdeprecated/client.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 vehicle_title has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def vehicle_title(vehicle, journey_frequency=nil)
              return t("vehicle_journeys.vehicle_journey#{'_frequency' if vehicle.frequency?}.title_stopless", :name => vehicle_name( vehicle)) if vehicle.vehicle_journey_at_stops.empty?
              first_vjas = vehicle.vehicle_journey_at_stops.first
              if vehicle.frequency? && journey_frequency
                t("vehicle_journeys.vehicle_journey_frequency.title_frequency",
          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

          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.step_progress}", :'aria-valuemin' => "0", :'aria-valuemax' => "100", :style => "width: #{report.step_progress}%;" ) do
                       end)
                  concat( content_tag(:span, t("progress_bar.step"), :class => "progress-type") )
                  concat( content_tag(:span, "#{report.current_step.realized}/#{report.current_step.total}", :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 18..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 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(:name) :
                               Chouette::Line.joins(:network).includes(:routes).order(:name)
              elsif object == "company"
          Severity: Minor
          Found in app/exporters/chouette/kml/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

          Severity
          Category
          Status
          Source
          Language