ActiveCampaign/postmark-gem

View on GitHub

Showing 10 of 12 total issues

Class ApiClient has 63 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ApiClient < Client
    attr_accessor :max_batch_size

    def initialize(api_token, options = {})
      options = options.dup
Severity: Major
Found in lib/postmark/api_client.rb - About 1 day to fix

    Class AccountApiClient has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class AccountApiClient < Client
    
        def initialize(api_token, options = {})
          options[:auth_header_name] = 'X-Postmark-Account-Token'
          super
    Severity: Minor
    Found in lib/postmark/account_api_client.rb - About 4 hrs to fix

      File api_client.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Postmark
        class ApiClient < Client
          attr_accessor :max_batch_size
      
          def initialize(api_token, options = {})
      Severity: Minor
      Found in lib/postmark/api_client.rb - About 3 hrs to fix

        Class Message has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Message
        
            attr_accessor :delivered, :postmark_response
        
            def delivered?
        Severity: Minor
        Found in lib/postmark/message_extensions/mail.rb - About 3 hrs to fix

          Method to_ruby has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_ruby(object, options = {})
                compatible = options.fetch(:compatible, false)
                deep = options.fetch(:deep, false)
          
                case object
          Severity: Minor
          Found in lib/postmark/helpers/hash_helper.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 to_postmark has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_postmark(object, options = {})
                deep = options.fetch(:deep, false)
          
                case object
                when Hash
          Severity: Minor
          Found in lib/postmark/helpers/hash_helper.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 with_retries has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def with_retries
                yield
              rescue HttpServerError, HttpClientError, TimeoutError, Errno::EINVAL,
                     Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError,
                     Net::ProtocolError, SocketError => e
          Severity: Minor
          Found in lib/postmark/client.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 prerender has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def prerender
                raise ::Postmark::Error, 'Cannot prerender a message without an associated template alias' unless templated?
          
                unless delivery_method.is_a?(::Mail::Postmark)
                  raise ::Postmark::MailAdapterError, "Cannot render templates via #{delivery_method.class} adapter."
          Severity: Minor
          Found in lib/postmark/message_extensions/mail.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 validate_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_template(attributes = {})
                data = serialize(HashHelper.to_postmark(attributes))
                response = format_response(http_client.post('templates/validate', data))
          
                response.each do |k, v|
          Severity: Minor
          Found in lib/postmark/api_client.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 to_ruby_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_ruby_hash(inbound)
                inbound = Json.decode(inbound) if inbound.is_a?(String)
                ret = HashHelper.to_ruby(inbound)
                ret[:from_full] ||= {}
                ret[:to_full] ||= []
          Severity: Minor
          Found in lib/postmark/inbound.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

          Severity
          Category
          Status
          Source
          Language