Skip to content

Commit

Permalink
Merge pull request #157 from yast/update_rubocop
Browse files Browse the repository at this point in the history
Update rubocop
  • Loading branch information
jreidinger authored Dec 29, 2023
2 parents a9a6f29 + 7db7fc5 commit e28faa1
Show file tree
Hide file tree
Showing 26 changed files with 510 additions and 931 deletions.
454 changes: 9 additions & 445 deletions .rubocop.yml

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions src/clients/security.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -35,7 +33,7 @@ class SecurityClient < Client
def main
Yast.import "UI"

#**
# **
# <h3> Security configuration

textdomain "security"
Expand Down Expand Up @@ -87,7 +85,7 @@ def main
}
},
"options" => {
"workstation" => {
"workstation" => {
# command line help text for 'level workstation' option
"help" => _(
"Workstation security level"
Expand Down Expand Up @@ -140,7 +138,7 @@ def main
"mappings" => {
"summary" => [],
"level" => ["workstation", "roaming", "server"],
#FIXME: 1,2,3 aliases
# FIXME: 1,2,3 aliases
"set" => [
"passwd",
"crack",
Expand All @@ -156,7 +154,7 @@ def main
# Finish
Builtins.y2milestone("Security module finished")
Builtins.y2milestone("----------------------------------------")
deep_copy(@ret)
deep_copy(@ret)

# EOF
end
Expand All @@ -166,8 +164,7 @@ def main

# Print security summary
# @return [Boolean] false
def SecuritySummaryHandler(options)
options = deep_copy(options)
def SecuritySummaryHandler(_options)
sum = Security.Summary
CommandLine.Print(Ops.get_string(sum, 0, ""))
false # do not call Write...
Expand Down Expand Up @@ -204,7 +201,7 @@ def SecuritySetHandler(options)
options = deep_copy(options)
if Builtins.haskey(options, "passwd") &&
Ops.get_string(options, "passwd", "") !=
Ops.get(Security.Settings, "PASSWD_ENCRYPTION", "")
Ops.get(Security.Settings, "PASSWD_ENCRYPTION", "")
Ops.set(
Security.Settings,
"PASSWD_ENCRYPTION",
Expand All @@ -214,7 +211,7 @@ def SecuritySetHandler(options)
end
if Builtins.haskey(options, "crack") &&
Ops.get_string(options, "crack", "") !=
Ops.get(Security.Settings, "PASSWD_USE_PWQUALITY", "")
Ops.get(Security.Settings, "PASSWD_USE_PWQUALITY", "")
Ops.set(
Security.Settings,
"PASSWD_USE_PWQUALITY",
Expand All @@ -237,11 +234,11 @@ def SecuritySetHandler(options)

if Builtins.haskey(options, "remember") &&
Ops.get(Security.Settings, "PASSWD_REMEMBER_HISTORY", "0") !=
Ops.get_string(options, "remember", "0")
Ops.get_string(options, "remember", "0")
to_remember = Builtins.tointeger(
Ops.get_string(options, "remember", "0")
)
if to_remember == nil || Ops.less_than(to_remember, 0) ||
if to_remember.nil? || Ops.less_than(to_remember, 0) ||
Ops.greater_than(to_remember, 400)
# error message
Report.Error(
Expand Down
29 changes: 14 additions & 15 deletions src/clients/security_auto.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -71,18 +69,19 @@ def main
Builtins.y2debug("param=%1", @param)

# Create a summary
if @func == "Summary"
case @func
when "Summary"
@summary = Security.Summary
@ret = Ops.get_string(@summary, 0, "")
# Reset configuration
elsif @func == "Reset"
when "Reset"
Security.Import({})
@ret = {}
# Change configuration (run AutoSequence)
elsif @func == "Change"
when "Change"
@ret = SecurityAutoSequence()
# Import Data
elsif @func == "Import"
when "Import"

# Checking value semantic
if @param.key?("selinux_mode")
Expand Down Expand Up @@ -110,37 +109,37 @@ def main
end
@ret = Security.Import(
Map.KeysToUpper(
Convert.convert(@param, :from => "map", :to => "map <string, any>")
Convert.convert(@param, from: "map", to: "map <string, any>")
)
)
# Return required packages
elsif @func == "Packages"
when "Packages"
@ret = {}
# Return actual state
elsif @func == "Export"
when "Export"
@ret = Map.KeysToLower(
Convert.convert(
Security.Export,
:from => "map",
:to => "map <string, any>"
from: "map",
to: "map <string, any>"
)
)
# Read current state
elsif @func == "Read"
when "Read"
Yast.import "Progress"
Progress.off
@ret = Security.Read
Progress.on
# Write givven settings
elsif @func == "Write"
when "Write"
Yast.import "Progress"
Security.write_only = true
Progress.off
@ret = Security.Write
Progress.on
elsif @func == "SetModified"
when "SetModified"
@ret = Security.SetModified
elsif @func == "GetModified"
when "GetModified"
@ret = Security.GetModified
else
Builtins.y2error("Unknown function: %1", @func)
Expand Down
4 changes: 1 addition & 3 deletions src/clients/security_summary.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -48,7 +46,7 @@ def main
# Finish
Builtins.y2milestone("Security summary finished")
Builtins.y2milestone("----------------------------------------")
@ret
@ret

# EOF
end
Expand Down
39 changes: 15 additions & 24 deletions src/include/security/complex.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
#
Expand Down Expand Up @@ -46,7 +44,7 @@ def initialize_security_complex(include_target)
# @return `next if success, else `abort
def WriteDialog
Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
Security.AbortFunction = lambda { Security.PollAbort }
Security.AbortFunction = -> { Security.PollAbort }
ret = Security.Write
ret ? :next : :abort
end
Expand All @@ -72,20 +70,20 @@ def MainDialog
Builtins.y2debug("%1=%2", current, Security.Settings)

# Create RB group from the list of settings
_RB = VBox()
_RB = Builtins.add(_RB, VSpacing(0.5))
rb = VBox()
rb = Builtins.add(rb, VSpacing(0.5))
Builtins.mapmap(@LevelsLabels) do |key, name|
_RB = Builtins.add(
_RB,
rb = Builtins.add(
rb,
Left(RadioButton(Id(key), Opt(:notify), name, key == current))
)
_RB = Builtins.add(_RB, VSpacing(0.03))
rb = Builtins.add(rb, VSpacing(0.03))
{ 0 => 0 }
end
_RB = Builtins.add(_RB, VSpacing(0.6))
rb = Builtins.add(rb, VSpacing(0.6))
# RadioButton label
_RB = Builtins.add(
_RB,
rb = Builtins.add(
rb,
Left(
RadioButton(
Id(:custom),
Expand All @@ -95,8 +93,8 @@ def MainDialog
)
)
)
_RB = Builtins.add(_RB, VSpacing(0.5))
Builtins.y2debug("RB=%1", _RB)
rb = Builtins.add(rb, VSpacing(0.5))
Builtins.y2debug("RB=%1", rb)

# Main dialog contents
contents = HVCenter(
Expand All @@ -105,7 +103,7 @@ def MainDialog
# Frame caption
Frame(
_("Security Settings"),
HBox(HSpacing(0.8), RadioButtonGroup(Id(:rb), _RB), HSpacing(0.8))
HBox(HSpacing(0.8), RadioButtonGroup(Id(:rb), rb), HSpacing(0.8))
)
),
VSpacing(0.6)
Expand Down Expand Up @@ -138,16 +136,9 @@ def MainDialog
ret = UI.UserInput

# abort?
if ret == :abort || ret == :cancel
if ReallyAbort()
break
else
next
end
elsif ret == :back
break
elsif ret == :next
# check_*
if [:abort, :cancel].include?(ret)
ReallyAbort() ? break : next
elsif [:back, :next].include?(ret)
break
elsif ret == :custom
next
Expand Down
Loading

0 comments on commit e28faa1

Please sign in to comment.