Noosfero/noosfero

View on GitHub
app/models/invitation.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method invite has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

  def self.invite(person, contacts_to_invite, message, profile)
    contacts_to_invite.each do |contact_to_invite|
      next if contact_to_invite == _("Firstname Lastname <friend@email.com>")

      contact_to_invite = contact_to_invite.to_s.strip
Severity: Minor
Found in app/models/invitation.rb - About 4 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 invite has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.invite(person, contacts_to_invite, message, profile)
    contacts_to_invite.each do |contact_to_invite|
      next if contact_to_invite == _("Firstname Lastname <friend@email.com>")

      contact_to_invite = contact_to_invite.to_s.strip
Severity: Minor
Found in app/models/invitation.rb - About 1 hr to fix

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

      def self.join_contacts(manual_import_addresses, webmail_import_addresses)
        contacts = []
        if manual_import_addresses
          contacts += manual_import_addresses.is_a?(Array) ? manual_import_addresses : manual_import_addresses.split
        end
    Severity: Minor
    Found in app/models/invitation.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