af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method validate_periods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_periods
    periods_are_valid = true

    unless periods.all?(&:valid?)
      periods_are_valid = false
Severity: Minor
Found in app/models/referential_metadata.rb - About 25 mins 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 handle_enumerize_option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_enumerize_option attribute_name, opts
        if opts.key?(:enumerize)
          collection = opts[:enumerize] == :collection ? opts[:collection] : opts[:enumerize]
          enumerize attribute_name, in: collection, default: opts[:default_value]
        end
Severity: Minor
Found in app/models/concerns/options_support.rb - About 25 mins 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 schedule_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def schedule_all
        load_all_subclasses

        descendants.each do |job_class|
          next if job_class.abstract_class?
Severity: Minor
Found in app/jobs/cron/base_job.rb - About 25 mins 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 company_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def company_ids
      ids = Set.new
      # OPTIMIZEME pluck is great bu can consume a lot of memory for very large Vehicle Journey collection
      vehicle_journeys.left_joins(route: { line: :company }).
        pluck("vehicle_journeys.id", "companies.id", "companies.time_zone").
Severity: Minor
Found in app/models/export/gtfs.rb - About 25 mins 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 find_stop_parent_or_create_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def find_stop_parent_or_create_message(stop_area_name, parent_station, resource)
    parent = stop_areas.find_by(registration_number: parent_station)

    unless parent
      parent = stop_area_referential.stop_areas.find_by(registration_number: parent_station)
Severity: Minor
Found in app/models/import/gtfs.rb - About 25 mins 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_periods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_periods
      periods_are_valid = periods.all?(&:valid?)

      periods.each do |period|
        if period.intersect?(periods)
Severity: Minor
Found in app/models/concerns/period_support.rb - About 25 mins 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 import! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def import!
      source.shapes.each_slice(1000).each do |gtfs_shapes|
        Shape.transaction do
          gtfs_shapes.each do |gtfs_shape|
            decorator = Decorator.new(gtfs_shape, code_space: code_space)
Severity: Minor
Found in app/models/import/gtfs.rb - About 25 mins 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 send_to_ara has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def send_to_ara(file, report)
      payload = { "force": force_import }

      request = Net::HTTP::Post.new(uri)
      request['Authorization'] = "Token token=#{credentials}"
Severity: Minor
Found in app/models/destination/ara.rb - About 25 mins 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 registration_number_is_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def registration_number_is_set
      return unless stop_area_referential&.registration_number_format.present?

      unless registration_number.present?
        errors.add(:registration_number, I18n.t('stop_areas.errors.registration_number.cannot_be_empty'))
Severity: Minor
Found in app/models/chouette/stop_area.rb - About 25 mins 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 check_auth_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def check_auth_token
    return if @publication_api.public?
    key = nil

    authenticate_with_http_token do |token|
Severity: Minor
Found in app/controllers/api/v1/datas_controller.rb - About 25 mins 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 bounding_dates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def bounding_dates
      dates = []

      time_tables.each do |tm|
        dates << tm.start_date if tm.start_date
Severity: Minor
Found in app/models/chouette/vehicle_journey.rb - About 25 mins 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 statuses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def statuses(statuses)
      change_scope(if: statuses.present?) do |scope|
        query = []
        query << 'deleted_at IS NOT NULL' if statuses.include?('deactivated')
        query << '(confirmed_at IS NULL AND deleted_at IS NULL)' if statuses.include?('in_creation')
Severity: Minor
Found in app/lib/query/stop_area.rb - About 25 mins 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 remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def remove(other)
    return self if (other.nil? or self.max < other.min or other.max < self.min)

    [].tap do |remaining|
      remaining << (self.min..other.min-1) if self.min < other.min
Severity: Minor
Found in app/lib/range_ext.rb - About 25 mins 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 webhook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def webhook
        if event.valid?
          if event.update_or_create?
            synchronization.source = event.netex_source
            synchronization.update_or_create
Severity: Minor
Found in app/controllers/api/v1/line_referentials_controller.rb - About 25 mins 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 webhook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def webhook
        if event.valid?
          if event.update_or_create?
            synchronization.source = event.netex_source
            synchronization.update_or_create
Severity: Minor
Found in app/controllers/api/v1/stop_area_referentials_controller.rb - About 25 mins 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 shortcuts_update_for_add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def shortcuts_update_for_add( stop_point)
      return if skip_save_shortcuts?

      stop_points << stop_point unless stop_points.include?( stop_point)

Severity: Minor
Found in app/models/chouette/journey_pattern.rb - About 25 mins 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 overlapped_referential_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def overlapped_referential_ids
    return [] unless metadatas.present?

    line_ids = metadatas.first.line_ids
    periodes = metadatas.first.periodes
Severity: Minor
Found in app/models/referential.rb - About 25 mins 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    tt_params = time_table_params
    if tt_params[:calendar_id] && tt_params[:calendar_id] != ""
      calendar = Calendar.find(tt_params[:calendar_id])
      comment = tt_params[:comment].presence
Severity: Minor
Found in app/controllers/time_tables_controller.rb - About 25 mins 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 sort_results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def sort_results collection
    dir =  %w[asc desc].include?(params[:direction]) ?  params[:direction] : 'asc'
    extra_cols = %w(organisation_name)
    col = (Calendar.column_names + extra_cols).include?(params[:sort]) ? params[:sort] : 'name'

Severity: Minor
Found in app/controllers/calendars_controller.rb - About 25 mins 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 enabled? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def enabled?
    enabled = false
    if @options[:_if].nil?
      enabled = true
    elsif @options[:_if].is_a?(Proc)
Severity: Minor
Found in app/lib/af83/decorator/link.rb - About 25 mins 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