af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method ransack_transport_mode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def ransack_transport_mode scope
      return scope unless params[:q].try(:[], :transport_mode) || params[:q].try(:[], :transport_submode)

      @transport_modes = params[:q][:transport_mode].keys  if params[:q].has_key?(:transport_mode)
      @transport_submodes = params[:q][:transport_submode].keys if params[:q].has_key?(:transport_submode)
Severity: Minor
Found in app/controllers/concerns/transport_mode_filter.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

          <div>
            <BSelect2 {...this.props} onSelect={ this.onChange.bind(this) }/>
            { hasError && <span className='help-block small'>{I18n.t('activerecord.errors.models.route.attributes.stop_points.empty_stop_point')}</span> }
          </div>
Severity: Major
Found in app/packs/src/routes/components/BSelect2.js and 1 other location - About 1 hr to fix
app/packs/src/routes/components/BSelect2.js on lines 57..60

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

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

        <div className={`select2-bootstrap-append ${hasError && 'has-error'}`}>
          <BSelect2 {...this.props} onSelect={ this.onChange.bind(this) }/>
          { hasError && <span className='help-block small'>{I18n.t('activerecord.errors.models.route.attributes.stop_points.empty_stop_point')}</span> }
        </div>
Severity: Major
Found in app/packs/src/routes/components/BSelect2.js and 1 other location - About 1 hr to fix
app/packs/src/routes/components/BSelect2.js on lines 65..68

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

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

Function componentDidUpdate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  componentDidUpdate(prevProps, prevState) {
    if(this.props.status.isFetching == false){
      $('.table-2entries').each(function() {
        $(this).find('.th').css('height', 'auto')
        var refH = []
Severity: Minor
Found in app/packs/src/vehicle_journeys/components/VehicleJourneysList.js - About 1 hr to fix

    Method state_update has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def state_update state
        update_attributes(self.class.state_permited_attributes(state))
        self.calendar_id = nil if self.respond_to?(:calendar_id) && !state['calendar']
    
        days = state['day_types'].split(',')
    Severity: Minor
    Found in app/models/concerns/timetable_support.rb - About 1 hr to fix

      Method line_params has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def line_params
          out = params.require(:line)
          out = out.permit(
            :activated,
            :active_from,
      Severity: Minor
      Found in app/controllers/lines_controller.rb - About 1 hr to fix

        Method stop_area_params has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def stop_area_params
            fields = [
              :area_type,
              :children_ids,
              :city_name,
        Severity: Minor
        Found in app/controllers/stop_areas_controller.rb - About 1 hr to fix

          Method show has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def show
              @q = route.journey_patterns
              if params[:q].present?
                ids = @q.ransack(params[:q]).result(distinct: true).pluck(:id)
                @q = @q.where(id: ids)
          Severity: Minor
          Found in app/controllers/journey_patterns_collections_controller.rb - About 1 hr to fix

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

                                      className={'btn btn-default ' + (this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm ? 'disabled' : '')}
            app/packs/src/vehicle_journeys/components/tools/DuplicateVehicleJourney.js on lines 69..69

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

            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

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

                let noInputChanges = this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm
            app/packs/src/vehicle_journeys/components/tools/DuplicateVehicleJourney.js on lines 185..185

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

            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

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

              render() {
                if (!this.hasPolicy()) {
                  return false
                }
                return (
            Severity: Minor
            Found in app/packs/src/helpers/cancel_button.js - About 1 hr to fix

              Method compute_for_referential has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def compute_for_referential(referential)
                    Chouette::Benchmark.measure 'service_counts', referential: referential.id do
                      referential_inserter = ReferentialInserter.new(referential) do |config|
                        config.add(IdInserter)
                        config.add(CopyInserter)
              Severity: Minor
              Found in app/models/service_count.rb - About 1 hr to fix

                Method collection has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def collection
                    scope = select_time_tables
                    scope = self.ransack_period_range(scope: scope, error_message: t('referentials.errors.validity_period'), query: :overlapping)
                    @q = scope.ransack(params[:q])
                
                
                Severity: Minor
                Found in app/controllers/time_tables_controller.rb - About 1 hr to fix

                  Method checksum_parents has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.checksum_parents object
                      klass = object.class
                      return [] unless klass.respond_to? :checksum_parent_relations
                      return [] unless klass.checksum_parent_relations
                  
                  
                  Severity: Minor
                  Found in app/lib/chouette/checksum_manager.rb - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if(this.props.status.fetchSuccess == true) {
                          return (
                            <li className='st_action'>
                              <button
                                type='button'

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

                            class UserStatusFinalizer
                              def initialize(macro_list_run)
                                @macro_list_run = macro_list_run
                              end
                              attr_reader :macro_list_run
                      Severity: Major
                      Found in app/models/macro/list.rb and 1 other location - About 1 hr to fix
                      app/models/control/list.rb on lines 103..140

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

                      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 UserStatusFinalizer
                              def initialize(control_list_run)
                                @control_list_run = control_list_run
                              end
                              attr_reader :control_list_run
                      Severity: Major
                      Found in app/models/control/list.rb and 1 other location - About 1 hr to fix
                      app/models/macro/list.rb on lines 103..140

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

                      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

                      Function configs has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static get configs() {
                          return {
                            default: {
                              valueField: 'id',
                              labelField: 'text',
                      Severity: Minor
                      Found in app/packs/entrypoints/inputs/tom_select.js - About 1 hr to fix

                        Method fill_passing_times! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def fill_passing_times!
                              encountered_empty_vjas = []
                              previous_stop = nil
                              vehicle_journey_at_stops.each do |vjas|
                                sp = vjas.stop_point
                        Severity: Minor
                        Found in app/models/chouette/vehicle_journey.rb - About 1 hr to fix

                          Method save_model has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def save_model(model, filename: nil, line_number: nil, column_number: nil, resource: nil)
                              return unless model.changed?
                          
                              if resource
                                filename ||= "#{resource.name}.txt"
                          Severity: Minor
                          Found in app/models/concerns/local_import_support.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language