From d01bc1507c4ea620b6c1c091f7633c5936fa7a88 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Fri, 28 Aug 2026 17:17:09 +0900 Subject: [PATCH 1/2] Fix the RuboCop offenses in lib/redmine/export/pdf.rb. --- .rubocop_todo.yml | 4 ---- lib/redmine/export/pdf.rb | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8633a264f..8bfa21328 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -281,7 +281,6 @@ Naming/MemoizedInstanceVariableName: # ForbiddenIdentifiers: __id__, __send__ Naming/MethodName: Exclude: - - 'lib/redmine/export/pdf.rb' - 'lib/redmine/scm/adapters/cvs_adapter.rb' - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' - 'test/helpers/application_helper_test.rb' @@ -612,7 +611,6 @@ Style/Alias: - 'app/models/user.rb' - 'app/models/version.rb' - 'config/initializers/10-patches.rb' - - 'lib/redmine/export/pdf.rb' - 'lib/redmine/menu_manager.rb' - 'lib/redmine/plugin.rb' - 'lib/redmine/wiki_formatting/textile/formatter.rb' @@ -627,7 +625,6 @@ Style/AndOr: - 'app/helpers/repositories_helper.rb' - 'app/models/query.rb' - 'db/migrate/022_serialize_possibles_values.rb' - - 'lib/redmine/export/pdf.rb' - 'lib/redmine/field_format.rb' - 'lib/redmine/scm/adapters/abstract_adapter.rb' - 'lib/redmine/scm/adapters/bazaar_adapter.rb' @@ -685,7 +682,6 @@ Style/ColonMethodCall: Exclude: - 'app/controllers/admin_controller.rb' - 'lib/redmine/configuration.rb' - - 'lib/redmine/export/pdf.rb' - 'lib/redmine/wiki_formatting.rb' - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' - 'test/unit/default_data_test.rb' diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index acb09bdce..f17dc437b 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -23,6 +23,8 @@ require 'rbpdf' module Redmine module Export module PDF + # The camel cased methods below follow the RBPDF API and cannot be renamed. + # rubocop:disable-next Naming/MethodName class ITCPDF < RBPDF include Redmine::I18n attr_accessor :footer_date @@ -59,10 +61,10 @@ module Redmine style.delete!('I') if family.to_s.casecmp('dejavusansmono') == 0 super end - alias_method :set_font, :SetFont + alias set_font SetFont def fix_text_encoding(txt) - RDMPdfEncoding::rdm_from_utf8(txt, "UTF-8") + RDMPdfEncoding.rdm_from_utf8(txt, "UTF-8") end def formatted_text(text) @@ -105,14 +107,14 @@ module Redmine if atta return atta.diskfile # rubocop:disable Lint/DuplicateBranch - elsif %r{/attachments/download/(?[^/]+)/} =~ attrname and - atta = @attachments.find{|a| a.id.to_s == id} and - atta.readable? and atta.visible? + elsif %r{/attachments/download/(?[^/]+)/} =~ attrname && + (atta = @attachments.find{|a| a.id.to_s == id}) && + atta.readable? && atta.visible? return atta.diskfile # rubocop:enable Lint/DuplicateBranch - elsif %r{/attachments/thumbnail/(?[^/]+)/(?\d+)} =~ attrname and - atta = @attachments.find{|a| a.id.to_s == id} and - atta.readable? and atta.visible? + elsif %r{/attachments/thumbnail/(?[^/]+)/(?\d+)} =~ attrname && + (atta = @attachments.find{|a| a.id.to_s == id}) && + atta.readable? && atta.visible? return atta.thumbnail(size: size) else return nil @@ -120,7 +122,7 @@ module Redmine end def get_sever_url(url) - if !empty_string(url) and url.start_with?('/') + if !empty_string(url) && url.start_with?('/') Setting.host_name.split('/')[0] + url else url -- 2.55.0