af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

Method save_model has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def save_model(model, filename: nil, line_number: nil, column_number: nil, resource: nil)
    return unless model.changed?

    if resource
      filename ||= "#{resource.name}.txt"
Severity: Minor
Found in app/models/concerns/local_import_support.rb - About 1 hr to fix

    Method line_params has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def line_params
        return @line_params if @line_params
    
        out = params.require(:line).permit(
          :activated,
    Severity: Minor
    Found in app/controllers/lines_controller.rb - About 1 hr to fix

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

              for(var nth = 1; nth < refH.length; nth++) {
                $(this).find('.td:nth-child('+ (nth + 1) +')').css('height', refCol[nth]);
              }
      app/packs/src/vehicle_journeys/components/VehicleJourneysList.js on lines 152..154

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

      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

              for(var nth = 1; nth < refH.length; nth++) {
                $(this).find('.td:nth-child('+ (nth + 1) +')').css('height', refCol[nth]);
              }
      app/packs/src/journey_patterns/components/JourneyPatterns.js on lines 57..59

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

      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

                [
                  <li key={`edit_shape_${id}`}>
                    <button
                      type='button'
                      onClick={onEditShape}
      Severity: Major
      Found in app/packs/src/journey_patterns/components/JourneyPattern.js and 1 other location - About 1 hr to fix
      app/packs/src/journey_patterns/components/JourneyPattern.js on lines 179..188

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

      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

            return [
              <li key={`create_shape_${id}`}>
                <button
                  type='button'
                  onClick={onCreateShape}
      Severity: Major
      Found in app/packs/src/journey_patterns/components/JourneyPattern.js and 1 other location - About 1 hr to fix
      app/packs/src/journey_patterns/components/JourneyPattern.js on lines 192..201

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

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

      export default function Navigate({ dispatch, metas, timetable, pagination, status, filters}) {
        if(status.isFetching == true) {
          return false
        }
        if(status.fetchSuccess == true) {
      Severity: Minor
      Found in app/packs/src/time_tables/components/Navigate.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 aggregate! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def aggregate!
          Rails.logger.tagged("Aggregate ##{id}") do
            measure 'aggregate', aggregate: id do
              prepare_new
      
      
      Severity: Minor
      Found in app/models/aggregate.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 initialize_custom_field has a Cognitive Complexity of 13 (exceeds 5 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: Minor
      Found in app/models/custom_field.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 new_ostruct_member! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def new_ostruct_member! name
            @_initialized_members ||= []
            unless is_timestamp_attr?(name)
              timestamp_attr_name = timestamp_attr(name)
            end
      Severity: Minor
      Found in app/models/concerns/metadata_support.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 merge_flattened_periods has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge_flattened_periods periods
            return [trim_period(periods.last)].compact unless periods.size > 1
      
            merged = []
            current = periods[0]
      Severity: Minor
      Found in app/models/chouette/vehicle_journey.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 input has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def input(wrapper_options = {})
          selected_color = object.send(attribute_name)
          label = if selected_color
            collection.find{|i| i.is_a?(Enumerable) && i.last == selected_color}.try(:first)
          end
      Severity: Minor
      Found in app/inputs/color_select_input.rb - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

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

        class Company
          def initialize(query_ctx, company_id)
            @company_id = company_id
            # Initialize the loading state for this query or get the previously-initiated state
            @lazy_state = query_ctx[:lazy_find_company] ||= {
      Severity: Major
      Found in app/graphql/lazy_loading/company.rb and 2 other locations - About 1 hr to fix
      app/graphql/lazy_loading/network.rb on lines 2..31
      app/graphql/lazy_loading/stop_relation.rb on lines 2..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 65.

      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

        def connection_link_arrival_metadatas(connection_link, workbench)
          attributes = {
            t('id_reflex') => connection_link_id_with_icon_color('blue', connection_link.arrival.get_objectid.short_id),
            Chouette::StopArea.tmf('name') => link_to(connection_link.arrival.name, workbench_stop_area_referential_stop_area_path(workbench, connection_link.arrival)),
          }
      Severity: Major
      Found in app/helpers/connection_links_helper.rb and 1 other location - About 1 hr to fix
      app/helpers/connection_links_helper.rb on lines 48..55

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

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

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

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

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

      Refactorings

      Further Reading

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

        class StopRelation
          def initialize(query_ctx, stop_relation_id)
            @stop_relation_id = stop_relation_id
            # Initialize the loading state for this query or get the previously-initiated state
            @lazy_state = query_ctx[:lazy_find_stop_relation] ||= {
      Severity: Major
      Found in app/graphql/lazy_loading/stop_relation.rb and 2 other locations - About 1 hr to fix
      app/graphql/lazy_loading/company.rb on lines 2..31
      app/graphql/lazy_loading/network.rb on lines 2..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 65.

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

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

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

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

      Refactorings

      Further Reading

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

        class Network
          def initialize(query_ctx, network_id)
            @network_id = network_id
            # Initialize the loading state for this query or get the previously-initiated state
            @lazy_state = query_ctx[:lazy_find_network] ||= {
      Severity: Major
      Found in app/graphql/lazy_loading/network.rb and 2 other locations - About 1 hr to fix
      app/graphql/lazy_loading/company.rb on lines 2..31
      app/graphql/lazy_loading/stop_relation.rb on lines 2..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 65.

      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

        def connection_link_departure_metadatas(connection_link, workbench)
          attributes = {
            t('id_reflex') => connection_link_id_with_icon_color('orange', connection_link.departure.get_objectid.short_id),
            Chouette::StopArea.tmf('name') => link_to(connection_link.departure.name, workbench_stop_area_referential_stop_area_path(workbench, connection_link.departure)),
          }
      Severity: Major
      Found in app/helpers/connection_links_helper.rb and 1 other location - About 1 hr to fix
      app/helpers/connection_links_helper.rb on lines 58..65

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

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

        submitJourneyPattern : (dispatch, state, next) => {
          dispatch(actions.fetchingApi())
          let urlJSON = window.location.pathname + ".json"
          let hasError = false
          fetch(urlJSON, {
      Severity: Minor
      Found in app/packs/src/journey_patterns/actions/index.js - About 1 hr to fix

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

          render() {
            return (
              <Select2
                id={this.props.id}
                value={ this.props.value.stoparea_id }
        Severity: Minor
        Found in app/packs/src/routes/components/BSelect2.js - About 1 hr to fix

          Function mapDispatchToProps has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const mapDispatchToProps = (dispatch) => {
            return {
              onDeleteClick: (index, stopPointId) =>{
                dispatch(actions.deleteStop(index, stopPointId))
                dispatch(actions.closeMaps())
          Severity: Minor
          Found in app/packs/src/routes/containers/VisibleStopPoints.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language