af83/chouette-core

View on GitHub

Showing 922 of 922 total issues

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")

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

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

  def validate_each(record, attribute, value)
    return if value.blank?

    url = URL.new(value)

Severity: Minor
Found in app/validators/url_validator.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 render has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const {
      route,
      isOutbound,
      errors,
Severity: Major
Found in app/packs/src/routes/components/form/index.js - About 2 hrs to fix

    Method option_input has 52 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).nil? ? option_def[:default_value] : export.try(attr)
    
    
    Severity: Major
    Found in app/helpers/options_helper.rb - About 2 hrs to fix

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

          if (this.footnotes().associated.includes(lf)) {
            return <button
              type='button'
              className='btn btn-outline-danger btn-xs'
              onClick={() => this.props.onToggleFootnoteModal(lf, false)}
      app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 43..49

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

      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

          } else {
            return <button
              type='button'
              className='btn btn-primary btn-xs'
              onClick={() => this.props.onToggleFootnoteModal(lf, true)}
      app/packs/src/vehicle_journeys/components/tools/NotesEditVehicleJourney.js on lines 37..43

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

      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 workbench.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module LockedReferentialToAggregateWithLog
        def locked_referential_to_aggregate
          super.tap do |ref|
            if locked_referential_to_aggregate_id.present? && !ref.present?
              Rails.logger.warn "Locked Referential for Workbench##{id} has been deleted"
      Severity: Minor
      Found in app/models/workbench.rb - About 2 hrs to fix

        Method mappings has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def mappings
              @mappings ||= [
                Mapper.new(source, target, :routes).exclude(:opposite_route_id),
        
                Mapper.new(source, target, :stop_points).mapping(:route_id, with: :routes),
        Severity: Minor
        Found in app/models/referential/copy.rb - About 1 hr to fix

          Function createSelect2 has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function createSelect2(WrappedComponent) {
            class Select2 extends Component {
              constructor(props) {
                super(props)
                this.handleChange = this.handleChange.bind(this)
          Severity: Minor
          Found in app/packs/src/helpers/select2/select2.js - About 1 hr to fix

            Method candidate_target_attributes has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def candidate_target_attributes # rubocop:disable Metrics/MethodLength
                    Chouette::ModelAttribute.collection do
            
                      # Chouette::Company
                      select Chouette::Company, :short_name
            Severity: Minor
            Found in app/models/macro/define_attribute_from_particulars.rb - About 1 hr to fix

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

              document.addEventListener("DOMContentLoaded", () => {
                if (document.getElementById("route")) {
                  render(
                    <Provider store={store}>
                      <App />
              Severity: Major
              Found in app/packs/entrypoints/routes/form.js and 2 other locations - About 1 hr to fix
              app/packs/entrypoints/journey_patterns/index.js on lines 39..48
              app/packs/entrypoints/time_tables/edit.js on lines 64..73

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

              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

              document.addEventListener("DOMContentLoaded", () => {
                if (document.getElementById("periods")) {
                  render(
                    <Provider store={store}>
                      <App />
              Severity: Major
              Found in app/packs/entrypoints/time_tables/edit.js and 2 other locations - About 1 hr to fix
              app/packs/entrypoints/journey_patterns/index.js on lines 39..48
              app/packs/entrypoints/routes/form.js on lines 13..22

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

              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

              document.addEventListener("DOMContentLoaded", () => {
                if (document.getElementById("journey_patterns")) {
                  render(
                    <Provider store={store}>
                      <App />
              Severity: Major
              Found in app/packs/entrypoints/journey_patterns/index.js and 2 other locations - About 1 hr to fix
              app/packs/entrypoints/routes/form.js on lines 13..22
              app/packs/entrypoints/time_tables/edit.js on lines 64..73

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

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

              export default function modal(state = {}, action) {
                switch (action.type) {
                  case 'OPEN_CONFIRM_MODAL':
                    $('#ConfirmModal').modal('show')
                    return assign({}, state, {
              Severity: Minor
              Found in app/packs/src/time_tables/reducers/modal.js - About 1 hr to fix

                Method candidate_target_attributes has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def candidate_target_attributes # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
                        Chouette::ModelAttribute.collection do # rubocop:disable Metrics/BlockLength
                          select Chouette::StopArea, :name
                          select Chouette::StopArea, :parent
                          select Chouette::StopArea, :country_code
                Severity: Minor
                Found in app/models/macro/update_attribute_from_referent_to_particulars.rb - About 1 hr to fix

                  Method parse_options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def parse_options args
                        options = {}
                        %i(weight primary secondary footer on action actions policy feature if groups group before_block).each do |k|
                          options[k] = args.delete(k) if args.has_key?(k)
                        end
                  Severity: Minor
                  Found in app/lib/af83/decorator/enhanced_decorator.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

                  Severity
                  Category
                  Status
                  Source
                  Language