af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

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

SaveVehicleJourneys.propTypes = {
  vehicleJourneys: PropTypes.array.isRequired,
  page: PropTypes.number.isRequired,
  status: PropTypes.object.isRequired,
  filters: PropTypes.object.isRequired,
app/packs/src/routes/components/StopPointList.js on lines 67..75
app/packs/src/routes/components/form/TextInput.js on lines 20..28
app/packs/src/time_tables/components/PeriodForm.js on lines 143..151

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

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 4 locations. Consider refactoring.
Open

TextInput.proptypes = {
  inputId: PropTypes.string.isRequired,
  inputName: PropTypes.string.isRequired,
  labelText: PropTypes.string.isRequired,
  value: PropTypes.string.isRequired,
Severity: Major
Found in app/packs/src/routes/components/form/TextInput.js and 3 other locations - About 3 hrs to fix
app/packs/src/routes/components/StopPointList.js on lines 67..75
app/packs/src/time_tables/components/PeriodForm.js on lines 143..151
app/packs/src/vehicle_journeys/components/SaveVehicleJourneys.js on lines 20..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 103.

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

  render() {
    this.previousCity = undefined
    requestAnimationFrame(function(){
      $(document).trigger("table:updated")
    })
Severity: Major
Found in app/packs/src/journey_patterns/components/JourneyPatterns.js - About 3 hrs to fix

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

      class VehicleJourneyAtStop < ::ActiveRecord::Base
        include Chouette::ForBoardingEnumerations
        include Chouette::ForAlightingEnumerations
        include ChecksumSupport
    
    
    Severity: Minor
    Found in app/models/chouette/vehicle_journey_at_stop.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

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

        def option_input(form, export, attr, option_def, type)
          attr = option_def[:name] if option_def[:name].present?
      
          value = export.try(attr) || option_def[:default_value]
      
      
      Severity: Minor
      Found in app/helpers/options_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

      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

      Method candidate_target_attributes has 80 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

        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

        Class ApplicationPolicy has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class ApplicationPolicy
          attr_reader :current_referential, :current_workbench, :current_workgroup, :record, :user
        
          def initialize(user_context, record)
            @user                = user_context.user
        Severity: Minor
        Found in app/policies/application_policy.rb - About 3 hrs to fix

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

              def process_trip(resource, trip, stop_times)
                begin
                  raise InvalidTripSingleStopTime unless stop_times.many?
            
                  journey_pattern = find_or_create_journey_pattern(resource, trip, stop_times)
            Severity: Major
            Found in app/models/import/gtfs.rb - 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

                      else{
                        if (action.isShown){
                          newModalProps.vehicleJourney.footnotes.push(action.footnote)
                        }else{
                          newModalProps.vehicleJourney.footnotes = newModalProps.vehicleJourney.footnotes.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 27..33

                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

                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