fiedl/your_platform

View on GitHub
app/pdfs/address_labels_dpag7037_pdf.rb

Summary

Maintainability
C
1 day
Test Coverage

Method initialize has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(address_labels, options = {title: '', updated_at: Time.zone.now, sender: '', book_rate: false})
    super(page_size: 'A4', top_margin: 0.mm, bottom_margin: 0.mm, left_margin: 0.mm, right_margin: 0.mm)
    
    @document_title = options[:title]
    @document_updated_at = options[:updated_at]
Severity: Minor
Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 7 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 initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(address_labels, options = {title: '', updated_at: Time.zone.now, sender: '', book_rate: false})
    super(page_size: 'A4', top_margin: 0.mm, bottom_margin: 0.mm, left_margin: 0.mm, right_margin: 0.mm)
    
    @document_title = options[:title]
    @document_updated_at = options[:updated_at]
Severity: Minor
Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                     address.gsub!("\nDeutschland", "") if I18n.locale == :de # in order to save space for in-country deliveries.
    Severity: Major
    Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                       sender_line if @sender and address.to_s.present?
      Severity: Major
      Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                         rescue Prawn::Errors::IncompatibleStringEncoding
                           logger.warn "PDF ADDRESS LABEL EXPORT ENCODING ISSUE for #{address_label.name}."
                           text "ENCODING ISSUE!"
        Severity: Major
        Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                           book_rate_line(address_label) if @book_rate and address_label
          Severity: Major
          Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status