af83/chouette-core

View on GitHub
app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js

Summary

Maintainability
F
1 wk
Test Coverage

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

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

    File ConstraintExclusionEditVehicleJourney.js has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import _ from 'lodash'
    import React, { Component } from 'react'
    import PropTypes from 'prop-types'
    import actions from '../../actions'
    import ConstraintZoneSelect2 from './select2s/ConstraintZoneSelect2'

      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

      Consider simplifying this complex logical expression.
      Open

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

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

                                { this.props.stopAreasConstraints && <div className='row'>
                                  <div className='col-lg-12'>
                                    <div className='subform'>
                                      <div className='nested-head'>
                                        <div className='wrapper'>
        app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 140..196

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

        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='row'>
                                  <div className='col-lg-12'>
                                    <div className='subform'>
                                      <div className='nested-head'>
                                        <div className='wrapper'>
        app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 198..254

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

        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

          fetch_stop_area_constraints() {
            if(this.fetching_stop_area_constraints){ return }
            this.fetching_stop_area_constraints = true
        
            let url = window.stop_area_constraints_routes + ".json"
        app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 58..77

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

        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

          fetch_constraint_zones() {
            if(this.fetching_constraint_zones){ return }
            this.fetching_constraint_zones = true
        
            let url = window.constraint_zones_routes + ".json"
        app/packs/src/vehicle_journeys/components/tools/ConstraintExclusionEditVehicleJourney.js on lines 79..98

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

        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

                  <button
                    type='button'
                    disabled={(actions.getSelected(this.props.vehicleJourneys).length < 1 || this.props.disabled)}
                    data-toggle='modal'
                    data-target='#ConstraintExclusionEditVehicleJourney'
        app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 31..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 140.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

                              {
                                this.props.editMode &&
                                <div className='modal-footer'>
                                  <button
                                    className='btn btn-cancel'
        app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 116..135

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

        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

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

        ConstraintExclusionEditVehicleJourney.propTypes = {
          onOpenCalendarsEditModal: PropTypes.func.isRequired,
          onModalClose: PropTypes.func.isRequired,
          disabled: PropTypes.bool.isRequired
        }
        app/packs/src/helpers/CustomFieldsInputs.js on lines 89..93
        app/packs/src/journey_patterns/components/ConfirmModal.js on lines 44..48
        app/packs/src/journey_patterns/components/SaveJourneyPattern.js on lines 20..24
        app/packs/src/shape_editor/components/SaveButton.jsx on lines 44..48
        app/packs/src/shape_editor/components/ShapeEditorMap.jsx on lines 99..103
        app/packs/src/time_tables/components/ConfirmModal.js on lines 44..48
        app/packs/src/time_tables/components/Navigate.js on lines 100..104
        app/packs/src/time_tables/components/SaveTimetable.js on lines 38..42
        app/packs/src/time_tables/components/TimeTableDay.js on lines 28..32
        app/packs/src/vehicle_journeys/components/Tools.js on lines 82..86
        app/packs/src/vehicle_journeys/components/tools/CopyButton.js on lines 22..26
        app/packs/src/vehicle_journeys/components/tools/DeleteVehicleJourneys.js on lines 25..29
        app/packs/src/vehicle_journeys/components/tools/DuplicateVehicleJourney.js on lines 207..211
        app/packs/src/vehicle_journeys/components/tools/EditVehicleJourney.js on lines 220..224
        app/packs/src/vehicle_journeys/components/tools/PasteButton.js on lines 24..28
        app/packs/src/vehicle_journeys/components/tools/SelectSpecificStop.js on lines 211..215
        app/packs/src/vehicle_journeys/components/tools/SelectVehicleJourneys.js on lines 25..29
        app/packs/src/vehicle_journeys/components/tools/ShiftVehicleJourney.js on lines 118..122

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

        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

        There are no issues that match your filters.

        Category
        Status