af83/chouette-core

View on GitHub
app/lib/chouette/sync/updater.rb

Summary

Maintainability
B
6 hrs
Test Coverage

File updater.rb has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Chouette
  module Sync
    class Updater
      include Measurable

Severity: Minor
Found in app/lib/chouette/sync/updater.rb - About 4 hrs to fix

    Method update_custom_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def update_custom_fields(model, resource, event)
              return unless resource.respond_to?(:custom_fields_attributes)
    
              resource.custom_fields_attributes.each do |custom_field_attributes|
                code = custom_field_attributes[:code]
    Severity: Minor
    Found in app/lib/chouette/sync/updater.rb - About 55 mins 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 has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

              def initialize(reference_type, resource_ids, model_id_attribute, code_space, updater)
    Severity: Minor
    Found in app/lib/chouette/sync/updater.rb - About 35 mins to fix

      Method update_codes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def update_codes(model, resource, event)
                return unless model.respond_to?(:codes) && resource.respond_to?(:codes_attributes)
      
                resource.codes_attributes.each do |code_attributes|
                  short_name = code_attributes[:short_name]
      Severity: Minor
      Found in app/lib/chouette/sync/updater.rb - About 35 mins 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 identifiers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def identifiers
                  return [] if resource_ids.empty? || !model_ref
      
                  ids = if support_model_id_attribute?
                          model_ref.where(model_id_attribute => resource_ids).pluck(:id)
      Severity: Minor
      Found in app/lib/chouette/sync/updater.rb - About 25 mins 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

      There are no issues that match your filters.

      Category
      Status