theforeman/foreman

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

Summary

Maintainability
A
2 hrs
Test Coverage

Method filter_encrypted has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_encrypted
    audited_changes.each do |name, change|
      next if change.nil? || change.to_s.empty?
      if change.is_a? Array
        change.map! { |c| c.to_s.start_with?(EncryptValue::ENCRYPTION_PREFIX) ? REDACTED : c }
Severity: Minor
Found in app/models/concerns/audit_extensions.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

Method log_audit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def log_audit
    telemetry_increment_counter(:audit_records_created, 1, type: auditable_type)
    audit_logger = Foreman::Logging.logger('audit')
    return unless (audited_changes && audit_logger.info?)
    audited_changes.each_pair do |attribute, change|
Severity: Minor
Found in app/models/concerns/audit_extensions.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

Method fix_auditable_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def fix_auditable_type
    # STI Host class should use the stub module instead of Host::Base
    self.auditable_type = "Host::Base" if auditable_type =~ /^(::)?Host::/
    self.associated_type = "Host::Base" if associated_type =~ /^(::)?Host::/
    self.auditable_type = auditable.type if ["Taxonomy", "LookupKey"].include?(auditable_type) && auditable
Severity: Minor
Found in app/models/concerns/audit_extensions.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

Method taxed_and_untaxed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def taxed_and_untaxed
        clauses = []
        if filter_taxonomy?(Organization)
          clauses << org_join_arel[:taxonomy_id].in(user_taxonomy_ids(Organization))
        end
Severity: Minor
Found in app/models/concerns/audit_extensions.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