af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method update_has_and_belongs_to_many_from_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_has_and_belongs_to_many_from_state item
      ['time_tables', 'footnotes', 'line_notices'].each do |assos|
        next unless item[assos]

        saved = self.send(assos).map(&:id)
Severity: Minor
Found in app/models/chouette/vehicle_journey.rb - About 45 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 single_sign_out has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def single_sign_out
    if ::Devise.cas_enable_single_sign_out
      session_index = read_session_index
      if session_index
        logger.debug "Intercepted single-sign-out request for CAS session #{session_index}."
Severity: Minor
Found in app/controllers/devise/cas_sessions_controller.rb - About 45 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 update_in_out has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update_in_out date, in_out
    if in_out
      self.excluded_dates.delete date
      self.dates << date unless include_in_dates?(date)
    else
Severity: Minor
Found in app/models/calendar.rb - About 45 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def index # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
    if (saved_search = saved_searches.find_by(id: params[:search_id]))
      @search = saved_search.search
    end

Severity: Minor
Found in app/controllers/workgroup_imports_controller.rb - About 45 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 copy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def copy(raise_error: false)
    measure "copy", source: source.id, target: target.id do
      CustomFieldsSupport.within_workgroup(workgroup) do
        copy_resource(:metadatas) unless skip_metadatas?
        source.switch do
Severity: Minor
Found in app/services/referential_copy.rb - About 45 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 extract_costs_to_way_costs! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_costs_to_way_costs!(way_costs, points, matrix_json)
      way_costs = []

      # `row` and `column` order is the same as `points`
      matrix_json['matrix'].each_with_index do |row, row_i|
Severity: Minor
Found in app/lib/tom_tom/matrix.rb - About 45 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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def show # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
    respond_to do |format|
      if collection.out_of_bounds?
        redirect_to params.merge(:page => 1)
      end
Severity: Minor
Found in app/controllers/route_vehicle_journeys_controller.rb - About 45 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 after_update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def after_update(operation)
    return unless email_sendable_for?(operation)

    workbench = operation.try(:workbench) || operation.try(:workbench_for_notifications)
    return unless workbench
Severity: Minor
Found in app/observers/notifiable_operation_observer.rb - About 45 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 month_periode_enum has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def month_periode_enum(bounding_dates, years)
    if bounding_dates.empty?
      start_date = Date.today - years.years
      end_date = Date.today + years.years
    else
Severity: Minor
Found in app/helpers/time_tables_helper.rb - About 45 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

Avoid deeply nested control flow statements.
Open

                  if (j + o[:width].to_i) >= i
                    prev = o
                    break
                  end
Severity: Major
Found in app/helpers/table_builder_helper.rb - About 45 mins to fix

    Method merge_periods has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def merge_periods(periods, join: false)
          return periods unless periods.size > 1
    
          [].tap do |out|
            current = periods.first
    Severity: Minor
    Found in app/services/referential_overview.rb - About 45 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 calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def calculate!
          previous_time_of_day = nil
          day_offset_base = 0
          @at_stops.each do |vehicle_journey_at_stop|
            %w{arrival departure}.each do |part|
    Severity: Minor
    Found in app/models/chouette/vehicle_journey_at_stops_day_offset.rb - About 45 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def index # rubocop:disable Metrics/MethodLength
        if (saved_search = saved_searches.find_by(id: params[:search_id]))
          @search = saved_search.search
        end
    
    
    Severity: Minor
    Found in app/controllers/imports_controller.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def statuses(statuses)
          change_scope(if: statuses.present?) do |scope|
            query = []
    
            query << '(ready = false AND failed_at IS NOT NULL)' if statuses.include?('failed')
    Severity: Minor
    Found in app/lib/query/referential.rb - About 45 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 grouped_by has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def grouped_by *groups
          add_footer = groups.include?(:footer)
          groups -= [:footer]
          out = HashWithIndifferentAccess[*groups.map{|g| [g, []]}.flatten(1)]
          out[:other] = []
    Severity: Minor
    Found in app/lib/af83/decorator.rb - About 45 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 search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def search(scope)
          if valid?
            result = query(scope).scope
            result = order.order(result) unless without_order?
            result = result.paginate(paginate_attributes) unless without_pagination?
    Severity: Minor
    Found in app/lib/search/base.rb - About 45 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

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

      onUpdatePublishedName(e) {
        const newPublishedName = handleInputChange('published_name')(e.target.value)()
        dispatch(actions.updateRouteFormInput(newPublishedName))
      },
    Severity: Minor
    Found in app/packs/src/routes/containers/Route.js and 1 other location - About 45 mins to fix
    app/packs/src/routes/containers/Route.js on lines 21..24

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

    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

      onUpdateName(e) {
        const newName = handleInputChange('name')(e.target.value)()
        dispatch(actions.updateRouteFormInput(newName))
      },
    Severity: Minor
    Found in app/packs/src/routes/containers/Route.js and 1 other location - About 45 mins to fix
    app/packs/src/routes/containers/Route.js on lines 25..28

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

    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

      class StopArea < Queries::BaseQuery
        description 'Find a stop area'
    
        argument :objectid, String, required: false
        argument :registration_number, String, required: false
    Severity: Minor
    Found in app/graphql/queries/stop_area.rb and 1 other location - About 45 mins to fix
    app/graphql/queries/line.rb on lines 2..14

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

    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 closest_specific_stops
          return self.specific_stops if position.blank?
    
          parent_point = self.class.connection.quote("SRID=4326;POINT(#{longitude} #{latitude})")
          specific_point   = "ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)"
    Severity: Minor
    Found in app/models/chouette/stop_area.rb and 1 other location - About 45 mins to fix
    app/models/chouette/stop_area.rb on lines 267..273

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

    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