Project

General

Profile

Feature #44396 » 0001-Fix-the-RuboCop-offenses-in-lib-redmine-export-pdf.r.patch

Go MAEDA, 2026-08-29 07:50

View differences:

.rubocop_todo.yml
281 281
# ForbiddenIdentifiers: __id__, __send__
282 282
Naming/MethodName:
283 283
  Exclude:
284
    - 'lib/redmine/export/pdf.rb'
285 284
    - 'lib/redmine/scm/adapters/cvs_adapter.rb'
286 285
    - 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
287 286
    - 'test/helpers/application_helper_test.rb'
......
612 611
    - 'app/models/user.rb'
613 612
    - 'app/models/version.rb'
614 613
    - 'config/initializers/10-patches.rb'
615
    - 'lib/redmine/export/pdf.rb'
616 614
    - 'lib/redmine/menu_manager.rb'
617 615
    - 'lib/redmine/plugin.rb'
618 616
    - 'lib/redmine/wiki_formatting/textile/formatter.rb'
......
627 625
    - 'app/helpers/repositories_helper.rb'
628 626
    - 'app/models/query.rb'
629 627
    - 'db/migrate/022_serialize_possibles_values.rb'
630
    - 'lib/redmine/export/pdf.rb'
631 628
    - 'lib/redmine/field_format.rb'
632 629
    - 'lib/redmine/scm/adapters/abstract_adapter.rb'
633 630
    - 'lib/redmine/scm/adapters/bazaar_adapter.rb'
......
685 682
  Exclude:
686 683
    - 'app/controllers/admin_controller.rb'
687 684
    - 'lib/redmine/configuration.rb'
688
    - 'lib/redmine/export/pdf.rb'
689 685
    - 'lib/redmine/wiki_formatting.rb'
690 686
    - 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
691 687
    - 'test/unit/default_data_test.rb'
lib/redmine/export/pdf.rb
23 23
module Redmine
24 24
  module Export
25 25
    module PDF
26
      # The camel cased methods below follow the RBPDF API and cannot be renamed.
27
      # rubocop:disable-next Naming/MethodName
26 28
      class ITCPDF < RBPDF
27 29
        include Redmine::I18n
28 30
        attr_accessor :footer_date
......
59 61
          style.delete!('I') if family.to_s.casecmp('dejavusansmono') == 0
60 62
          super
61 63
        end
62
        alias_method :set_font, :SetFont
64
        alias set_font SetFont
63 65
        def fix_text_encoding(txt)
64
          RDMPdfEncoding::rdm_from_utf8(txt, "UTF-8")
66
          RDMPdfEncoding.rdm_from_utf8(txt, "UTF-8")
65 67
        end
66 68
        def formatted_text(text)
......
105 107
          if atta
106 108
            return atta.diskfile
107 109
          # rubocop:disable Lint/DuplicateBranch
108
          elsif %r{/attachments/download/(?<id>[^/]+)/} =~ attrname and
109
                atta = @attachments.find{|a| a.id.to_s == id} and
110
                atta.readable? and atta.visible?
110
          elsif %r{/attachments/download/(?<id>[^/]+)/} =~ attrname &&
111
                (atta = @attachments.find{|a| a.id.to_s == id}) &&
112
                atta.readable? && atta.visible?
111 113
            return atta.diskfile
112 114
          # rubocop:enable Lint/DuplicateBranch
113
          elsif %r{/attachments/thumbnail/(?<id>[^/]+)/(?<size>\d+)} =~ attrname and
114
                atta = @attachments.find{|a| a.id.to_s == id} and
115
                atta.readable? and atta.visible?
115
          elsif %r{/attachments/thumbnail/(?<id>[^/]+)/(?<size>\d+)} =~ attrname &&
116
                (atta = @attachments.find{|a| a.id.to_s == id}) &&
117
                atta.readable? && atta.visible?
116 118
            return atta.thumbnail(size: size)
117 119
          else
118 120
            return nil
......
120 122
        end
121 123
        def get_sever_url(url)
122
          if !empty_string(url) and url.start_with?('/')
124
          if !empty_string(url) && url.start_with?('/')
123 125
            Setting.host_name.split('/')[0] + url
124 126
          else
125 127
            url
(1-1/2)