Skip to content

Commit

Permalink
Merge pull request #874 from yast/rubocop_update
Browse files Browse the repository at this point in the history
Rubocop update
  • Loading branch information
jreidinger committed Dec 28, 2023
2 parents 519c4d8 + 4ef9ed8 commit c2dc345
Show file tree
Hide file tree
Showing 72 changed files with 649 additions and 644 deletions.
53 changes: 8 additions & 45 deletions .rubocop.yml
@@ -1,6 +1,6 @@
# use the shared Yast defaults
inherit_from:
- /usr/share/YaST2/data/devtools/data/rubocop-0.71.0_yast_style.yml
- /usr/share/YaST2/data/devtools/data/rubocop-1.24.1_yast_style.yml

# this needs more testing if we can have frozen string literals
Style/FrozenStringLiteralComment:
Expand All @@ -10,46 +10,9 @@ Naming/FileName:
Include:
- "library/*/src/lib/**/*.rb"

# TODO: enable it, just ENOTIME
# Offense count: 21
Lint/Loop:
Exclude:
- 'src/clients/files_auto.rb'
- 'src/clients/inst_autosetup.rb'
- 'src/clients/inst_autosetup_upgrade.rb'
- 'src/clients/report_auto.rb'
- 'src/clients/software_auto.rb'
- 'src/include/autoinstall/classes.rb'
- 'src/include/autoinstall/dialogs.rb'
- 'src/include/autoinstall/general_dialogs.rb'
- 'src/include/autoinstall/script_dialogs.rb'
- 'src/modules/Profile.rb'
- 'src/modules/ProfileLocation.rb'

# TODO: enable it, just ENOTIME
# Offense count: 7
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'src/clients/inst_autoinit.rb'
- 'src/include/autoinstall/conftree.rb'
- 'src/include/autoinstall/general_dialogs.rb'

# TODO: enable it, just ENOTIME
# Offense count: 27
# Configuration parameters: AllowKeywordBlockArguments.
Lint/UnderscorePrefixedVariableName:
Exclude:
- 'src/clients/inst_autoconfigure.rb'
- 'src/clients/inst_autopost.rb'
- 'src/include/autoinstall/classes.rb'
- 'src/include/autoinstall/conftree.rb'
- 'src/modules/AutoInstallRules.rb'
- 'src/modules/Profile.rb'
- 'src/modules/Y2ModuleConfig.rb'

# Offense count: 95
# GeneralDialogs.AskDialog rules them all
Metrics/AbcSize:
Max: 448
Max: 455

# Offense count: 105
# Configuration parameters: CountComments, ExcludedMethods.
Expand All @@ -70,9 +33,9 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Max: 1000

# Offense count: 82
# GeneralDialogs.AskDialog rules them all
Metrics/CyclomaticComplexity:
Max: 78
Max: 86

# Offense count: 112
# Configuration parameters: CountComments, ExcludedMethods.
Expand All @@ -82,7 +45,7 @@ Metrics/MethodLength:
# Offense count: 12
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 1062
Max: 1063

# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Expand Down Expand Up @@ -110,7 +73,7 @@ Naming/MethodName:
# TODO: enable it, just ENOTIME
# Offense count: 16
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
Naming/UncommunicativeBlockParamName:
Naming/BlockParameterName:
Exclude:
- 'src/clients/clone_system.rb'
- 'src/include/autoinstall/PartitionDialog.rb'
Expand All @@ -124,7 +87,7 @@ Naming/UncommunicativeBlockParamName:
# Offense count: 91
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
Enabled: false

# Offense count: 573
Expand Down
2 changes: 1 addition & 1 deletion doc/profile_conversions.md
Expand Up @@ -37,7 +37,7 @@ data types to the old ones. This is useful if you want to use a new profile
in an old system (SLE15-SP2 and older). The old AutoYaST cannot read the new
data types and it would fail.

The [`old_types.xslt`](../xslt/old_types.xslt) file converts the short
The [old_types.xslt](../xslt/old_types.xslt) file converts the short
attributes `t="boolean"` to long attributes `config:type="boolean"`.

```shell
Expand Down
5 changes: 3 additions & 2 deletions src/clients/autoinst_scripts1_finish.rb
Expand Up @@ -36,7 +36,8 @@ def main
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Info"
case @func
when "Info"
return {
"steps" => 1,
# progress step title
Expand All @@ -45,7 +46,7 @@ def main
),
"when" => [:autoinst, :autoupg]
}
elsif @func == "Write"
when "Write"
AutoinstScripts.Write("chroot-scripts", false)
AutoInstall.Finish(Installation.destdir)
else
Expand Down
5 changes: 3 additions & 2 deletions src/clients/autoinst_scripts2_finish.rb
Expand Up @@ -35,7 +35,8 @@ def main
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Info"
case @func
when "Info"
return {
"steps" => 1,
# progress step title
Expand All @@ -44,7 +45,7 @@ def main
),
"when" => [:autoinst, :autoupg]
}
elsif @func == "Write"
when "Write"
# Calling chroot scripts
AutoinstScripts.Write("chroot-scripts", true)

Expand Down
11 changes: 6 additions & 5 deletions src/clients/classes_auto.rb
Expand Up @@ -35,7 +35,8 @@ def main
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Import"
case @func
when "Import"
@ret = AutoinstClass.Import(
Convert.convert(@param, from: "list", to: "list <map>")
)
Expand All @@ -46,18 +47,18 @@ def main
@ret = false
end
# create a summary
elsif @func == "Summary"
when "Summary"
@ret = AutoinstClass.Summary
elsif @func == "Reset"
when "Reset"
AutoinstClass.Import([])
@ret = []
elsif @func == "Change"
when "Change"
Wizard.CreateDialog
Wizard.SetDesktopIcon("general")
@ret = classConfiguration
Wizard.CloseDialog
return deep_copy(@ret)
elsif @func == "Export"
when "Export"
@ret = AutoinstClass.Export
else
Builtins.y2error("unknown function: %1", @func)
Expand Down
15 changes: 8 additions & 7 deletions src/clients/general_auto.rb
Expand Up @@ -35,22 +35,23 @@ def main
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Import"
case @func
when "Import"
@ret = AutoinstGeneral.Import(@param)
# create a summary
elsif @func == "Summary"
when "Summary"
@ret = AutoinstGeneral.Summary
elsif @func == "GetModified"
when "GetModified"
@ret = AutoinstGeneral.GetModified
elsif @func == "SetModified"
when "SetModified"
AutoinstGeneral.SetModified
elsif @func == "Reset"
when "Reset"
AutoinstGeneral.Import({})
@ret = {}
elsif @func == "Change"
when "Change"
@ret = generalSequence
return deep_copy(@ret)
elsif @func == "Export"
when "Export"
@ret = AutoinstGeneral.Export
else
Builtins.y2error("unknown function: %1", @func)
Expand Down
6 changes: 3 additions & 3 deletions src/clients/inst_autoconfigure.rb
Expand Up @@ -40,8 +40,8 @@ def main
# Help text for last dialog of base installation
@help_text = _(
"<p>\n" \
"Please wait while the system is being configured.\n" \
"</p>"
"Please wait while the system is being configured.\n" \
"</p>"
)

log.info "Profile general,mode:#{AutoinstGeneral.mode.inspect}"
Expand Down Expand Up @@ -193,7 +193,7 @@ def main
logStep(_("Restarting all running services"))
@cmd = "systemctl --type=service list-units | grep \" running \""
@out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd))
@sl = Ops.get_string(@out, "stdout", "").split("\n").collect { |c| c.split(" ").first }
@sl = Ops.get_string(@out, "stdout", "").split("\n").collect { |c| c.split.first }
Builtins.y2milestone("running services \"%1\"", @sl)

# Filtering out all services which must not to be restarted
Expand Down
3 changes: 1 addition & 2 deletions src/clients/inst_autopost.rb
Expand Up @@ -125,12 +125,11 @@ def dirname(filePath)
Ops.subtract(Builtins.size(pathComponents), 1),
""
)
ret = Builtins.substring(
Builtins.substring(
filePath,
0,
Ops.subtract(Builtins.size(filePath), Builtins.size(last))
)
ret
end
end
end
Expand Down
16 changes: 7 additions & 9 deletions src/clients/inst_store_upgrade_software.rb
Expand Up @@ -18,16 +18,15 @@ def main
p.transact_by == :app_high
end

# note: does not matter if it is installed or to be installed, the resulting
# NOTE: does not matter if it is installed or to be installed, the resulting
# state is the same; similar for uninstallation (valid for all packages, patterns
# and products
@patterns_to_remove = []
@patterns_to_install = @patterns.map do |p|
if p.status == :selected ||
p.status == :installed
case p.status
when :selected, :installed
next p.name
elsif p.status == :removed ||
p.status == :available
when :removed, :available
@patterns_to_remove << p.name
end

Expand Down Expand Up @@ -56,11 +55,10 @@ def main

@products_to_remove = []
@products_to_install = @products.map do |p|
if p.status == :selected ||
p.status == :installed
case p.status
when :selected, :installed
next p.name
elsif p.status == :removed ||
p.status == :available
when :removed, :available
@products_to_remove << p.name
end

Expand Down
17 changes: 9 additions & 8 deletions src/clients/storage_auto.rb
Expand Up @@ -40,7 +40,8 @@ def main
Builtins.y2debug("param=%1", @param)

# Import Data
if @func == "Import"
case @func
when "Import"
@ret = AutoinstPartPlan.Import(
Convert.convert(@param, from: "list", to: "list <map>")
)
Expand All @@ -51,29 +52,29 @@ def main
@ret = false
end
Builtins.y2milestone("Import: %1", @param)
elsif @func == "Read"
when "Read"
@ret = AutoinstPartPlan.Read
# Create a summary
elsif @func == "Summary"
when "Summary"
@ret = AutoinstPartPlan.Summary
# Reset configuration
elsif @func == "Reset"
when "Reset"
AutoinstPartPlan.Reset
@ret = []
# Change configuration (run AutoSequence)
elsif @func == "Change"
when "Change"
storage_dialog = build_storage_dialog
@ret = storage_dialog.run
# After succesfully editing the storage settings, import the result as
# the new partition plan.
AutoinstPartPlan.Import(storage_dialog.partitioning) if @ret == :next
# Return actual state
elsif @func == "Export"
when "Export"
@ret = AutoinstPartPlan.Export
# Return true if modified
elsif @func == "GetModified"
when "GetModified"
@ret = AutoinstPartPlan.GetModified
elsif @func == "SetModified"
when "SetModified"
AutoinstPartPlan.SetModified
else
Builtins.y2error("Unknown function: %1", @func)
Expand Down

0 comments on commit c2dc345

Please sign in to comment.