af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

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

SaveRoute.propTypes = {
  status: PropTypes.object.isRequired,
  route: PropTypes.object.isRequired,
  stopPoints: PropTypes.array.isRequired,
  editMode: PropTypes.bool.isRequired,
Severity: Major
Found in app/packs/src/routes/components/SaveRoute.js and 5 other locations - About 2 hrs to fix
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
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 path has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def path
      if model_class == Chouette::Line
        workbench_line_referential_line_path(workbench, model_id)
      elsif model_class == Chouette::Company
        workbench_line_referential_company_path(workbench, model_id)
Severity: Minor
Found in app/lib/chouette/model_path_finder.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

Function SelectableContainer has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SelectableContainer = props => {
    const {
        children,
        clearSelectedItems,
        selectionMode,
Severity: Major
Found in app/packs/src/vehicle_journeys/components/SelectableContainer.js - About 2 hrs to fix

    Method links_builder has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def links_builder(item, actions)
        trigger = content_tag :div, class: 'btn dropdown-toggle', data: { toggle: 'dropdown' } do
          content_tag :span, '', class: 'fa fa-cog'
        end
    
    
    Severity: Major
    Found in app/helpers/newapplication_helper.rb - About 2 hrs to fix

      Function filters has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function  filters(state = {}, action) {
        switch (action.type) {
          case 'RESET_FILTERS':
            let interval = {
              start:{
      Severity: Major
      Found in app/packs/src/vehicle_journeys/reducers/filters.js - About 2 hrs to fix

        Class Merge has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Merge < ApplicationModel
          include OperationSupport
          include NotifiableSupport
        
          belongs_to :workbench
        Severity: Minor
        Found in app/models/merge.rb - About 2 hrs to fix

          Class ReferentialsController has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ReferentialsController < Chouette::ResourceController
            defaults :resource_class => Referential
            before_action :load_workbench
            include PolicyChecker
          
          
          Severity: Minor
          Found in app/controllers/referentials_controller.rb - About 2 hrs to fix

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

                case 'SELECT_SHAPE_EDIT_MODAL':
                  journeyPattern =  _.assign({}, state.modalProps.journeyPattern, {shape: action.selectedItem})
                  newModalProps = _.assign({}, state.modalProps, {journeyPattern})
                  return _.assign({}, state, {modalProps: newModalProps})
            Severity: Major
            Found in app/packs/src/journey_patterns/reducers/modal.js and 1 other location - About 2 hrs to fix
            app/packs/src/vehicle_journeys/reducers/modal.js on lines 119..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 88.

            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

                case 'SELECT_CP_EDIT_MODAL':
                  vehicleJourney =  _.assign({}, state.modalProps.vehicleJourney, {company: action.selectedItem})
                  newModalProps = _.assign({}, state.modalProps, {vehicleJourney})
                  return _.assign({}, state, {modalProps: newModalProps})
            Severity: Major
            Found in app/packs/src/vehicle_journeys/reducers/modal.js and 1 other location - About 2 hrs to fix
            app/packs/src/journey_patterns/reducers/modal.js on lines 24..27

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

            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

            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'

              File clean.rb has 276 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Clean
                class Base
                  include Measurable
              
                  attr_reader :scope
              Severity: Minor
              Found in app/services/clean.rb - About 2 hrs to fix

                Method import_without_status has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  def import_without_status
                    begin
                      index = 0
                      # TODO manage automatic id attribute detection if shape_attribute_as_id blank
                      shape_attribute_as_id = parent.shape_attribute_as_id
                Severity: Minor
                Found in app/models/import/shapefile.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 state_update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  def state_update state
                    update_attributes(self.class.state_permited_attributes(state))
                    self.calendar_id = nil if self.respond_to?(:calendar_id) && !state['calendar']
                
                    days = state['day_types'].split(',')
                Severity: Minor
                Found in app/models/concerns/timetable_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

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

                  class LineStopAreas
                    def initialize(query_ctx, line_id)
                      @line_id = line_id
                      # Initialize the loading state for this query or get the previously-initiated state
                      @lazy_state = query_ctx[:lazy_find_line_stop_areas] ||= {
                Severity: Major
                Found in app/graphql/lazy_loading/line_stop_areas.rb and 1 other location - About 2 hrs to fix
                app/graphql/lazy_loading/lines.rb on lines 2..37

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

                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 Lines
                    def initialize(query_ctx, stop_area_id)
                      @stop_area_id = stop_area_id
                      # Initialize the loading state for this query or get the previously-initiated state
                      @lazy_state = query_ctx[:lazy_find_liness] ||= {
                Severity: Major
                Found in app/graphql/lazy_loading/lines.rb and 1 other location - About 2 hrs to fix
                app/graphql/lazy_loading/line_stop_areas.rb on lines 2..37

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

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

                  fetchJourneyPatterns : (dispatch, currentPage, nextPage) => {
                    if(currentPage == undefined){
                      currentPage = 1
                    }
                    let journeyPatterns = []
                Severity: Major
                Found in app/packs/src/journey_patterns/actions/index.js - About 2 hrs to fix

                  Function StopPoint has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function StopPoint(props) {
                    return (
                      <div className='nested-fields'>
                        <div className='wrapper'>
                          <div style={{width: 90}}>
                  Severity: Major
                  Found in app/packs/src/routes/components/StopPoint.js - About 2 hrs to fix

                    Method import_without_status has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def import_without_status
                        begin
                          index = 0
                          # TODO manage automatic id attribute detection if shape_attribute_as_id blank
                          shape_attribute_as_id = parent.shape_attribute_as_id
                    Severity: Major
                    Found in app/models/import/shapefile.rb - About 2 hrs to fix

                      File index.js has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      const actions = {
                        enterEditMode: () => ({
                          type: "ENTER_EDIT_MODE"
                        }),
                        exitEditMode: () => ({
                      Severity: Minor
                      Found in app/packs/src/journey_patterns/actions/index.js - About 2 hrs to fix

                        Class Index has 23 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class Index
                        
                            def initialize
                              @stop_ids = {}
                              @route_ids = {}
                        Severity: Minor
                        Found in app/models/export/gtfs.rb - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language