af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method fetch has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def self.fetch key, opts={}
    key = key.to_s
    unless keys.include?(key)
      logger.warn("Fetching unexpected ENV key `#{key}`")
      keys << key
Severity: Minor
Found in app/lib/smart_env.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

  class Batch
    def address(position, key: nil)
      item = Item.new(position)

      # Reuse an already defined Item
Severity: Major
Found in app/lib/reverse_geocode.rb and 1 other location - About 2 hrs to fix
app/lib/route_planner.rb on lines 23..72

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

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

  class Batch
    def shape(points, key: nil)
      item = Item.new(points)

      # Reuse an already defined Item
Severity: Major
Found in app/lib/route_planner.rb and 1 other location - About 2 hrs to fix
app/lib/reverse_geocode.rb on lines 23..72

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

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

  render() {
    if(this.props.status.isFetching == true) {
      return (
        <div className="isLoading" style={{marginTop: 80, marginBottom: 80}}>
          <div className="loader"></div>
Severity: Major
Found in app/packs/src/time_tables/components/Timetable.js - About 2 hrs to fix

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

    export default class SaveVehicleJourneys extends SaveButton{
      hasPolicy(){
        return this.props.filters.policy['vehicle_journeys.update'] == true
      }
    
    
    app/packs/src/journey_patterns/components/SaveJourneyPattern.js on lines 6..18

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

    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

    export default class SaveJourneyPattern extends SaveButton {
      hasPolicy(){
        return this.props.status.policy['journey_patterns.update'] == true
      }
    
    
    app/packs/src/vehicle_journeys/components/SaveVehicleJourneys.js on lines 6..18

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

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

      def tr item, columns, selectable, links, overhead, model_name, action
        klass = "#{model_name} #{model_name}-#{item.id}"
        content_tag :tr, class: klass do
          bcont = []
          if selectable
    Severity: Major
    Found in app/helpers/table_builder_helper.rb - About 2 hrs to fix

      Class TimeOfDay has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class TimeOfDay
        include Comparable
      
        attr_reader :hour, :minute, :second, :day_offset, :utc_offset, :second_offset
        alias min minute
      Severity: Minor
      Found in app/lib/time_of_day.rb - About 2 hrs to fix

        Class Link has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class AF83::Decorator::Link
          REQUIRED_ATTRIBUTES = %i(href content)
        
          attr_reader :context
          attr_reader :action
        Severity: Minor
        Found in app/lib/af83/decorator/link.rb - About 2 hrs to fix

          File modal.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import _ from 'lodash'
          
          let vehicleJourneysModal, newModalProps, vehicleJourney, alreadyPresent, notAlreadyPresent, newReferentialCodesArray, selectedConstraintZones, selectedStopAreasConstraints
          
          export default function modal(state = {}, action) {
          Severity: Minor
          Found in app/packs/src/vehicle_journeys/reducers/modal.js - About 2 hrs to fix

            Method legacy_merge_vehicle_journeys has 69 lines of code (exceeds 25 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: Major
            Found in app/models/merge/referential/legacy.rb - About 2 hrs to fix

              Method state_update has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.state_update route, state
                    objects = []
                    transaction do
                      state.each do |item|
                        item.delete('errors')
              Severity: Minor
              Found in app/models/chouette/vehicle_journey.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 polymorphic_url_parts has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.polymorphic_url_parts(item, referential, workgroup)
                    polymorph_url = []
              
                    unless item.is_a?(Calendar) || item.is_a?(Referential)
                      if referential
              Severity: Minor
              Found in app/helpers/table_builder_helper/url.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 6 locations. Consider refactoring.
              Open

              Timetable.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/Timetable.js and 5 other locations - About 2 hrs to fix
              app/packs/src/routes/components/SaveRoute.js on lines 39..46
              app/packs/src/routes/components/form/SelectInput.js on lines 27..34
              app/packs/src/time_tables/components/ExceptionsInDay.js on lines 65..72
              app/packs/src/vehicle_journeys/components/SelectableContainer.js on lines 93..100
              app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 151..158

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

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

              SelectableContainer.propTypes = {
                  selectionMode: PropTypes.bool.isRequired,
                  toggleArrivals: PropTypes.bool.isRequired,
                  updateSelectedItems: PropTypes.func.isRequired,
                  updateSelectionDimensions: PropTypes.func.isRequired,
              app/packs/src/routes/components/SaveRoute.js on lines 39..46
              app/packs/src/routes/components/form/SelectInput.js on lines 27..34
              app/packs/src/time_tables/components/ExceptionsInDay.js on lines 65..72
              app/packs/src/time_tables/components/Timetable.js on lines 105..112
              app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 151..158

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

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

              SelectInput.proptypes = {
                inputId: PropTypes.string.isRequired,
                inputName: PropTypes.string.isRequired,
                value: PropTypes.string.isRequired,
                labelText: PropTypes.string.isRequired,
              Severity: Major
              Found in app/packs/src/routes/components/form/SelectInput.js and 5 other locations - About 2 hrs to fix
              app/packs/src/routes/components/SaveRoute.js on lines 39..46
              app/packs/src/time_tables/components/ExceptionsInDay.js on lines 65..72
              app/packs/src/time_tables/components/Timetable.js on lines 105..112
              app/packs/src/vehicle_journeys/components/SelectableContainer.js on lines 93..100
              app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 151..158

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

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

              TimetablesEditVehicleJourney.propTypes = {
                onOpenCalendarsEditModal: PropTypes.func.isRequired,
                onModalClose: PropTypes.func.isRequired,
                onTimetablesEditVehicleJourney: PropTypes.func.isRequired,
                onDeleteCalendarModal: PropTypes.func.isRequired,
              app/packs/src/routes/components/SaveRoute.js on lines 39..46
              app/packs/src/routes/components/form/SelectInput.js on lines 27..34
              app/packs/src/time_tables/components/ExceptionsInDay.js on lines 65..72
              app/packs/src/time_tables/components/Timetable.js on lines 105..112
              app/packs/src/vehicle_journeys/components/SelectableContainer.js on lines 93..100

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

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

              ExceptionsInDay.propTypes = {
                value: PropTypes.object.isRequired,
                metas: PropTypes.object.isRequired,
                blueDaytype: PropTypes.bool.isRequired,
                onExcludeDateFromPeriod: PropTypes.func.isRequired,
              Severity: Major
              Found in app/packs/src/time_tables/components/ExceptionsInDay.js and 5 other locations - About 2 hrs to fix
              app/packs/src/routes/components/SaveRoute.js on lines 39..46
              app/packs/src/routes/components/form/SelectInput.js on lines 27..34
              app/packs/src/time_tables/components/Timetable.js on lines 105..112
              app/packs/src/vehicle_journeys/components/SelectableContainer.js on lines 93..100
              app/packs/src/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js on lines 151..158

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

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

                def self.add key, opts={}
                  key = key.to_s
                  keys << key unless keys.include?(key)
                  if opts.has_key?(:required)
                    required_keys.delete key
              Severity: Minor
              Found in app/lib/smart_env.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 commit has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def commit
                    begin
                      return if resolution_stack.empty?
              
                      Apartment::Tenant.switch @current_tenant do
              Severity: Minor
              Found in app/lib/chouette/checksum_manager/transactional.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