af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

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

  class Retrieval < Operation
    include Measurable

    belongs_to :source, optional: false
    belongs_to :import, class_name: "Import::Workbench"
Severity: Minor
Found in app/models/source.rb - About 2 hrs to fix

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

    class User < ApplicationModel
      extend Enumerize
      # Include default devise modules. Others available are:
      # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable, :database_authenticatable
    
    
    Severity: Minor
    Found in app/models/user.rb - About 2 hrs to fix

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

      class ReferentialsController < Chouette::WorkbenchController
        defaults :resource_class => Referential
      
        respond_to :html
        respond_to :json, :only => :show
      Severity: Minor
      Found in app/controllers/referentials_controller.rb - About 2 hrs to fix

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

            class Context
              include Log
        
              attr_writer :attributes
              attr_accessor :instance, :instance_name, :parent
        Severity: Minor
        Found in app/lib/chouette/factory/context.rb - About 2 hrs to fix

          Method each has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def each(collection_or_opts={}, opts = {})
              if collection_or_opts.is_a? Hash
                collection = nil
                opts = collection_or_opts
              else
          Severity: Major
          Found in app/models/concerns/iev_interfaces/resource.rb - About 2 hrs to fix

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

                case 'UNSELECT_CP_EDIT_MODAL':
                  vehicleJourney =  _.assign({}, state.modalProps.vehicleJourney, {company: undefined})
                  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 28..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 84.

            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 'UNSELECT_SHAPE_EDIT_MODAL':
                  journeyPattern =  _.assign({}, state.modalProps.journeyPattern, {shape: undefined})
                  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 123..126

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

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

              render() {
                return (
                  <div className="container-fluid">
                    <div className="row">
                      <div className="col xs-9 col-xs-offset-3">
            Severity: Major
            Found in app/packs/src/time_tables/components/PeriodList.js - About 2 hrs to fix

              Function CopyModal has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              const CopyModal = props => {
                const copyContentRef = useRef(null)
                const pasteContentRef = useRef(null)
              
                const {
              Severity: Minor
              Found in app/packs/src/vehicle_journeys/components/CopyModal.js - 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 save_model has a Cognitive Complexity of 18 (exceeds 5 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 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>
                                    <div className="form-group">
                                      <label htmlFor="" className="control-label required">
                                        {I18n.t('time_tables.edit.period_form.begin')}
                                        <abbr title="requis">*</abbr>
              Severity: Major
              Found in app/packs/src/time_tables/components/PeriodForm.js and 1 other location - About 2 hrs to fix
              app/packs/src/time_tables/components/PeriodForm.js on lines 59..66

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

              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>
                                    <div className="form-group">
                                      <label htmlFor="" className="control-label required">
                                        {I18n.t('time_tables.edit.period_form.end')}
                                        <abbr title="requis">*</abbr>
              Severity: Major
              Found in app/packs/src/time_tables/components/PeriodForm.js and 1 other location - About 2 hrs to fix
              app/packs/src/time_tables/components/PeriodForm.js on lines 51..58

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

              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 VehicleJourneysList.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React, { Component } from 'react'
              import PropTypes from 'prop-types'
              import { flatMap, isEmpty, map, some, uniqBy } from 'lodash'
              import autoBind from 'react-autobind'
              import VehicleJourney from './VehicleJourney'
              Severity: Minor
              Found in app/packs/src/vehicle_journeys/components/VehicleJourneysList.js - About 2 hrs to fix

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

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

                  Class Scheduled has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class Scheduled < Base
                      attr_writer :final_scope
                  
                      def final_scope
                        @final_scope || current_scope
                  Severity: Minor
                  Found in app/models/export/scope.rb - About 2 hrs to fix

                    Class Mapper has 22 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class Mapper
                          def initialize(source_referential, target_referential, table_name, legacy_id: true, where: nil)
                            @table_name = table_name
                            @source_referential = source_referential
                            @target_referential = target_referential
                    Severity: Minor
                    Found in app/models/referential/copy.rb - About 2 hrs to fix

                      Class ReferentialSchema has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ReferentialSchema
                        include Measurable
                      
                        PUBLIC_SCHEMA = 'public'
                      
                      
                      Severity: Minor
                      Found in app/lib/referential_schema.rb - About 2 hrs to fix

                        Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class Base
                            class << self
                              def strategy_classes
                                @strategy_classes ||= {}
                              end
                        Severity: Minor
                        Found in app/lib/policy/base.rb - About 2 hrs to fix

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

                            render() {
                              return (
                                <div>
                                  { this.props.values.map((code, index) =>
                                    <div className="row vertical-align" key={code.id || code.fallback_id}>
                          Severity: Major
                          Found in app/packs/src/vehicle_journeys/components/tools/CodesInputs.js - About 2 hrs to fix

                            Method import_routes has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def import_routes
                                @lines_by_registration_number = {}
                            
                                CustomFieldsSupport.within_workgroup(workbench.workgroup) do
                                  create_resource(:routes).each(source.routes, transaction: true) do |route, resource|
                            Severity: Major
                            Found in app/models/import/gtfs.rb - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language