ActiveCampaign/postmark-gem

View on GitHub

Showing 12 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 = options.dup
          options[:auth_header_name] = 'X-Postmark-Account-Token'
    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 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 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 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                with_retries do
                  response, error = take_response_of { http_client.post("email", data) }
                  update_message(message, response)
                  raise error if error
                  format_response(response, :compatible => true)
          Severity: Minor
          Found in lib/postmark/api_client.rb and 1 other location - About 15 mins to fix
          lib/postmark/api_client.rb on lines 50..54

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 26.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                with_retries do
                  response, error = take_response_of { http_client.post("email/withTemplate", data) }
                  update_message(message, response)
                  raise error if error
                  format_response(response, :compatible => true)
          Severity: Minor
          Found in lib/postmark/api_client.rb and 1 other location - About 15 mins to fix
          lib/postmark/api_client.rb on lines 37..41

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 26.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language