Skip to content

Commit

Permalink
fix Style/ConditionalAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Nov 22, 2021
1 parent 3e932a1 commit b55fd93
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 40 deletions.
13 changes: 0 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,6 @@ Security/YAMLLoad:
- 'src/modules/ZFCPController.rb'
- 'test/test_helper.rb'

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'src/include/s390/dasd/dialogs.rb'
- 'src/include/s390/iucvterminal-server/ui.rb'
- 'src/include/s390/zfcp/dialogs.rb'
- 'src/modules/DASDController.rb'
- 'src/modules/IUCVTerminalServer.rb'
- 'src/modules/ZFCPController.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/ExpandPathArguments:
Expand Down
18 changes: 9 additions & 9 deletions src/include/s390/dasd/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ def GetDASDDiskItems

items = []

if Mode.config
items = Builtins.maplist(devices) do |k, d|
items = if Mode.config
Builtins.maplist(devices) do |k, d|
channel = Ops.get_string(d, "channel", "")
diag = String.YesNo(Ops.get_boolean(d, "diag", false))
format = String.YesNo(Ops.get_boolean(d, "format", false))
Item(Id(k), channel, format, diag)
end
else
items = Builtins.maplist(devices) do |k, d|
Builtins.maplist(devices) do |k, d|
active = Ops.get_boolean(d, ["resource", "io", 0, "active"], false)
channel = Ops.get_string(d, "channel", "")
access = Builtins.toupper(
Expand Down Expand Up @@ -237,11 +237,11 @@ def PerformAction(action)
unformatted_disks << channel if act_ret == 8 # 8 means disk is not formatted
end
if !unformatted_disks.empty?
if unformatted_disks.size == 1
popup = Builtins.sformat(_("Device %1 is not formatted. Format device now?"),
popup = if unformatted_disks.size == 1
Builtins.sformat(_("Device %1 is not formatted. Format device now?"),
unformatted_disks[0])
else
popup = Builtins.sformat(_("There are %1 unformatted devices. Format them now?"),
Builtins.sformat(_("There are %1 unformatted devices. Format them now?"),
unformatted_disks.size)
end
# for autoinst, format unformatted disks later
Expand Down Expand Up @@ -409,8 +409,8 @@ def DisplayDASDDialog

header = Empty()

if Mode.config
header = Header(
header = if Mode.config
Header(
# table header
Right(_("Channel ID")),
# table header
Expand All @@ -419,7 +419,7 @@ def DisplayDASDDialog
_("Use DIAG")
)
else
header = Header(
Header(
# table header
Right(_("Channel ID")),
# table header
Expand Down
6 changes: 3 additions & 3 deletions src/include/s390/iucvterminal-server/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1175,12 +1175,12 @@ def HandleEvent(widget)
Builtins.size(GenerateTsMembersTable()),
0
)
if ts_isnt_empty
@ts_selected_member = Convert.to_string(
@ts_selected_member = if ts_isnt_empty
Convert.to_string(
UI.QueryWidget(Id(:ts_users_groups), :CurrentItem)
)
else
@ts_selected_member = ""
""
end

# show the current selected user
Expand Down
12 changes: 6 additions & 6 deletions src/include/s390/zfcp/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ def GetZFCPDiskItems

items = []

if Mode.config
items = Builtins.maplist(devices) do |k, d|
items = if Mode.config
Builtins.maplist(devices) do |k, d|
channel = Ops.get_string(d, ["detail", "controller_id"], "")
wwpn = Ops.get_string(d, ["detail", "wwpn"], "")
lun = Ops.get_string(d, ["detail", "fcp_lun"], "")
Item(Id(k), channel, wwpn, lun)
end
else
items = Builtins.maplist(devices) do |k, d|
Builtins.maplist(devices) do |k, d|
channel = Ops.get_string(d, ["detail", "controller_id"], "")
wwpn = Ops.get_string(d, ["detail", "wwpn"], "")
lun = Ops.get_string(d, ["detail", "fcp_lun"], "")
Expand All @@ -108,8 +108,8 @@ def DisplayZFCPDialog

header = Empty()

if Mode.config
header = Header(
header = if Mode.config
Header(
# table header
Right(_("Channel ID")),
# table header
Expand All @@ -118,7 +118,7 @@ def DisplayZFCPDialog
Right(_("LUN"))
)
else
header = Header(
Header(
# table header
Right(_("Channel ID")),
# table header
Expand Down
6 changes: 3 additions & 3 deletions src/modules/DASDController.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ def Write
end

if !unformatted_devices.empty?
if unformatted_devices.size == 1
message = Builtins.sformat(_("Device %1 is not formatted. Format device now?"),
message = if unformatted_devices.size == 1
Builtins.sformat(_("Device %1 is not formatted. Format device now?"),
unformatted_devices[0])
else
message = Builtins.sformat(_("There are %1 unformatted devices. Format them now?"),
Builtins.sformat(_("There are %1 unformatted devices. Format them now?"),
unformatted_devices.size)
end
if Popup.ContinueCancel(message)
Expand Down
6 changes: 3 additions & 3 deletions src/modules/IUCVTerminalServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,16 @@ def Read
Convert.to_string(SCR.Read(path(".target.string"), filename)),
"\n"
)
if Builtins.contains(original_ts_audited_ids, "[*ALL*]")
@ts_audited_ids = if Builtins.contains(original_ts_audited_ids, "[*ALL*]")
# add all if configured
@ts_audited_ids = Convert.convert(
Convert.convert(
Builtins.merge([@TEXT_ALL], @zvm_id_list),
from: "list",
to: "list <string>"
)
else
# only add known ids
@ts_audited_ids = Builtins.filter(original_ts_audited_ids) do |name|
Builtins.filter(original_ts_audited_ids) do |name|
!Builtins.contains(@zvm_id_list, name)
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ZFCPController.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def GetDeviceIndex(channel, wwpn, lun)
def Summary
ret = []

if Mode.config
ret = Builtins.maplist(@devices) do |_index, d|
ret = if Mode.config
Builtins.maplist(@devices) do |_index, d|
Builtins.sformat(
_("Channel ID: %1, WWPN: %2, LUN: %3"),
Ops.get_string(d, ["detail", "controller_id"], ""),
Expand All @@ -272,7 +272,7 @@ def Summary
)
end
else
ret = Builtins.maplist(@devices) do |_index, d|
Builtins.maplist(@devices) do |_index, d|
Builtins.sformat(
_("Channel ID: %1, WWPN: %2, LUN: %3, Device: %4"),
Ops.get_string(d, ["detail", "controller_id"], ""),
Expand Down

0 comments on commit b55fd93

Please sign in to comment.