af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method candidate_target_attributes has 84 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::StopArea
            select Chouette::StopArea, :name
            select Chouette::StopArea, :country_code
Severity: Major
Found in app/models/control/presence_attribute.rb - About 3 hrs to fix

    Class Workbench has 28 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 Route has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Route < Referential::Model
          has_metadata
      
          attr_accessor :prevent_costs_calculation
      
      
      Severity: Minor
      Found in app/models/chouette/route.rb - About 3 hrs to fix

        Class JourneyPattern has 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class JourneyPattern < Referential::Model
            include CustomFieldsSupport
            has_metadata
        
            include TransientSupport
        Severity: Minor
        Found in app/models/chouette/journey_pattern.rb - About 3 hrs to fix

          Class VehicleJourneyAtStop has 28 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class VehicleJourneyAtStop < Referential::ActiveRecord
              include ChecksumSupport
          
              include Chouette::ForBoardingEnumerations
              include Chouette::ForAlightingEnumerations
          Severity: Minor
          Found in app/models/chouette/vehicle_journey_at_stop.rb - About 3 hrs to fix

            Class Base has 28 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Base
                extend ActiveModel::Naming
                extend Enumerize
            
                include ActiveModel::Validations
            Severity: Minor
            Found in app/lib/search/base.rb - About 3 hrs to fix

              Method process_trip has 83 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def process_trip(resource, trip, stop_times)
                  begin
                    raise InvalidTripSingleStopTime unless stop_times.many?
                    raise InvalidTripTimesError unless consistent_stop_times(stop_times)
              
              
              Severity: Major
              Found in app/models/import/gtfs.rb - About 3 hrs to fix

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

                  excluded_stop_area_constraints() {
                    let out = []
                    this.props.modal.modalProps.selectedStopAreasConstraints.map((id, _)=>{
                      this.stop_area_constraints.map((zone, _)=>{
                        if(zone.id == id){
                app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 34..44

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

                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

                  excluded_constraint_zones() {
                    let out = []
                    this.props.modal.modalProps.selectedConstraintZones.map((id, _)=>{
                      this.constraint_zones.map((zone, _)=>{
                        if(zone.id == id){
                app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 46..56

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

                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

                Method merge! has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                  def merge!
                    Rails.logger.info "Start Merge##{id} merge for #{referential_ids}"
                
                    CustomFieldsSupport.within_workgroup(workgroup) do
                      Chouette::Benchmark.measure('merge', merge: id) do
                Severity: Minor
                Found in app/models/merge.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 set_date_time_params has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                    def set_date_time_params(param_name, klass, prefix: nil)
                      start_date = []
                      end_date = []
                
                      if params[:q] && params[:q][param_name] && !params[:q][param_name].has_value?(nil) && !params[:q][param_name].has_value?("")
                Severity: Minor
                Found in app/controllers/concerns/ransack_date_filter.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

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

                    case 'REMOVE_EXCLUDED_DATE':
                      newDates = reject(state.time_table_dates, ['date', action.date])
                      newCM = state.current_month.map((d, i) => {
                        if (i == action.index) d.excluded_date = false
                        return d
                Severity: Major
                Found in app/packs/src/time_tables/reducers/timetable.js and 1 other location - About 3 hrs to fix
                app/packs/src/time_tables/reducers/timetable.js on lines 53..59

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

                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

                    case 'REMOVE_INCLUDED_DATE':
                      newDates = reject(state.time_table_dates, ['date', action.date])
                      newCM = state.current_month.map((d, i) => {
                        if (i == action.index) d.include_date = false
                        return d
                Severity: Major
                Found in app/packs/src/time_tables/reducers/timetable.js and 1 other location - About 3 hrs to fix
                app/packs/src/time_tables/reducers/timetable.js on lines 67..73

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

                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

                        {hasFeature('costs_in_journey_patterns') &&
                          <div className="small row totals commercial">
                            <span className="col-md-5"><i className="fas fa-arrows-alt-h"></i>{commercialTotalDistance}</span>
                            <span className="col-md-6"><i className="fa fa-clock"></i>{commercialTotalTime}</span>
                          </div>
                Severity: Major
                Found in app/packs/src/journey_patterns/components/JourneyPattern.js and 1 other location - About 3 hrs to fix
                app/packs/src/journey_patterns/components/JourneyPattern.js on lines 230..235

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

                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

                        {hasFeature('costs_in_journey_patterns') &&
                          <div className="small row totals">
                            <span className="col-md-5"><i className="fas fa-arrows-alt-h"></i>{totalDistance}</span>
                            <span className="col-md-6"><i className="fa fa-clock"></i>{totalTime}</span>
                          </div>
                Severity: Major
                Found in app/packs/src/journey_patterns/components/JourneyPattern.js and 1 other location - About 3 hrs to fix
                app/packs/src/journey_patterns/components/JourneyPattern.js on lines 236..241

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

                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 TopologicReferentialController < WorkbenchController
                    # To prevent a "chouette_" to be added to all its chidren
                    resources_configuration[:self].delete(:route_prefix)
                
                    include ControllerResourceValidations
                Severity: Major
                Found in app/controllers/chouette/topologic_referential_controller.rb and 1 other location - About 3 hrs to fix
                app/controllers/chouette/stop_area_referential_controller.rb on lines 4..62

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

                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 StopAreaReferentialController < WorkbenchController
                    # To prevent a "chouette_" to be added to all its chidren
                    resources_configuration[:self].delete(:route_prefix)
                
                    include ControllerResourceValidations
                Severity: Major
                Found in app/controllers/chouette/stop_area_referential_controller.rb and 1 other location - About 3 hrs to fix
                app/controllers/chouette/topologic_referential_controller.rb on lines 4..61

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

                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 journeyPatterns has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function journeyPatterns (state = [], action)  {
                  switch (action.type) {
                    case 'RECEIVE_JOURNEY_PATTERNS':
                      return [...action.json]
                    case 'RECEIVE_ERRORS':
                Severity: Major
                Found in app/packs/src/journey_patterns/reducers/journeyPatterns.js - About 3 hrs to fix

                  Method import_transfers has 79 lines of code (exceeds 25 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: Major
                  Found in app/models/import/gtfs.rb - About 3 hrs to fix

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

                          if(action.footnote.line_notice){
                            if (action.isShown){
                              newModalProps.vehicleJourney.line_notices.push(action.footnote)
                            }else{
                              newModalProps.vehicleJourney.line_notices = newModalProps.vehicleJourney.line_notices.filter((f) => {return f.id != action.footnote.id })
                    Severity: Major
                    Found in app/packs/src/vehicle_journeys/reducers/modal.js and 1 other location - About 3 hrs to fix
                    app/packs/src/vehicle_journeys/reducers/modal.js on lines 34..40

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

                    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