talho/openphin

View on GitHub
app/models/alert.rb

Summary

Maintainability
D
1 day
Test Coverage

Method xml_build_behavior has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

  def xml_build_behavior builder, options={}
    options={ :Delivery => {:Providers => {} } } if options.blank?
    builder.Behavior do |behavior|
      if options[:override]
        options[:override].call(behavior)
Severity: Minor
Found in app/models/alert.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 update_statistics has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def update_statistics(options)
    aa_size = nil

    return unless respond_to? :call_down_messages
    if options[:response] && options[:response].to_i > 0
Severity: Minor
Found in app/models/alert.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 xml_build_author has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def xml_build_author builder, options={}
    options={} if options.blank?
    unless self.author.blank?
      builder.Author(:givenName => self.author.first_name, :surname => self.author.last_name, :display_name => self.author.display_name) do |a|
        if options[:override]
Severity: Minor
Found in app/models/alert.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 xml_build_behavior has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def xml_build_behavior builder, options={}
    options={ :Delivery => {:Providers => {} } } if options.blank?
    builder.Behavior do |behavior|
      if options[:override]
        options[:override].call(behavior)
Severity: Minor
Found in app/models/alert.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                      if options[:Delivery][:Providers][:override]
                        options[:Delivery][:Providers][:override].call(providers)
                      else
                        (self.alert_device_types.map{|device| device.device_type.display_name} || Service::Swn::Message::SUPPORTED_DEVICES.keys).each do |device|
                          device_options = {:name => "swn", :device => device}
    Severity: Major
    Found in app/models/alert.rb - About 45 mins to fix

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

        def xml_build_messages builder, options={}
          options={} if options.blank?
          builder.Messages do |messages|
            if options[:override]
                options[:override].call(messages)
      Severity: Minor
      Found in app/models/alert.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 xml_build_recipients has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def xml_build_recipients builder, options={}
          options={} if options.blank?
          builder.Recipients do |rcpts|
            if options[:override]
              options[:override].call(rcpts)
      Severity: Minor
      Found in app/models/alert.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 xml_build_ivrtree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def xml_build_ivrtree builder, options={}
          options={} if options.blank?
          builder.IVRTree do |ivrtree|
            if options[:override]
                options[:override].call(ivrtree)
      Severity: Minor
      Found in app/models/alert.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

      There are no issues that match your filters.

      Category
      Status