Skip to content

Commit

Permalink
style manual changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed May 11, 2015
1 parent 1b105fe commit 9633617
Show file tree
Hide file tree
Showing 46 changed files with 884 additions and 982 deletions.
39 changes: 37 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,46 @@ Metrics/ParameterLists:
Metrics/PerceivedComplexity:
Max: 59

# Offense count: 1
Style/AccessorMethodName:
# Offense count: 436
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodName:
Enabled: false

# Offense count: 94
Style/Documentation:
Enabled: false

# Offense count: 436
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodName:
Enabled: false

# Offense count: 97
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
Enabled: false

# Offense count: 1
Style/ClassVars:
Enabled: false

# Offense count: 20
# Configuration parameters: Exclude.
Style/FileName:
Enabled: false

# Offense count: 1
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
Enabled: false

# Offense count: 1
Style/AccessorMethodName:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
Style/TrivialAccessors:
Enabled: false

4 changes: 1 addition & 3 deletions src/clients/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ def DNSGUI

# Handler for action "list"
# @param [Hash{String => String}] options action options
def ListHandler(options)
options = deep_copy(options)
summary = ""
def ListHandler(_options)
# Command line output Headline
summary = Ops.add(
Ops.add(
Expand Down
71 changes: 40 additions & 31 deletions src/clients/firewall_stage1_proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
# **************************************************************************

# File: firewall_stage1_proposal.ycp
# Summary: Configuration of fw in 1st stage
# Author: Bubli <kmachalkova@suse.cz>
#
require "yast"

# yast namespace
module Yast
# Configuration of fw in 1st stage
class FirewallStage1ProposalClient < Client
PROPOSAL_ID = "fw_1ststage"

Expand All @@ -42,6 +43,7 @@ class FirewallStage1ProposalClient < Client
LINK_DISABLE_VNC = "firewall--disable_vnc_in_proposal"
LINK_FIREWALL_DIALOG = "firewall_stage1"

# Namespace for UI constants
module ID
SSH_PORT = "open_ssh_port"
VNC_PORT = "open_vnc_port"
Expand Down Expand Up @@ -201,15 +203,18 @@ def FirewallDialogSimple
"<p>With enabled firewall, you can decide whether to open firewall port for SSH\n" \
"service and allow remote SSH logins. Independently you can also enable SSH service (i.e. it\n" \
"will be started on computer boot).</p>"
) +
(Linuxrc.vnc ?
# TRANSLATORS: help text
_(
"<p>You can also open VNC ports in firewall. It will not enable\n" \
"the remote administration service on a running system but it is\n" \
"started by the installer automatically if needed.</p>"
) :
"")
) + (
if Linuxrc.vnc
# TRANSLATORS: help text
_(
"<p>You can also open VNC ports in firewall. It will not enable\n" \
"the remote administration service on a running system but it is\n" \
"started by the installer automatically if needed.</p>"
)
else
""
end
)

Wizard.CreateDialog
Wizard.SetTitleIcon("yast-firewall")
Expand Down Expand Up @@ -273,23 +278,25 @@ def FirewallDialogSimple
private

def preformatted_proposal
firewall_proposal = SuSEFirewall4Network.Enabled1stStage ?
_(
"Firewall will be enabled (<a href=\"%s\">disable</a>)"
) % LINK_DISABLE_FIREWALL
:
_(
"Firewall will be disabled (<a href=\"%s\">enable</a>)"
) % LINK_ENABLE_FIREWALL

sshd_proposal = SuSEFirewall4Network.EnabledSshd ?
_(
"SSH service will be enabled (<a href=\"%s\">disable</a>)"
) % LINK_DISABLE_SSHD
:
_(
"SSH service will be disabled (<a href=\"%s\">enable</a>)"
) % LINK_ENABLE_SSHD
firewall_proposal = if SuSEFirewall4Network.Enabled1stStage
_(
"Firewall will be enabled (<a href=\"%s\">disable</a>)"
) % LINK_DISABLE_FIREWALL
else
_(
"Firewall will be disabled (<a href=\"%s\">enable</a>)"
) % LINK_ENABLE_FIREWALL
end

This comment has been minimized.

Copy link
@mchf

mchf May 12, 2015

Member

I personally dislike this style - too much white space at the beginning of lines.

This comment has been minimized.

Copy link
@jreidinger

jreidinger May 12, 2015

Author Member

well, advantage of this style is that you can clearly see what belongs to what. If you just quick scan code without reading it, you see that whole this block belongs together. Another option is to have firewall_proposal in each branch of condition.


sshd_proposal = if SuSEFirewall4Network.EnabledSshd
_(
"SSH service will be enabled (<a href=\"%s\">disable</a>)"
) % LINK_DISABLE_SSHD
else
_(
"SSH service will be disabled (<a href=\"%s\">enable</a>)"
) % LINK_ENABLE_SSHD
end

# Filter proposals with content and sort them
proposals = [firewall_proposal, ssh_fw_proposal, sshd_proposal, vnc_fw_proposal].compact
Expand Down Expand Up @@ -334,10 +341,11 @@ def vnc_fw_proposal
# Show VNC port only if installing over VNC
return nil unless Linuxrc.vnc

SuSEFirewall4Network.EnabledVnc1stStage ?
if SuSEFirewall4Network.EnabledVnc1stStage
_("VNC ports will be open (<a href=\"%s\">close</a>)") % LINK_DISABLE_VNC
:
else
_("VNC ports will be blocked (<a href=\"%s\">open</a>)") % LINK_ENABLE_VNC
end
end

# Returns the SSH-port part of the firewall proposal description
Expand All @@ -347,10 +355,11 @@ def ssh_fw_proposal
return nil unless SuSEFirewall4Network.Enabled1stStage
return nil unless known_firewall_services?(SuSEFirewall4NetworkClass::SSH_SERVICES)

SuSEFirewall4Network.EnabledSsh1stStage ?
if SuSEFirewall4Network.EnabledSsh1stStage
_("SSH port will be open (<a href=\"%s\">block</a>)") % LINK_BLOCK_SSH_PORT
:
else
_("SSH port will be blocked (<a href=\"%s\">open</a>)") % LINK_OPEN_SSH_PORT
end
end

# Returns true if all services are known to firewall
Expand Down
4 changes: 1 addition & 3 deletions src/clients/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ def HostGUI

# Handler for action "list"
# @param [Hash{String => String}] options action options
def ListHandler(options)
options = deep_copy(options)
summary = ""
def ListHandler(_options)
# Command line output Headline
# configuration of hosts
summary = Ops.add(
Expand Down
2 changes: 1 addition & 1 deletion src/clients/inst_ask_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main
Yast.include self, "network/installation/dialogs.rb"

if Mode.update
# FIXME should be made somewhere else
# FIXME: should be made somewhere else

Builtins.y2milestone("starting network")
SCR.Execute(path(".target.bash"), "/sbin/rcnetwork start")
Expand Down
48 changes: 22 additions & 26 deletions src/clients/inst_do_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,10 @@ def make_dialog
Left(HBox(Heading(Id(:s1), @dash), Label(@l1)))
)
end
if true
progress = Builtins.add(
progress,
Left(HBox(Heading(Id(:s2), @dash), Label(@l2)))
)
end
progress = Builtins.add(
progress,
Left(HBox(Heading(Id(:s2), @dash), Label(@l2)))
)
# do not shutdown the connection when already connected
if !@already_up
progress = Builtins.add(
Expand Down Expand Up @@ -361,9 +359,6 @@ def show_result
end

def copy_logs1
ret_command = nil
run_command = nil

# label of combobox where the log is selected
@logs = Builtins.add(
@logs,
Expand Down Expand Up @@ -425,9 +420,6 @@ def copy_logs1
end

def copy_logs2
ret_command = nil
run_command = nil

# label of combobox where the log is selected
@logs = Builtins.add(
@logs,
Expand All @@ -451,22 +443,22 @@ def copy_logs2
end

def wait_for_test
while Convert.to_boolean(SCR.Read(path(".background.output_open"))) ||
Convert.to_boolean(SCR.Read(path(".background.isrunning")))
while SCR.Read(path(".background.output_open")) ||
SCR.Read(path(".background.isrunning"))
Builtins.sleep(100)

ret = UI.PollInput

if ret == :abort || ret == :abort_test
# Abort pressed by the user
Builtins.y2milestone("Test aborted by user")
SCR.Execute(path(".background.kill"))
return -1
end
next unless [:abort, :abort_test].include?(ret)

# Abort pressed by the user
Builtins.y2milestone("Test aborted by user")
SCR.Execute(path(".background.kill"))
return -1
end

# check the exit code of the test
res = Convert.to_integer(SCR.Read(path(".background.status")))
res = SCR.Read(path(".background.status"))

Builtins.y2milestone("Command returned: %1", res)

Expand Down Expand Up @@ -536,14 +528,18 @@ def download_release_notes

if Ops.get_boolean(proxy_ret, ["HTTP", "tested"], true) == true &&
Ops.get_integer(proxy_ret, ["HTTP", "exit"], 1) == 0
user_pass = Proxy.user != "" ?
Ops.add(Ops.add(Proxy.user, ":"), Proxy.pass) :
""
user_pass = if Proxy.user != ""
Ops.add(Ops.add(Proxy.user, ":"), Proxy.pass)
else
""
end
proxy = Ops.add(
Ops.add("--proxy ", Proxy.http),
user_pass != "" ?
Ops.add(Ops.add(" --proxy-user '", user_pass), "'") :
if user_pass != ""
Ops.add(Ops.add(" --proxy-user '", user_pass), "'")
else
""
end
)
end
end
Expand Down
7 changes: 4 additions & 3 deletions src/clients/lan_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# Authors: Michal Svec <msvec@suse.cz>
#
module Yast
# Client providing autoyast functionality
class LanAutoClient < Client
def main
Yast.import "UI"
Expand Down Expand Up @@ -167,9 +168,9 @@ def main

result = Lan.WriteOnly
Builtins.y2error("Writing lan config failed") if !result
@ret = @ret && result
@ret &&= result

if Ops.get(LanItems.autoinstall_settings, "strict_IP_check_timeout") != nil
if Ops.get(LanItems.autoinstall_settings, "strict_IP_check_timeout")
if Lan.isAnyInterfaceDown
@timeout = Ops.get_integer(
LanItems.autoinstall_settings,
Expand Down Expand Up @@ -317,7 +318,7 @@ def FromAY(input)
dhcp = UpcaseCondSet(dhcp, dhcpopts, "dhclient_hostname_option")

Ops.set(input, "config", "dhcp" => dhcp)
if Ops.get(input, "strict_IP_check_timeout") != nil
if !Ops.get(input, "strict_IP_check_timeout").nil?
Ops.set(input, ["config", "config"], "CHECK_DUPLICATE_IP" => true)
end

Expand Down
3 changes: 1 addition & 2 deletions src/clients/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ def startDialog
end
end

def runHandler(options)
options = deep_copy(options)
def runHandler(_options)
true
end
end
Expand Down
4 changes: 1 addition & 3 deletions src/clients/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ def RemoteGUI

# Handler for action "list"
# @param [Hash{String => String}] options action options
def ListHandler(options)
options = deep_copy(options)
summary = ""
def ListHandler(_options)
# Command line output Headline
summary = Ops.add(
Ops.add(
Expand Down
13 changes: 5 additions & 8 deletions src/clients/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ def main
# Finish
Builtins.y2milestone("Routing module finished")
Builtins.y2milestone("----------------------------------------")
deep_copy(@ret)

# EOF
deep_copy(@ret)
end

# Return a modification status
Expand Down Expand Up @@ -219,8 +217,7 @@ def PrintableRoutingTable(items)
end
# Handler for action "list"
# @param [Hash{String => String}] options action options
def ListHandler(options)
options = deep_copy(options)
def ListHandler(_options)
CommandLine.Print(PrintableRoutingTable(Routing.Routes))
CommandLine.Print("")

Expand Down Expand Up @@ -258,19 +255,19 @@ def forwarding_handler(options, protocol)

return false unless forward_ivar

if Ops.get(options, "show") != nil
if !Ops.get(options, "show").nil?
if Routing.instance_variable_get(forward_ivar)
# translators: %s is "IPv4" or "IPv6"
CommandLine.Print(_("%s forwarding is enabled") % protocol)
else
# translators: %s is "IPv4" or "IPv6"
CommandLine.Print(_("%s forwarding is disabled") % protocol)
end
elsif Ops.get(options, "on") != nil
elsif !Ops.get(options, "on").nil?
# translators: %s is "IPv4" or "IPv6"
CommandLine.Print(_("Enabling %s forwarding...") % protocol)
Routing.instance_variable_set(forward_ivar, true)
elsif Ops.get(options, "off") != nil
elsif !Ops.get(options, "off").nil?
# translators: %s is "IPv4" or "IPv6"
CommandLine.Print(_("Disabling %s forwarding...") % protocol)
Routing.instance_variable_set(forward_ivar, false)
Expand Down
2 changes: 1 addition & 1 deletion src/clients/save_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def CopyConfiguredNetworkFiles
dest_file = copy_to + file
# apply options from initrd configuration files into installed system
# i.e. just modify (not replace) files from sysconfig rpm
# FIXME this must be ripped out, refactored and tested
# FIXME: this must be ripped out, refactored and tested
# In particular, values containing slashes will break the last sed
command = "\n" \
"source_file=#{source_file};dest_file=#{dest_file}\n" \
Expand Down
Loading

0 comments on commit 9633617

Please sign in to comment.