jpmckinney/multi_mail

View on GitHub

Showing 22 of 22 total issues

Method transform has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def transform(params)
        case @http_post_format
        when 'raw', '', nil
          message = self.class.condense(MultiMail::Message::Cloudmailin.new(Mail.new(params['message'])))

Severity: Minor
Found in lib/multi_mail/cloudmailin/receiver.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 transform has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def transform(params)
        case @http_post_format
        when 'parsed', '', nil
          # Mail changes `self`.
          headers = self.class.multimap(JSON.load(params['message-headers']))
Severity: Minor
Found in lib/multi_mail/mailgun/receiver.rb - About 2 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 transform has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def transform(params)
        case @http_post_format
        when 'raw', '', nil
          message = self.class.condense(MultiMail::Message::Cloudmailin.new(Mail.new(params['message'])))

Severity: Major
Found in lib/multi_mail/cloudmailin/receiver.rb - About 2 hrs to fix

    Method transform has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def transform(params)
            case @http_post_format
            when 'parsed', '', nil
              # Mail changes `self`.
              headers = self.class.multimap(JSON.load(params['message-headers']))
    Severity: Minor
    Found in lib/multi_mail/mailgun/receiver.rb - About 1 hr to fix

      Method parse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def parse(raw)
                case raw
                when String
                  begin
                    JSON.load(raw)
      Severity: Minor
      Found in lib/multi_mail/receiver/base.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 transform has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def transform(params)
              # JSON is necessarily UTF-8.
              JSON.load(params['mandrill_events']).select do |event|
                event.fetch('event') == 'inbound'
              end.map do |event|
      Severity: Minor
      Found in lib/multi_mail/mandrill/receiver.rb - About 1 hr to fix

        Method deliver! has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def deliver!(mail)
                message = MultiMail::Message::Postmark.new(mail).to_postmark_hash.merge(parameters)
        
                response = Faraday.post do |request|
                  request.url 'https://api.postmarkapp.com/email'
        Severity: Minor
        Found in lib/multi_mail/postmark/sender.rb - About 1 hr to fix

          Method transform has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def transform(params)
                  headers = Multimap.new
                  params['Headers'].each do |header|
                    headers[header['Name']] = header['Value']
                  end
          Severity: Minor
          Found in lib/multi_mail/postmark/receiver.rb - About 1 hr to fix

            Method parse has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def parse(raw)
                      case raw
                      when String
                        begin
                          JSON.load(raw)
            Severity: Minor
            Found in lib/multi_mail/receiver/base.rb - About 1 hr to fix

              Method deliver! has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def deliver!(mail)
                      message = MultiMail::Message::Mandrill.new(mail).to_mandrill_hash.merge(parameters)
              
                      api_params = {
                        :key     => api_key,
              Severity: Minor
              Found in lib/multi_mail/mandrill/sender.rb - About 1 hr to fix

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

                      def to_mailgun_hash
                        map = Multimap.new
                        hash = Hash.new
                
                        %w(from subject).each do |field|
                Severity: Minor
                Found in lib/multi_mail/mailgun/message.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 deliver! has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def deliver!(mail)
                        parameters = settings.dup
                        parameters.delete(:return_response)
                        message = MultiMail::Message::SendGrid.new(mail).to_sendgrid_hash.merge(parameters)
                
                
                Severity: Minor
                Found in lib/multi_mail/sendgrid/sender.rb - About 1 hr to fix

                  Method deliver! has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def deliver!(mail)
                          message = MultiMail::Message::Mailgun.new(mail).to_mailgun_hash.merge(parameters)
                  
                          connection = Faraday.new do |conn|
                            conn.basic_auth 'api', api_key
                  Severity: Minor
                  Found in lib/multi_mail/mailgun/sender.rb - About 1 hr to fix

                    Method validate_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def validate_options(options, raise_error_if_unrecognized = true)
                          keys = []
                          for key, value in options
                            unless value.nil?
                              keys << key
                    Severity: Minor
                    Found in lib/multi_mail/service.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 autoresponse? has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def autoresponse?(message)
                          !!(
                            # If any of the following headers are present and have the given value.
                            {
                              'Delivered-To'          => 'Autoresponder',
                    Severity: Minor
                    Found in lib/multi_mail.rb - About 1 hr to fix

                      Method to_mailgun_hash has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def to_mailgun_hash
                              map = Multimap.new
                              hash = Hash.new
                      
                              %w(from subject).each do |field|
                      Severity: Minor
                      Found in lib/multi_mail/mailgun/message.rb - About 1 hr to fix

                        Method condense has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def condense(message)
                                  if message.multipart? && message.parts.any?(&:multipart?)
                                    # Get the message parts as a flat array.
                                    result = flatten(Mail.new, message.parts.dup)
                        
                        
                        Severity: Minor
                        Found in lib/multi_mail/receiver/base.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 deliver! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def deliver!(mail)
                                message = MultiMail::Message::Mandrill.new(mail).to_mandrill_hash.merge(parameters)
                        
                                api_params = {
                                  :key     => api_key,
                        Severity: Minor
                        Found in lib/multi_mail/mandrill/sender.rb - About 55 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 deliver! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def deliver!(mail)
                                message = MultiMail::Message::Postmark.new(mail).to_postmark_hash.merge(parameters)
                        
                                response = Faraday.post do |request|
                                  request.url 'https://api.postmarkapp.com/email'
                        Severity: Minor
                        Found in lib/multi_mail/postmark/sender.rb - About 55 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 to_postmark_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def to_postmark_hash
                                hash = {}
                        
                                %w(from subject).each do |field|
                                  if self[field]
                        Severity: Minor
                        Found in lib/multi_mail/postmark/message.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

                        Severity
                        Category
                        Status
                        Source
                        Language