af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method expand_multiparameter_attributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def expand_multiparameter_attributes(attributes)
    attributes ||= {}

    single_parameter_attributes = {}
    multi_parameter_attributes = {}
Severity: Minor
Found in app/lib/activeattr_ext.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 3 locations. Consider refactoring.
Open

  class Routes
    def initialize(query_ctx, line_id)
      @line_id = line_id
      # Initialize the loading state for this query or get the previously-initiated state
      @lazy_state = query_ctx[:lazy_find_routes] ||= {
Severity: Major
Found in app/graphql/lazy_loading/routes.rb and 2 other locations - About 1 hr to fix
app/graphql/lazy_loading/children.rb on lines 2..34
app/graphql/lazy_loading/route_stop_points.rb on lines 2..34

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

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

  class RouteStopPoints
    def initialize(query_ctx, route_id)
      @route_id = route_id
      # Initialize the loading state for this query or get the previously-initiated state
      @lazy_state = query_ctx[:lazy_find_route_stop_points] ||= {
Severity: Major
Found in app/graphql/lazy_loading/route_stop_points.rb and 2 other locations - About 1 hr to fix
app/graphql/lazy_loading/children.rb on lines 2..34
app/graphql/lazy_loading/routes.rb on lines 2..34

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

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

  class Children
    def initialize(query_ctx, stop_id)
      @stop_id = stop_id
      # Initialize the loading state for this query or get the previously-initiated state
      @lazy_state = query_ctx[:lazy_find_children] ||= {
Severity: Major
Found in app/graphql/lazy_loading/children.rb and 2 other locations - About 1 hr to fix
app/graphql/lazy_loading/route_stop_points.rb on lines 2..34
app/graphql/lazy_loading/routes.rb on lines 2..34

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

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

                  <div className='modal-header'>
                    <h4 className='modal-title'>{I18n.t('vehicle_journeys.form.footnotes')}</h4>
                    <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                  </div>
app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 132..135
app/packs/src/vehicle_journeys/components/tools/CreateModal.js on lines 56..59
app/packs/src/vehicle_journeys/components/tools/EditVehicleJourney.js on lines 62..65
app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 46..49

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

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

                  <div className='modal-header'>
                    <h4 className='modal-title'>{I18n.t('vehicle_journeys.form.time_tables')}</h4>
                    <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                  </div>
app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 132..135
app/packs/src/vehicle_journeys/components/tools/CreateModal.js on lines 56..59
app/packs/src/vehicle_journeys/components/tools/EditVehicleJourney.js on lines 62..65
app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 138..141

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

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

                  <div className='modal-header'>
                    <h4 className='modal-title'>{I18n.t('activerecord.attributes.vehicle_journey.constraint_exclusions')}</h4>
                    <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                  </div>
app/packs/src/vehicle_journeys/components/tools/CreateModal.js on lines 56..59
app/packs/src/vehicle_journeys/components/tools/EditVehicleJourney.js on lines 62..65
app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 138..141
app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 46..49

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

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

                  <div className='modal-header'>
                    <h4 className='modal-title'>{I18n.t('vehicle_journeys.form.infos')}</h4>
                    <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                  </div>
app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 132..135
app/packs/src/vehicle_journeys/components/tools/CreateModal.js on lines 56..59
app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 138..141
app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 46..49

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

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

                  <div className='modal-header'>
                    <h4 className='modal-title'>{I18n.t('vehicle_journeys.actions.new')}</h4>
                    <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                  </div>
app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 132..135
app/packs/src/vehicle_journeys/components/tools/EditVehicleJourney.js on lines 62..65
app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 138..141
app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 46..49

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

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

    def all_resources
      %w[
        aggregates
        accessibility_assessments
        api_keys
Severity: Minor
Found in app/models/permission.rb - About 1 hr to fix

    Function modal has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function modal(state = {}, action) {
      switch (action.type) {
        case 'OPEN_CONFIRM_MODAL':
          $('#ConfirmModal').modal('show')
          return _.assign({}, state, {
    Severity: Minor
    Found in app/packs/src/journey_patterns/reducers/modal.js - About 1 hr to fix

      Method truncate_time_table_periods has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def truncate_time_table_periods
          periods = Chouette::TimeTablePeriod
      
          truncated_periods = []
          case date_type.to_sym
      Severity: Minor
      Found in app/models/concerns/clean_up_methods.rb - About 1 hr to fix

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

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

          Method copy_with_inserters has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def copy_with_inserters
              source.switch do
                vehicle_journeys = source.vehicle_journeys.joins(:route).where("routes.line_id" => lines)
                time_tables = source.time_tables.joins(:vehicle_journeys).where('vehicle_journeys.id' => vehicle_journeys).distinct
          
          
          Severity: Minor
          Found in app/services/referential_copy.rb - About 1 hr to fix

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

                      <div style={{width: 100}}>
                        <div className="form-group">
                          <label className="control-label">{I18n.t('simple_form.labels.stop_point.reflex_id')}</label>
                        </div>
                      </div>
            Severity: Major
            Found in app/packs/src/routes/components/StopPointList.js and 3 other locations - About 1 hr to fix
            app/packs/src/routes/components/StopPointList.js on lines 22..26
            app/packs/src/routes/components/StopPointList.js on lines 27..31
            app/packs/src/routes/components/StopPointList.js on lines 32..36

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

            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

                      <div style={{width: 120}}>
                        <div className="form-group">
                          <label className="control-label">{I18n.t('simple_form.labels.stop_point.for_boarding')}</label>
                        </div>
                      </div>
            Severity: Major
            Found in app/packs/src/routes/components/StopPointList.js and 3 other locations - About 1 hr to fix
            app/packs/src/routes/components/StopPointList.js on lines 17..21
            app/packs/src/routes/components/StopPointList.js on lines 22..26
            app/packs/src/routes/components/StopPointList.js on lines 32..36

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

            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={'btn btn-link' + (props.first ? ' disabled' : '')}
                        onClick={props.first ? null : props.onMoveUpClick}
                      >
                        <span className='fa fa-arrow-up'></span>
            Severity: Major
            Found in app/packs/src/routes/components/StopPoint.js and 1 other location - About 1 hr to fix
            app/packs/src/routes/components/StopPoint.js on lines 49..54

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

            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

                      <div style={{width: 250}}>
                        <div className="form-group">
                          <label className="control-label">{I18n.t('simple_form.labels.stop_point.name')}</label>
                        </div>
                      </div>
            Severity: Major
            Found in app/packs/src/routes/components/StopPointList.js and 3 other locations - About 1 hr to fix
            app/packs/src/routes/components/StopPointList.js on lines 17..21
            app/packs/src/routes/components/StopPointList.js on lines 27..31
            app/packs/src/routes/components/StopPointList.js on lines 32..36

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

            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

                      <div style={{width: 120}}>
                        <div className="form-group">
                          <label className="control-label">{I18n.t('simple_form.labels.stop_point.for_alighting')}</label>
                        </div>
                      </div>
            Severity: Major
            Found in app/packs/src/routes/components/StopPointList.js and 3 other locations - About 1 hr to fix
            app/packs/src/routes/components/StopPointList.js on lines 17..21
            app/packs/src/routes/components/StopPointList.js on lines 22..26
            app/packs/src/routes/components/StopPointList.js on lines 27..31

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

            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={'btn btn-link' + (props.last ? ' disabled' : '')}
                        onClick={props.last ? null : props.onMoveDownClick}
                      >
                        <span className='fa fa-arrow-down'></span>
            Severity: Major
            Found in app/packs/src/routes/components/StopPoint.js and 1 other location - About 1 hr to fix
            app/packs/src/routes/components/StopPoint.js on lines 43..48

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

            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