Skip to content

Commit

Permalink
update rubocop to 0.41.2 except one possible buggy part, that need ve…
Browse files Browse the repository at this point in the history
…rification
  • Loading branch information
jreidinger committed Jul 14, 2016
1 parent c805270 commit 75fdcf8
Show file tree
Hide file tree
Showing 53 changed files with 516 additions and 560 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Expand Up @@ -15,6 +15,10 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Max: 1916

# some includes are really long
Metrics/ModuleLength:
Max: 1500

# Offense count: 81
Metrics/CyclomaticComplexity:
Max: 50
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -5,7 +5,7 @@ before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-storage yast2-proxy yast2-country yast2-packager" -g "rspec:3.3.0 yast-rake gettext rubocop:0.29.1 simplecov:0.10.0 coveralls"
- sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-storage yast2-proxy yast2-country yast2-packager" -g "rspec:3.3.0 yast-rake gettext rubocop:0.41.2 simplecov:0.10.0 coveralls"
script:
- rubocop
- rake check:syntax
Expand Down
62 changes: 31 additions & 31 deletions src/clients/firewall_stage1_proposal.rb
Expand Up @@ -31,24 +31,24 @@
module Yast
# Configuration of fw in 1st stage
class FirewallStage1ProposalClient < Client
PROPOSAL_ID = "fw_1ststage"

LINK_ENABLE_FIREWALL = "firewall--enable_firewall_in_proposal"
LINK_DISABLE_FIREWALL = "firewall--disable_firewall_in_proposal"
LINK_OPEN_SSH_PORT = "firewall--enable_ssh_port_in_proposal"
LINK_BLOCK_SSH_PORT = "firewall--disable_ssh_port_in_proposal"
LINK_ENABLE_SSHD = "firewall--enable_sshd_in_proposal"
LINK_DISABLE_SSHD = "firewall--disable_sshd_in_proposal"
LINK_ENABLE_VNC = "firewall--enable_vnc_in_proposal"
LINK_DISABLE_VNC = "firewall--disable_vnc_in_proposal"
LINK_FIREWALL_DIALOG = "firewall_stage1"
PROPOSAL_ID = "fw_1ststage".freeze

LINK_ENABLE_FIREWALL = "firewall--enable_firewall_in_proposal".freeze
LINK_DISABLE_FIREWALL = "firewall--disable_firewall_in_proposal".freeze
LINK_OPEN_SSH_PORT = "firewall--enable_ssh_port_in_proposal".freeze
LINK_BLOCK_SSH_PORT = "firewall--disable_ssh_port_in_proposal".freeze
LINK_ENABLE_SSHD = "firewall--enable_sshd_in_proposal".freeze
LINK_DISABLE_SSHD = "firewall--disable_sshd_in_proposal".freeze
LINK_ENABLE_VNC = "firewall--enable_vnc_in_proposal".freeze
LINK_DISABLE_VNC = "firewall--disable_vnc_in_proposal".freeze
LINK_FIREWALL_DIALOG = "firewall_stage1".freeze

# Namespace for UI constants
module ID
SSH_PORT = "open_ssh_port"
VNC_PORT = "open_vnc_port"
ENABLE_FW = "enable_fw"
ENABLE_SSHD = "enable_sshd"
SSH_PORT = "open_ssh_port".freeze
VNC_PORT = "open_vnc_port".freeze
ENABLE_FW = "enable_fw".freeze
ENABLE_SSHD = "enable_sshd".freeze
end

include Yast::Logger
Expand Down Expand Up @@ -281,24 +281,24 @@ def FirewallDialogSimple

def preformatted_proposal
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
_(
"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

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
_(
"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
6 changes: 3 additions & 3 deletions src/clients/host_auto.rb
Expand Up @@ -101,10 +101,10 @@ def main
@ret2 = Builtins.maplist(@hosts) do |hostaddress, names|
{ "host_address" => hostaddress, "names" => names }
end
if Ops.greater_than(Builtins.size(@ret2), 0)
@ret = { "hosts" => @ret2 }
@ret = if Ops.greater_than(Builtins.size(@ret2), 0)
{ "hosts" => @ret2 }
else
@ret = {}
{}
end
# Read current state
elsif @func == "Read"
Expand Down
63 changes: 29 additions & 34 deletions src/clients/inst_do_net_test.rb
Expand Up @@ -529,10 +529,10 @@ 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 = if Proxy.user != ""
Ops.add(Ops.add(Proxy.user, ":"), Proxy.pass)
else
""
end
Ops.add(Ops.add(Proxy.user, ":"), Proxy.pass)
else
""
end
proxy = Ops.add(
Ops.add("--proxy ", Proxy.http),
if user_pass != ""
Expand Down Expand Up @@ -761,9 +761,7 @@ def handle_stage
return
end

if @already_up
@test_stage = :wait # not `copy. NM takes its time. #145153
else
if !@already_up
mark_label(1, :arrow)

if !AskForPassword()
Expand Down Expand Up @@ -795,9 +793,8 @@ def handle_stage
mark_label(1, :dash)
return
end

@test_stage = :wait
end
@test_stage = :wait # not `copy. NM takes its time. #145153
return
end

Expand Down Expand Up @@ -875,34 +872,32 @@ def handle_stage
)
)
ret = false
else
if !download_release_notes
# return code is not on the blacklist (meaning misconfigured network)
# return true if user wants to continue despite the failure, false otherwise
if !Builtins.contains(@curl_ret_codes_bad, @curl_ret_code)
# popup informing user about the failure to retrieve release notes
# most likely due to server-side error
ret = Popup.ContinueCancel(
_(
"Download of latest release notes failed due to server-side error. \n" \
"This does not necessarily imply a faulty network configuration.\n" \
"\n" \
"Click 'Continue' to proceed to the next installation step. To skip any steps\n" \
"requiring an internet connection or to get back to your network configuration,\n" \
"click 'Cancel'.\n"
)
elsif !download_release_notes
# return code is not on the blacklist (meaning misconfigured network)
# return true if user wants to continue despite the failure, false otherwise
if !Builtins.contains(@curl_ret_codes_bad, @curl_ret_code)
# popup informing user about the failure to retrieve release notes
# most likely due to server-side error
ret = Popup.ContinueCancel(
_(
"Download of latest release notes failed due to server-side error. \n" \
"This does not necessarily imply a faulty network configuration.\n" \
"\n" \
"Click 'Continue' to proceed to the next installation step. To skip any steps\n" \
"requiring an internet connection or to get back to your network configuration,\n" \
"click 'Cancel'.\n"
)
else
# popup to inform user about the failure
Report.Error(
_(
"Download of latest release notes failed. View\nthe logs for details."
)
)
else
# popup to inform user about the failure
Report.Error(
_(
"Download of latest release notes failed. View\nthe logs for details."
)
ret = false
end
@test_stage = :close
)
ret = false
end
@test_stage = :close
end
if ret
install_release_notes
Expand Down
6 changes: 3 additions & 3 deletions src/clients/inst_lan.rb
Expand Up @@ -56,10 +56,10 @@ def main

log.info("Configured network found: #{@@network_configured}")

if @@network_configured && !manual_conf_request
ret = GetInstArgs.going_back ? :back : :next
ret = if @@network_configured && !manual_conf_request
GetInstArgs.going_back ? :back : :next
else
ret = LanSequence()
LanSequence()
end

log.info("Lan module finished, ret = #{ret}")
Expand Down
8 changes: 4 additions & 4 deletions src/clients/lan_auto.rb
Expand Up @@ -178,10 +178,10 @@ def FromAY(input)
# uppercase map keys
newk = nil
interface = Builtins.mapmap(interface) do |k, v|
if k == "aliases"
newk = "_aliases"
newk = if k == "aliases"
"_aliases"
else
newk = Builtins.toupper(k)
Builtins.toupper(k)
end
{ newk => v }
end
Expand Down Expand Up @@ -375,7 +375,7 @@ def ToAY(settings)
if Ops.greater_than(
Builtins.size(Ops.get_map(settings, "routing", {})),
0
)
)
Ops.set(ret, "routing", Ops.get_map(settings, "routing", {}))
end
if Ops.greater_than(Builtins.size(interfaces), 0)
Expand Down
19 changes: 8 additions & 11 deletions src/clients/network.rb
Expand Up @@ -71,10 +71,10 @@ def main
}

# main ui function
if @propose
@ret = startDialog
@ret = if @propose
startDialog
else
@ret = CommandLine.Run(@cmdline_description)
CommandLine.Run(@cmdline_description)
end
Builtins.y2debug("ret=%1", @ret)

Expand Down Expand Up @@ -130,15 +130,16 @@ def startDialog
ret = UI.UserInput

# abort?
if ret == :abort || ret == :cancel
case ret
when :abort, :cancel
break
# next
elsif ret == :next || ret == :modules
when :next, :modules
# check_*
ret = :next
break
# back
elsif ret == :back
when :back
break
else
Builtins.y2error("unexpected retcode: %1", ret)
Expand All @@ -158,11 +159,7 @@ def startDialog
Builtins.y2milestone("Network module finished")
Builtins.y2milestone("----------------------------------------")

if ret == :next
return WFM.CallFunction(launch, WFM.Args)
else
return :back
end
ret == :next ? WFM.CallFunction(launch, WFM.Args) : :back
end

def runHandler(_options)
Expand Down
9 changes: 4 additions & 5 deletions src/clients/routing.rb
Expand Up @@ -215,6 +215,7 @@ def PrintableRoutingTable(items)

Ops.add(Ops.add(headline, "\n"), table)
end

# Handler for action "list"
# @param [Hash{String => String}] options action options
def ListHandler(_options)
Expand Down Expand Up @@ -402,11 +403,9 @@ def DeleteHandler(options)
options = deep_copy(options)
found = false
Routing.Routes = Builtins.maplist(Routing.Routes) do |m|
if Ops.get(m, "destination") == Ops.get(options, "dest")
found = true
else
next deep_copy(m)
end
next deep_copy(m) if Ops.get(m, "destination") == Ops.get(options, "dest")

found = true
end

if found
Expand Down
4 changes: 2 additions & 2 deletions src/clients/save_network.rb
Expand Up @@ -80,8 +80,8 @@ def adjust_for_network_disks(file)
)
end

ETC = "/etc/"
SYSCONFIG = "/etc/sysconfig/network/"
ETC = "/etc/".freeze
SYSCONFIG = "/etc/sysconfig/network/".freeze

def CopyConfiguredNetworkFiles
return if Mode.autoinst && !NetworkAutoYast.instance.keep_net_config?
Expand Down

0 comments on commit 75fdcf8

Please sign in to comment.