af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

File operation.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Operation < ApplicationModel
  self.abstract_class = true

  extend Enumerize

Severity: Minor
Found in app/models/operation.rb - About 2 hrs to fix

    Method validate_date_values has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_date_values
          date_values_are_valid = date_values.all?(&:valid?)
    
          date_values.each do |date_value|
            if date_values.count { |d| d.value == date_value.value } > 1
    Severity: Minor
    Found in app/models/concerns/date_support.rb - About 2 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 force_register_models_with_checksum has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.force_register_models_with_checksum
        paths = Rails.application.paths['app/models'].to_a
        Rails.application.railties.each do |tie|
          next unless tie.respond_to? :paths
          paths += tie.paths['app/models'].to_a
    Severity: Minor
    Found in app/models/referential.rb - About 2 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 wrong_calendar_data? has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def wrong_calendar_data? entry
        content = entry.get_input_stream.read
        periods = STIF::NetexFile::Frame.parse_calendars content.to_s
        periods.each do |period|
    
    
    Severity: Minor
    Found in app/services/zip_service.rb - About 2 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

                      <div className='modal-header'>
                        <h4 className='modal-title'>{I18n.t('vehicle_journeys.form.specific_stops_title', {id: id})}</h4>
                        <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                      </div>
    app/packs/src/vehicle_journeys/components/tools/ShiftVehicleJourney.js on lines 59..62

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    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='modal-header'>
                        <h4 className='modal-title'>{I18n.t('vehicle_journeys.form.slide_title', {id: id})}</h4>
                        <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
                      </div>
    app/packs/src/vehicle_journeys/components/tools/SelectSpecificStop.js on lines 135..138

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

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

      def find_or_create_journey_pattern(resource, trip, stop_times)
        journey_pattern_id = journey_pattern_ids[trip_signature(trip, stop_times)]
        return Chouette::JourneyPattern.find(journey_pattern_id) if journey_pattern_id
        stop_points = []
    
    
    Severity: Major
    Found in app/models/import/gtfs.rb - About 2 hrs to fix

      Method initialize_custom_field has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def initialize_custom_field
              custom_field_code = self.code
              _attr_name = attr_name
              _uploader_name = uploader_name
              _digest_name = digest_name
      Severity: Major
      Found in app/models/custom_field.rb - About 2 hrs to fix

        Class NetexImportCreator has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class NetexImportCreator
          include Measurable
          attr_reader :attributes, :file
        
          def initialize(workbench, attributes = {})
        Severity: Minor
        Found in app/services/netex_import_creator.rb - About 2 hrs to fix

          Method option_input has 53 lines of code (exceeds 25 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: Major
          Found in app/helpers/options_helper.rb - About 2 hrs to fix

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

            NotesEditVehicleJourney.propTypes = {
              onOpenNotesEditModal: PropTypes.func.isRequired,
              onModalClose: PropTypes.func.isRequired,
              onToggleFootnoteModal: PropTypes.func.isRequired,
              onNotesEditVehicleJourney: PropTypes.func.isRequired,
            app/packs/src/routes/components/form/SwitchInput.js on lines 24..30
            app/packs/src/time_tables/components/Metas.js on lines 111..117
            app/packs/src/time_tables/components/PeriodList.js on lines 84..90
            app/packs/src/vehicle_journeys/components/tools/CodesInputs.js on lines 86..92

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

            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

            Metas.propTypes = {
              metas: PropTypes.object.isRequired,
              onUpdateDayTypes: PropTypes.func.isRequired,
              onUpdateShared: PropTypes.func.isRequired,
              onUpdateColor: PropTypes.func.isRequired,
            Severity: Major
            Found in app/packs/src/time_tables/components/Metas.js and 4 other locations - About 2 hrs to fix
            app/packs/src/routes/components/form/SwitchInput.js on lines 24..30
            app/packs/src/time_tables/components/PeriodList.js on lines 84..90
            app/packs/src/vehicle_journeys/components/tools/CodesInputs.js on lines 86..92
            app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 184..190

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

            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

            CodesInputs.propTypes = {
              onUpdateReferentialCode: PropTypes.func.isRequired,
              onDeleteReferentialCode: PropTypes.func.isRequired,
              onAddReferentialCode: PropTypes.func.isRequired,
              values: PropTypes.array.isRequired,
            app/packs/src/routes/components/form/SwitchInput.js on lines 24..30
            app/packs/src/time_tables/components/Metas.js on lines 111..117
            app/packs/src/time_tables/components/PeriodList.js on lines 84..90
            app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 184..190

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

            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

            SwitchInput.proptypes = {
              inputId: PropTypes.string.isRequired,
              inputName: PropTypes.string.isRequired,
              labelText: PropTypes.string.isRequired,
              isChecked: PropTypes.bool.isRequired,
            Severity: Major
            Found in app/packs/src/routes/components/form/SwitchInput.js and 4 other locations - About 2 hrs to fix
            app/packs/src/time_tables/components/Metas.js on lines 111..117
            app/packs/src/time_tables/components/PeriodList.js on lines 84..90
            app/packs/src/vehicle_journeys/components/tools/CodesInputs.js on lines 86..92
            app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 184..190

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

            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

            PeriodList.propTypes = {
              metas: PropTypes.object.isRequired,
              timetable: PropTypes.object.isRequired,
              status: PropTypes.object.isRequired,
              onDeletePeriod: PropTypes.func.isRequired,
            Severity: Major
            Found in app/packs/src/time_tables/components/PeriodList.js and 4 other locations - About 2 hrs to fix
            app/packs/src/routes/components/form/SwitchInput.js on lines 24..30
            app/packs/src/time_tables/components/Metas.js on lines 111..117
            app/packs/src/vehicle_journeys/components/tools/CodesInputs.js on lines 86..92
            app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 184..190

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

            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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              render() {
                if(this.props.status.isFetching == true) {
                  return false
                }
                if(this.props.status.fetchSuccess == true) {

            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 initialize_custom_fields has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize_custom_fields
                  return if skip_custom_fields_initialization
                  return if custom_fields_initialized?
                  return unless self.attributes.has_key?("custom_field_values")
                  return unless self.workgroup.present?
            Severity: Minor
            Found in app/models/concerns/custom_fields_support.rb - About 2 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 average_bearings has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def average_bearings(options={})
                    options_ = options.dup
                    options_[:limit] = 5000 unless options_[:limit]
                    options_[:page] = 1 unless options_[:page]
                    options_[:debug_mode] = false
            Severity: Minor
            Found in app/models/chouette/stop_area.rb - About 2 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 legacy_merge_vehicle_journeys has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def legacy_merge_vehicle_journeys(referential_vehicle_journeys)
                referential_vehicle_journey_footnote_checksums = {}
                referential_vehicle_journey_codes = Hash.new { |h,k| h[k] = [] }
            
                referential.switch do
            Severity: Minor
            Found in app/models/merge/referential/legacy.rb - About 2 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 build_column_header has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def build_column_header(
                    column,
                    table_is_sortable,
                    model,
                    params
            Severity: Minor
            Found in app/helpers/table_builder_helper.rb - About 2 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

            Severity
            Category
            Status
            Source
            Language