af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

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

              unless item.class == Calendar or item.class == Referential
                if current_referential
                  lnk << current_referential
                  lnk << item.line if item.respond_to? :line
                  lnk << item.route.line if item.class == Chouette::RoutingConstraintZone
Severity: Major
Found in app/helpers/newapplication_helper.rb and 1 other location - About 1 hr to fix
app/helpers/newapplication_helper.rb on lines 106..119

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

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

        unless item.class == Calendar or item.class == Referential
          if current_referential
            polymorph_url << current_referential
            polymorph_url << item.line if item.respond_to? :line
            polymorph_url << item.route.line if item.class == Chouette::RoutingConstraintZone
Severity: Major
Found in app/helpers/newapplication_helper.rb and 1 other location - About 1 hr to fix
app/helpers/newapplication_helper.rb on lines 55..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 74.

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 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 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: 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 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: 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 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 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

        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

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

          render() {
            return (
              <div
                className='period_manager'
                id={this.props.value.id}
        Severity: Minor
        Found in app/packs/src/time_tables/components/PeriodManager.js - About 1 hr to fix

          Method import_stop_areas has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def import_stop_areas
              @parent_stop_areas = {}
              stop_area_registration_numbers = Set.new
          
              each_element_matching_css('ChouettePTNetwork ChouetteArea') do |source_parent, _, progress|
          Severity: Minor
          Found in app/models/import/neptune.rb - About 1 hr to fix

            Function render has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              render() {
                let fetched = true
                if(this.constraint_zones === null) {
                  this.fetch_constraint_zones()
                  fetched = false

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function mapDispatchToProps has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            const mapDispatchToProps = (dispatch) => {
              return {
                onLoadFirstPage: (filters, routeUrl) =>{
                  dispatch(actions.fetchingApi())
                  actions.fetchVehicleJourneys(dispatch, undefined, undefined, filters.queryString, routeUrl)
            Severity: Minor
            Found in app/packs/src/vehicle_journeys/containers/VehicleJourneysList.js - 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

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

                  def run
                    journey_patterns.find_in_batches(batch_size: 100) do |group|
                      batch = workgroup.route_planner.batch
            
                      factories_by_ids = {}
            Severity: Minor
            Found in app/models/macro/create_shape.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

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

              def resources_are_identifiers
                resources.each do |resource_name, resource|
                  unless resource.attributes?
                    errors.add resource_name, "resource  required"
                    next
            Severity: Minor
            Found in app/models/webhook_event.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

            Severity
            Category
            Status
            Source
            Language