af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method operation_status has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def operation_status(status, verbose: false, default_status: nil, i18n_prefix: nil)
    status = status.status if status.respond_to?(:status)
    status ||= default_status
    return unless status
    i18n_prefix ||= "operation_support.statuses"
Severity: Minor
Found in app/helpers/operations_helper.rb - About 3 hrs 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 build_instance has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def build_instance(context, options = {})
        options = { parent: nil, save: false }.update(options)

        parent = options[:parent]
        save = options[:save]
Severity: Minor
Found in app/lib/chouette/factory/model.rb - About 3 hrs 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

Function render has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render() {
        const {
            vjas,
            x,
            y,
Severity: Major
Found in app/packs/src/vehicle_journeys/components/VehicleJourneyAtStop.js - About 3 hrs to fix

    Method candidate_target_attributes has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def candidate_target_attributes # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
              Chouette::ModelAttribute.collection do # rubocop:disable Metrics/BlockLength
                # Chouette::Line
                select Chouette::Line, :name
                select Chouette::Line, :color
    Severity: Major
    Found in app/models/control/format_attribute.rb - About 3 hrs to fix

      Method new_alt_calendar has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def new_alt_calendar(options = {}, &block)
          raise(ArgumentError, "No year given")  unless options.has_key?(:year)
          raise(ArgumentError, "No month given") unless options.has_key?(:month)
      
          block                        ||= Proc.new {|d| nil}
      Severity: Major
      Found in app/helpers/time_tables_helper.rb - About 3 hrs to fix

        Function render has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render() {
            let id =  _.get(actions.getSelected(this.props.vehicleJourneys), ['0', 'short_id'])
        
            if(this.props.status.isFetching == true) {
              return false

          Method import_stops has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def import_stops
              sorted_stops = source.stops.sort_by { |s| s.parent_station.present? ? 1 : 0 }
              @stop_areas_id_by_registration_number = {}
          
              CustomFieldsSupport.within_workgroup(workbench.workgroup) do
          Severity: Major
          Found in app/models/import/gtfs.rb - About 3 hrs to fix

            File table_builder_helper.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'table_builder_helper/column'
            require 'table_builder_helper/url'
            
            # table_builder_2
            # A Rails helper that constructs an HTML table from a collection of objects. It
            Severity: Minor
            Found in app/helpers/table_builder_helper.rb - About 3 hrs to fix

              Class Workgroup has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Workgroup < ApplicationModel
                NIGHTLY_AGGREGATE_CRON_TIME = 5.minutes
                DEFAULT_EXPORT_TYPES = %w[Export::Gtfs Export::NetexGeneric Export::Ara].freeze
              
                belongs_to :line_referential, dependent: :destroy, required: true
              Severity: Minor
              Found in app/models/workgroup.rb - About 3 hrs to fix

                Class Workbench has 26 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Workbench < ApplicationModel
                  prepend LockedReferentialToAggregateWithLog
                
                  include ObjectidFormatterSupport
                
                
                Severity: Minor
                Found in app/models/workbench.rb - About 3 hrs to fix

                  Class Line has 26 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class Line < Chouette::ActiveRecord
                      # Must be defined before ObjectidSupport
                      before_validation :define_line_referential, on: :create
                      before_validation :update_unpermitted_blank_values
                  
                  
                  Severity: Minor
                  Found in app/models/chouette/line.rb - About 3 hrs to fix

                    File experimental.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module Merge::Referential
                    
                      module Sanitizer
                        def sanitize_joins(query)
                          # in fact, new.slug is already sanitized but .. it is better to be safe than sorry.
                    Severity: Minor
                    Found in app/models/merge/referential/experimental.rb - About 3 hrs to fix

                      Method thead has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def thead(collection, columns, sortable, selectable, has_links, overhead, model, action)
                          content_tag :thead do
                            # Inserts overhead content if any specified
                            over_head = ''
                      
                      
                      Severity: Major
                      Found in app/helpers/table_builder_helper.rb - About 2 hrs to fix

                        Method table_builder has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def table_builder collection, columns, actions, selectable = [], cls = nil
                            return unless collection.present?
                        
                            head = content_tag :thead do
                              content_tag :tr do
                        Severity: Major
                        Found in app/helpers/newapplication_helper.rb - About 2 hrs to fix

                          Function vehicleJourney has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const vehicleJourney= (state = {}, action, keep) => {
                            switch (action.type) {
                              case 'SELECT_VEHICLEJOURNEY':
                                return _.assign({}, state, {selected: !state.selected})
                              case 'CANCEL_SELECTION':
                          Severity: Minor
                          Found in app/packs/src/vehicle_journeys/reducers/vehicleJourneys.js - About 2 hrs 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_serialize_option has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def handle_serialize_option attribute_name, opts
                                  serializer = opts[:serialize]
                              
                                  define_method attribute_name do
                                    return nil unless respond_to?(:options)
                          Severity: Minor
                          Found in app/models/concerns/options_support.rb - About 2 hrs 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_or_create_journey_pattern has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def find_or_create_journey_pattern(resource, trip, stop_times)
                              journey_pattern_id = journey_pattern_ids[trip_signature(trip, stop_times)]
                              return Chouette::JourneyPattern.find(journey_pattern_id) if journey_pattern_id
                              stop_points = []
                          
                          
                          Severity: Minor
                          Found in app/models/import/gtfs.rb - About 2 hrs 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_transfers has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def import_transfers
                              @trips = {}
                              create_resource(:transfers).each(source.transfers, slice: 100, transaction: true) do |transfer, resource|
                                next unless transfer.type == '2'
                                from_id = @stop_areas_id_by_registration_number[transfer.from_stop_id]
                          Severity: Minor
                          Found in app/models/import/gtfs.rb - About 2 hrs 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 21 (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,MONDAY)
                                  valid_days << 2  if day_by_mask(int_day_types,TUESDAY)
                          Severity: Minor
                          Found in app/models/concerns/application_days_support.rb - About 2 hrs 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_periods! has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def remove_periods!(removed_periods)
                                deleted_dates = []
                                dates.each do |date|
                                  if removed_periods.any? { |p| p.include? date.date }
                                     deleted_dates << date
                          Severity: Minor
                          Found in app/models/chouette/time_table.rb - About 2 hrs 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