Skip to content

Commit

Permalink
new rubocop: make multiline strings indented
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jun 3, 2024
1 parent f8f5d4b commit 0859b18
Show file tree
Hide file tree
Showing 28 changed files with 97 additions and 90 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ Style/OptionalBooleanParameter:
# it sometimes make code harder to read
Style/GuardClause:
Enabled: false

# use indented style as there is a lot of multiline strings and it often
# too much fragile that string as default style makes really narrow strings
Layout/LineEndStringConcatenationIndentation:
EnforcedStyle: indented
12 changes: 7 additions & 5 deletions src/clients/scc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ def print_help
# @return [Boolean] true if the repository manager was successfuly closed,
# false after pressing [Cancel]
def fix_repositories(details)
# TRANSLATORS: Error message in RichText format, %s contains the details from libzypp
Report.LongError(_("<p>The repository initialization failed. " \
"Disable (or remove) the offending service or repository " \
"in the repository manager.</p><p>Details:</p><p>%s</p>") %
CGI.escapeHTML(details))
Report.LongError(
# TRANSLATORS: Error message in RichText format, %s contains the details from libzypp
_("<p>The repository initialization failed. " \
"Disable (or remove) the offending service or repository " \
"in the repository manager.</p><p>Details:</p><p>%s</p>") %
CGI.escapeHTML(details)
)

ret = WFM.call("repositories", WFM.Args)
log.info "repository manager result: #{ret}"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/registration/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ def self.dump_addons

require "yaml"
header = "# see " \
"https://github.com/yast/yast-registration/tree/master/devel/dump_reader.rb\n" \
"# for an example how to read this dump file\n"
"https://github.com/yast/yast-registration/tree/master/devel/dump_reader.rb\n" \
"# for an example how to read this dump file\n"
File.write("/var/log/YaST2/registration_addons.yml",
header + @cached_addons.to_yaml)
end
Expand Down
26 changes: 13 additions & 13 deletions src/lib/registration/connect_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def self.catch_registration_errors(message_prefix: "",
error_code_message + error_msg)
when 500..599
report_error(message_prefix + _("Registration server error.\n" \
"Retry the operation later."), error_msg)
"Retry the operation later."), error_msg)
else
report_error(message_prefix + _("Connection to registration server failed."),
error_code_message + error_msg)
Expand Down Expand Up @@ -224,7 +224,7 @@ def self.handle_ssl_error(error, certificate_imported)
else
# error message
Yast::Report.Error(_("Received SSL Certificate does not match " \
"the expected certificate."))
"the expected certificate."))
end
elsif Yast::Mode.autoinst && Storage::Config.instance.reg_server_cert &&
!Storage::Config.instance.reg_server_cert.empty?
Expand Down Expand Up @@ -264,9 +264,9 @@ def self.import_ssl_certificate(cert)
# imported but the registration server still cannot be accessed securely,
# user has to solve the certificate issue manually.
Yast::Report.Error(_("A certificate has been already imported\n" \
"but the server connection still cannot be trusted.\n\n" \
"Please fix the certificate issue manually, ensure that the server\n" \
"can be connected securely and start the YaST module again."))
"but the server connection still cannot be trusted.\n\n" \
"Please fix the certificate issue manually, ensure that the server\n" \
"can be connected securely and start the YaST module again."))

return false
end
Expand Down Expand Up @@ -311,8 +311,8 @@ def self.check_smt_api(error_msg)
# TRANSLATORS: error message, %s is a server URL,
# e.g. https://smt.example.com
msg = _("An old registration server was detected at\n%s.\n" \
"Make sure the latest product supporting the new registration\n" \
"protocol is installed at the server.") % display_url
"Make sure the latest product supporting the new registration\n" \
"protocol is installed at the server.") % display_url

error_msg.replace(msg)
end
Expand Down Expand Up @@ -351,12 +351,12 @@ def self.add_update_hint(error_msg)
msg += "\n\n"
# TRANSLATORS: additional hint for an error message
msg += _("If you are upgrading from SLE11 make sure the SCC server\n" \
"knows the old NCC registration. Synchronization from NCC to SCC\n" \
"might take very long time.\n\n" \
"If the SLE11 system was installed recently you could log into\n" \
"%s to speed up the synchronization process.\n" \
"Just wait several minutes after logging in and then retry \n" \
"the upgrade again.") % \
"knows the old NCC registration. Synchronization from NCC to SCC\n" \
"might take very long time.\n\n" \
"If the SLE11 system was installed recently you could log into\n" \
"%s to speed up the synchronization process.\n" \
"Just wait several minutes after logging in and then retry \n" \
"the upgrade again.") % \
SUSE::Connect::YaST::DEFAULT_URL
end

Expand Down
2 changes: 1 addition & 1 deletion src/lib/registration/controllers/package_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def yes_no_popup(message)
# @param addon [Registration::Addon]
def log_addon(msg, addon)
log.info "#{msg}: #{addon.inspect}, registered=#{addon.registered?}, " \
"selected=#{addon.selected?}, auto_selected=#{addon.auto_selected?}"
"selected=#{addon.selected?}, auto_selected=#{addon.auto_selected?}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/lib/registration/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.download_file(file_url, insecure: false, redirection_count: 10)
download_file(location, insecure: insecure, redirection_count: redirection_count - 1)
else
log.error "HTTP request failed: Error #{response.code}:" \
"#{response.message}: #{response.body}"
"#{response.message}: #{response.body}"

raise DownloadError, "Downloading #{file_url} failed: #{response.message}"
end
Expand Down
2 changes: 1 addition & 1 deletion src/lib/registration/eula_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def download
log.info "Downloading license from #{license_file_url}..."
license_text = Downloader.download(license_file_url, insecure: insecure)
log.info "Downloaded license: #{license_text[0..32].inspect}... " \
"(#{license_text.bytesize} bytes)"
"(#{license_text.bytesize} bytes)"

license_file_name = File.join(target_dir, license)

Expand Down
6 changes: 3 additions & 3 deletions src/lib/registration/registration_ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ def registered_addons_to_rollback
# %s are all the product names splited by '\n' e.g
# "SUSE Linux Enterprise Server 12\nSUSE Enterprise Storage 1 x86_64"
msg = _("The add-ons listed below are registered but not installed: \n\n%s\n\n" \
"Would you like to downgrade also them in the registration server? \n" \
"If not they will be deactivated. ") % addon_names.join("\n")
"Would you like to downgrade also them in the registration server? \n" \
"If not they will be deactivated. ") % addon_names.join("\n")

Yast::Popup.YesNo(msg) ? addons : []
end
Expand Down Expand Up @@ -367,7 +367,7 @@ def register_base_product

if ret
group.summary = "Registered \"#{base_product_data["name"]}-" \
"#{base_product_data["version"]}-#{base_product_data["arch"]}\""
"#{base_product_data["version"]}-#{base_product_data["arch"]}\""
end

ret
Expand Down
2 changes: 1 addition & 1 deletion src/lib/registration/ssl_certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def log_details
require "registration/ssl_certificate_details"
# log also the dates
log.info("#{SslCertificateDetails.new(self).summary}\n" \
"Issued on: #{issued_on}\nExpires on: #{expires_on}")
"Issued on: #{issued_on}\nExpires on: #{expires_on}")

# log a warning for expired certificate
expires = x509_cert.not_after.localtime
Expand Down
6 changes: 3 additions & 3 deletions src/lib/registration/sw_mgmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def self.check_repositories
# when a migration repository cannot be accessed, there are [Skip]
# and [Abort] buttons displayed below the question
question = _("Repository '%s'\ncannot be loaded.\n\n"\
"Skip the repository or abort?") % data["name"]
"Skip the repository or abort?") % data["name"]
ret = Popup.ErrorAnyQuestion(Label.ErrorMsg, question, Label.SkipButton,
Label.AbortButton, :focus_yes)

Expand Down Expand Up @@ -680,11 +680,11 @@ def self.select_product_addons(products, addons)
remote_addon.selected
else
product_label = "#{product["display_name"]} (#{product["name"]}" \
"-#{product["version_version"]}-#{product["arch"]})"
"-#{product["version_version"]}-#{product["arch"]})"

# TRANSLATORS: %s is a product name
Report.Error(_("Cannot find remote product %s.\n" \
"The product cannot be registered.") % product_label)
"The product cannot be registered.") % product_label)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions src/lib/registration/ui/addon_selection_base_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,21 @@ def generic_help_text

def checkboxes_help
header = _("<p>The extensions and modules can have several states depending " \
"how they were selected.</p>")
"how they were selected.</p>")

# TRANSLATORS: help text for checked check box
selected = _("The extension or module is selected to install by user or is " \
"pre-selected as a recommended addon.") + "<br>"
"pre-selected as a recommended addon.") + "<br>"
# TRANSLATORS: help text for unchecked check box
deselected = _("The extension or module is not selected to install.") + "<br>"
# TRANSLATORS: help text for automatically checked check box (it has a
# different look that a user selected check box)
auto_selected = _("The extension or module was selected automatically as a dependency " \
"of another extension or module.")
"of another extension or module.")

if Yast::UI.TextMode
return header + "<p>" \
"[x] = " + selected +
"[x] = " + selected +
"[ ] = " + deselected +
"[a] = " + auto_selected +
"</p>"
Expand All @@ -316,7 +316,7 @@ def checkboxes_help
mode = (ENV["Y2STYLE"] == "installation.qss") ? "inst" : "normal"

header + "<p>" \
"<img src='#{IMAGE_DIR}/#{IMAGES["#{mode}:on:enabled"]}'></img> = " + selected +
"<img src='#{IMAGE_DIR}/#{IMAGES["#{mode}:on:enabled"]}'></img> = " + selected +
"<img src='#{IMAGE_DIR}/#{IMAGES["#{mode}:off:enabled"]}'></img> = " + deselected +
"<img src='#{IMAGE_DIR}/#{IMAGES["#{mode}:auto:enabled"]}'></img> = " + auto_selected +
"</p>"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/registration/ui/autoyast_addon_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(addons)
def run
# help text
help_text = _("<p>Here you can select which extensions or modules"\
"will be registered together with the base product.</p>")
"will be registered together with the base product.</p>")

Wizard.SetContents(_("Register Optional Extensions or Modules"), content,
help_text, true, true)
Expand Down
12 changes: 6 additions & 6 deletions src/lib/registration/ui/autoyast_config_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def run
help_text = "<p><b>#{caption}</b></p>"
help_text += _(
"<p>Product registration includes your product in SUSE Customer " \
"Center database,\nenabling you to get online updates and " \
"technical support.\nTo register while installing automatically, " \
"select <b>Run Product Registration</b>.</p>"
"Center database,\nenabling you to get online updates and " \
"technical support.\nTo register while installing automatically, " \
"select <b>Run Product Registration</b>.</p>"
)
help_text += _(
"<p>If your network deploys a custom registration server, set the " \
"correct URL of the server\nand the location of the RMT " \
"certificate in <b>RMT Server Settings</b>. Refer\nto your RMT " \
"manual for further assistance.</p>"
"correct URL of the server\nand the location of the RMT " \
"certificate in <b>RMT Server Settings</b>. Refer\nto your RMT " \
"manual for further assistance.</p>"
)

# FIXME: the dialog should be created by external code before calling this
Expand Down
6 changes: 3 additions & 3 deletions src/lib/registration/ui/base_system_registration_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def online_skipping_text
# TRANSLATORS:
# Popup (1/3) : Installation cannot be continued without registration.
warning = _("<p>This installation is online only which requires registration for "\
"package repositories.</p>")
"package repositories.</p>")

# these cannot be nil
if !media_name.empty? && !download_url.empty?
Expand All @@ -456,15 +456,15 @@ def online_skipping_text
# %{download_url} is an URL link (e.g. https://download.suse.com)
msg = format(_(
"<p>For installation without registering the system please "\
"install using the %{media_name} installation media from %{download_url}.</p>"
"install using the %{media_name} installation media from %{download_url}.</p>"
),
media_name: media_name, download_url: download_url) # these cannot be nil
warning += msg

else
# TRANSLATORS: a popup message (3/3) the user wants to skip the registration
warning += _("<p>For installations without registration please "\
"install using full installation media.</p>")
"install using full installation media.</p>")
end
warning
end
Expand Down
8 changes: 4 additions & 4 deletions src/lib/registration/ui/import_certificate_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def initialize(cert, error_code)
# @return [Symbol] user input (:import, :cancel)
def run
log.info "Certificate import dialog: issuer: #{certificate.issuer_name}, " \
"subject: #{certificate.subject_name}, SHA1: " \
"#{certificate.fingerprint(Fingerprint::SHA1).value}"
"subject: #{certificate.subject_name}, SHA1: " \
"#{certificate.fingerprint(Fingerprint::SHA1).value}"

Yast::UI.OpenDialog(Opt(:decorated), import_dialog_content)

Expand Down Expand Up @@ -109,8 +109,8 @@ def certificate_description
details = SslCertificateDetails.new(certificate)

"<h2>#{_("Secure Connection Error")}</h2>\n" \
"<p>#{_("Details:")} #{h(url)}: #{h(msg)}</p>\n" \
"<h3>#{_("Failed Certificate Details")}</h3>\n" +
"<p>#{_("Details:")} #{h(url)}: #{h(msg)}</p>\n" \
"<h3>#{_("Failed Certificate Details")}</h3>\n" +
details.richtext_summary
end

Expand Down
6 changes: 3 additions & 3 deletions src/lib/registration/ui/media_addon_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def find_products
if products.empty?
repo_data = Pkg.SourceGeneralData(repo_id)
log.warn "Repository #{repo_data["name"]} (#{repo_data["alias"]}) " \
"does not provide any product resolvable"
"does not provide any product resolvable"
log.warn "Skipping add-on registration"
return :finish
end
Expand All @@ -129,8 +129,8 @@ def register_base

if !Registration.is_registered? &&
Yast::Popup.YesNo(_("The base system has to be registered " \
"in order to register the '%s' add-on.\nSkip the base system " \
"and the add-on registration?") %
"in order to register the '%s' add-on.\nSkip the base system " \
"and the add-on registration?") %
Pkg.SourceGeneralData(repo_id)["name"])

return :skip
Expand Down
24 changes: 12 additions & 12 deletions src/lib/registration/ui/migration_repos_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def registration_check
# pressing [Continue] starts the registration module, [Cancel] aborts
# the online migration
register = Yast::Popup.ContinueCancel(_("The system is not registered,\n" \
"to run the online migration you need\n" \
"to register the system first."))
"to run the online migration you need\n" \
"to register the system first."))

return :abort unless register

Expand Down Expand Up @@ -273,9 +273,9 @@ def merge_registered_addons
# installed to the current migration products list.
# %s is an addon friendly name, e.g 'SUSE Enterprise Storage 2 x86_64'
msg = _("The '%s' extension is registered but not installed.\n" \
"If you accept it will be added for be installed, in other case " \
"it will be unregistered at the end of the migration.\n\n" \
"Do you want to add it?")
"If you accept it will be added for be installed, in other case " \
"it will be unregistered at the end of the migration.\n\n" \
"Do you want to add it?")

addons =
Addon.registered_not_installed.each_with_object([]) do |addon, result|
Expand Down Expand Up @@ -369,9 +369,9 @@ def load_migrations_for_products(products, remote_product)
_("No migration product found."),
# TRANSLATORS: Help message, %{product} is the product name
format(_("Please, boot the original system and make sure " \
"that all registerable products are correctly registered.\n" \
"Also check that the installed system is supported for upgrade to \n" \
"%{product}."),
"that all registerable products are correctly registered.\n" \
"Also check that the installed system is supported for upgrade to \n" \
"%{product}."),
product: Y2Packager::ProductUpgrade.new_base_product.display_name)
]

Expand Down Expand Up @@ -403,7 +403,7 @@ def migration_confirmed?(base_product, activations)
# TRANSLATORS: Continue/Cancel popup question, confirm the migration by user,
# %s is a product name, e.g. "SUSE Linux Enterprise Server 15"
message = _("The product %s\nis already activated on this system.\n\n" \
"Migrating again to the same product might not work properly.") %
"Migrating again to the same product might not work properly.") %
base_product.label
ui = Yast2::Popup.show(message, buttons: :continue_cancel, focus: :cancel)
log.info("Use input: #{ui.inspect}")
Expand Down Expand Up @@ -807,8 +807,8 @@ def media_upgrade(registered)
# User requested media based upgrade which does not use SCC/SMT/RMT
# but the downloaded media (physical DVD or shared repo on a local server).
ret = _("<h2>Media Based Upgrade</h2><p>The media based upgrade is requested. " \
"In this mode YaST will not contact the registration server to obtain " \
"the new software repositories required for migration.</p>") +
"In this mode YaST will not contact the registration server to obtain " \
"the new software repositories required for migration.</p>") +
# TRANSLATORS: Media based upgrade requested by user (2/3)
_("<p>Please add the installation media manually in the next step.</p>")

Expand All @@ -817,7 +817,7 @@ def media_upgrade(registered)
# TRANSLATORS: a warning message, upgrading the registered systems
# using media is not supported
ret + _("<h2>Warning!</h2><p><b>The media based upgrade for registered " \
"systems is not supported!<b></p>") +
"systems is not supported!<b></p>") +
_("<p>If you upgrade the system using media the registration status " \
"will not be updated and the system will be still registered " \
"using the previous product. The packages from the registration " \
Expand Down
Loading

0 comments on commit 0859b18

Please sign in to comment.