zammad/zammad

View on GitHub
app/models/concerns/can_csv_import.rb

Summary

Maintainability
F
4 days
Test Coverage

Method csv_import has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
Open

    def csv_import(data)
      try    = data[:try].to_s == 'true'
      delete = data[:delete].to_s == 'true'

      begin
Severity: Minor
Found in app/models/concerns/can_csv_import.rb - About 1 day 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 csv_example has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    def csv_example(params = {})
      header = []
      records = where.not(id: csv_object_ids_ignored).offset(1).limit(23).to_a
      if records.count < 20
        record_ids = records.pluck(:id).concat(csv_object_ids_ignored)
Severity: Minor
Found in app/models/concerns/can_csv_import.rb - About 1 day 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 csv_import has 122 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def csv_import(data)
      try    = data[:try].to_s == 'true'
      delete = data[:delete].to_s == 'true'

      begin
Severity: Major
Found in app/models/concerns/can_csv_import.rb - About 4 hrs to fix

    File can_csv_import.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module CanCsvImport
      extend ActiveSupport::Concern
    
      # methods defined here are going to extend the class, not the instance of it
      class_methods do
    Severity: Minor
    Found in app/models/concerns/can_csv_import.rb - About 3 hrs to fix

      Method csv_example has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def csv_example(params = {})
            header = []
            records = where.not(id: csv_object_ids_ignored).offset(1).limit(23).to_a
            if records.count < 20
              record_ids = records.pluck(:id).concat(csv_object_ids_ignored)
      Severity: Major
      Found in app/models/concerns/can_csv_import.rb - About 2 hrs to fix

        Method csv_verify_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def csv_verify_attributes(clean_params)
              all_clean_attributes = {}
              new.attributes.each_key do |attribute|
                all_clean_attributes[attribute.to_sym] = true
              end
        Severity: Minor
        Found in app/models/concerns/can_csv_import.rb - About 45 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