afimb/chouette2

View on GitHub

Showing 117 of 269 total issues

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

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

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

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

              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

              Severity
              Category
              Status
              Source
              Language