yegor256/mailanes

View on GitHub
objects/letter.rb

Summary

Maintainability
D
2 days
Test Coverage

Method deliver_smtp has 129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def deliver_smtp(content, recipient, codec, delivery)
    html = with_utm(
      Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content),
      delivery
    )
Severity: Major
Found in objects/letter.rb - About 5 hrs to fix

    Method deliver_smtp has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

      def deliver_smtp(content, recipient, codec, delivery)
        html = with_utm(
          Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content),
          delivery
        )
    Severity: Minor
    Found in objects/letter.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

    File letter.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'yaml'
    require 'mail'
    require 'uuidtools'
    require 'timeout'
    require 'pg'
    Severity: Minor
    Found in objects/letter.rb - About 3 hrs to fix

      Class Letter has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Letter
        # When can't deliver
        class CantDeliver < StandardError; end
      
        attr_reader :id
      Severity: Minor
      Found in objects/letter.rb - About 3 hrs to fix

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

          def cfg(default, *items)
            result = yaml
            items.each do |i|
              result = result[i]
              break if result.nil?
        Severity: Minor
        Found in objects/letter.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 move has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def move(inc = 1)
            raise "Invalid direction #{inc.inspect}" if inc != 1 && inc != -1
            @pgsql.transaction do |t|
              other = t.exec(
                [
        Severity: Minor
        Found in objects/letter.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_utm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def with_utm(text, delivery)
            text.gsub(%r{(https?://[a-zA-Z0-9%-_./&?]+)}) do |u|
              r = u + (u.include?('?') ? '&' : '?')
              r += 'utm_source=mailanes.com&utm_medium=email&utm_campaign='
              r += delivery.nil? ? '0' : delivery.campaign.id.to_s
        Severity: Minor
        Found in objects/letter.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