robertgauld/osm

View on GitHub
lib/osm/email.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method get_for_section has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.get_for_section(api, section, options={})
        Osm::Model.require_access_to_section(api, section, options)
        section_id = section.to_i
        cache_key = ['email_delivery_reports', section_id]

Severity: Minor
Found in lib/osm/email.rb - About 1 hr to fix

    Method send_email has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def self.send_email(api, section, send_to, cc='', from, subject, body)
    Severity: Major
    Found in lib/osm/email.rb - About 50 mins to fix

      Method fetch_from_osm has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def self.fetch_from_osm(api, section_id, email_id, member_id=nil, email_address='')
      Severity: Minor
      Found in lib/osm/email.rb - About 35 mins to fix

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

              def self.get_for_section(api, section, options={})
                Osm::Model.require_access_to_section(api, section, options)
                section_id = section.to_i
                cache_key = ['email_delivery_reports', section_id]
        
        
        Severity: Minor
        Found in lib/osm/email.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 get_emails_for_contacts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.get_emails_for_contacts(api, section, contacts, members)
              # Convert contacts into OSM's format
              contacts = [*contacts]
              fail ArgumentError, "You must pass at least one contact" if contacts.none?
              contact_group_map = {
        Severity: Minor
        Found in lib/osm/email.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 fetch_from_osm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def self.fetch_from_osm(api, section_id, email_id, member_id=nil, email_address='')
                  Osm::Model.require_access_to_section(api, section_id)
        
                  data = api.perform_query("ext/settings/emails/?action=getSentEmail&section_id=#{section_id}&email_id=#{email_id}&email=#{email_address}&member_id=#{member_id}")
                  fail Osm::Error, "Unexpected format for response - got a #{data.class}" unless data.is_a?(Hash)
        Severity: Minor
        Found in lib/osm/email.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 unblock_address has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def unblock_address(api)
                  return true unless bounced?
        
                  data = api.perform_query('ext/settings/emails/?action=unBlockEmail', {
                    'section_id' => delivery_report.section_id,
        Severity: Minor
        Found in lib/osm/email.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