Skip to content

Commit

Permalink
fix parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 14, 2015
1 parent 4a9a454 commit cbf452f
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 90 deletions.
11 changes: 0 additions & 11 deletions .rubocop.yml
Expand Up @@ -77,17 +77,6 @@ Style/DoubleNegation:
Style/FileName:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
Style/MethodCallParentheses:
Enabled: false

# Offense count: 71
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodDefParentheses:
Enabled: false

# Offense count: 1748
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodName:
Expand Down
18 changes: 9 additions & 9 deletions library/general/src/modules/Hooks.rb
Expand Up @@ -71,7 +71,7 @@ def initialize
@search_path = SearchPath.new
end

def run hook_name
def run(hook_name)
hook_name = hook_name.to_s
raise "Hook name not specified" if hook_name.empty?

Expand All @@ -80,21 +80,21 @@ def run hook_name
@last = hook
end

def find hook_name
def find(hook_name)
hooks[hook_name]
end

def all
hooks.values
end

def exists? hook_name
def exists?(hook_name)
!!find(hook_name)
end

private

def create hook_name, source_file
def create(hook_name, source_file)
if hooks[hook_name]
log.warn "Hook '#{hook_name}' has already been run from #{hooks[hook_name].caller_path}"
hooks[hook_name]
Expand All @@ -112,15 +112,15 @@ def initialize
set_default_path
end

def join! new_path
def join!(new_path)
@path = path.join(new_path)
end

def reset
set_default_path
end

def set new_path
def set(new_path)
@path = Pathname.new(new_path)
end

Expand Down Expand Up @@ -152,7 +152,7 @@ class Hook

attr_reader :name, :results, :files, :caller_path, :search_path

def initialize name, caller_path, search_path
def initialize(name, caller_path, search_path)
log.debug "Creating hook '#{name}' from '#{self.caller_path}'"
search_path.verify!
@search_path = search_path
Expand Down Expand Up @@ -184,7 +184,7 @@ def failed?

private

def find_hook_files hook_name
def find_hook_files(hook_name)
log.debug "Searching for hook files in '#{search_path}'..."
hook_files = search_path.children.select do |file|
file.basename.fnmatch?("#{hook_name}_[0-9][0-9]_*")
Expand All @@ -202,7 +202,7 @@ class HookFile

attr_reader :path, :content, :result

def initialize path
def initialize(path)
@path = path
end

Expand Down
2 changes: 1 addition & 1 deletion library/network/src/modules/SuSEFirewallServices.rb
Expand Up @@ -35,7 +35,7 @@

module Yast
class SuSEFirewalServiceNotFound < StandardError
def initialize message
def initialize(message)
super message
end
end
Expand Down
2 changes: 1 addition & 1 deletion library/packages/src/modules/SlideShow.rb
Expand Up @@ -646,7 +646,7 @@ def SetReleaseNotes(relnotes, base_product)
@_base_product = base_product
end

def add_relnotes_for_product product, relnotes, tabs
def add_relnotes_for_product(product, relnotes, tabs)
id = ProductRelNotesID product
# Translators: Tab name, keep short, %s is product name, e.g. SLES
tabs << Item(Id(id), _("%s Release Notes") % product)
Expand Down
12 changes: 6 additions & 6 deletions library/packages/test/slide_show_test.rb
Expand Up @@ -29,7 +29,7 @@
describe "when total progress widget is missing" do
it "does not update the total progress" do
expect(Yast::UI).to receive(:WidgetExists).with(TOTAL_PROGRESS_ID).and_return(false)
expect(Yast::UI).not_to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, anything(), anything())
expect(Yast::UI).not_to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, anything, anything)

Yast::SlideShow.UpdateGlobalProgress(1, "new label -1")
end
Expand Down Expand Up @@ -57,13 +57,13 @@

it "does not update progress label when setting it to nil" do
expect(Yast::UI).to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, :Value, 25)
expect(Yast::UI).not_to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, :Label, anything())
expect(Yast::UI).not_to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, :Label, anything)

Yast::SlideShow.UpdateGlobalProgress(25, nil)
end

it "does not update progress value when setting it to nil" do
expect(Yast::UI).not_to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, :Value, anything())
expect(Yast::UI).not_to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, :Value, anything)
expect(Yast::UI).to receive(:ChangeWidget).with(TOTAL_PROGRESS_ID, :Label, "new label 1")

Yast::SlideShow.UpdateGlobalProgress(nil, "new label 1")
Expand Down Expand Up @@ -93,7 +93,7 @@
describe "when total progress widget does not exists" do
it "does not update the total progress" do
expect(Yast::UI).to receive(:WidgetExists).with(PACKAGES_PROGRESS_ID).and_return(false)
expect(Yast::UI).not_to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, anything(), anything())
expect(Yast::UI).not_to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, anything, anything)

Yast::SlideShow.SubProgress(9, "some label")
end
Expand All @@ -113,13 +113,13 @@

it "does not update progress label when setting it to nil" do
expect(Yast::UI).to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, :Value, 13)
expect(Yast::UI).not_to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, :Label, anything())
expect(Yast::UI).not_to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, :Label, anything)

Yast::SlideShow.SubProgress(13, nil)
end

it "does not update progress value when setting it to nil" do
expect(Yast::UI).not_to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, :Value, anything())
expect(Yast::UI).not_to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, :Value, anything)
expect(Yast::UI).to receive(:ChangeWidget).with(PACKAGES_PROGRESS_ID, :Label, "package test 1")

Yast::SlideShow.SubProgress(nil, "package test 1")
Expand Down
50 changes: 25 additions & 25 deletions library/runlevel/src/modules/Service.rb
Expand Up @@ -55,7 +55,7 @@ def initialize
# If the command fails, log entry with output from systemctl is created in y2log
# @param [String,String] Command name and service name
# @return [Boolean] Result of the action, true means success
def call command_name, service_name
def call(command_name, service_name)
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service

Expand Down Expand Up @@ -84,7 +84,7 @@ def call command_name, service_name
#
# @param [String] name service name
# @return true if service is active
def Active service_name
def Active(service_name)
service = SystemdService.find(service_name)
!!(service && service.active?)
end
Expand All @@ -97,7 +97,7 @@ def Active service_name
#
# @param [String] name service name
# @return true if service is set to run in any runlevel
def Enabled name
def Enabled(name)
service = SystemdService.find(name)
!!(service && service.enabled?)
end
Expand All @@ -108,7 +108,7 @@ def Enabled name
# Logs error with output from systemctl if the command fails
# @param [String] service service to be enabled
# @return true if operation is successful
def Enable service_name
def Enable(service_name)
log.info "Enabling service '#{service_name}'"
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service
Expand All @@ -122,7 +122,7 @@ def Enable service_name
# Logs error with output from systemctl if the command fails
# @param [String] service service to be disabled
# @return true if operation is successful
def Disable service_name
def Disable(service_name)
log.info "Disabling service '#{service_name}'"
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service
Expand All @@ -136,7 +136,7 @@ def Disable service_name
# Logs error with output from systemctl if the command fails
# @param [String] service service to be started
# @return true if operation is successful
def Start service_name
def Start(service_name)
log.info "Starting service '#{service_name}'"
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service
Expand All @@ -150,7 +150,7 @@ def Start service_name
# Logs error with output from systemctl if the command fails
# @param [String] service service to be restarted
# @return true if operation is successful
def Restart service_name
def Restart(service_name)
log.info "Restarting service '#{service_name}'"
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service
Expand All @@ -164,7 +164,7 @@ def Restart service_name
# Logs error with output from systemctl if the command fails
# @param [String] service service to be reloaded
# @return true if operation is successful
def Reload service_name
def Reload(service_name)
log.info "Reloading service '#{service_name}'"
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service
Expand All @@ -178,7 +178,7 @@ def Reload service_name
# Logs error with output from systemctl if the command fails
# @param [String] service service to be stopped
# @return true if operation is successful
def Stop service_name
def Stop(service_name)
log.info "Stopping service '#{service_name}'"
service = SystemdService.find(service_name)
return failure(:not_found, service_name) unless service
Expand All @@ -203,7 +203,7 @@ def Error
# If not, set error_msg.
# @param [String] name service name without a path, eg. nfsserver
# @return Return true if the service exists.
def checkExists name
def checkExists(name)
deprecate("use `SystemdService.find` instead")

return failure(:not_found, name) unless SystemdService.find(name)
Expand All @@ -214,7 +214,7 @@ def checkExists name
# Get service info without peeking if service runs.
# @param [String] name name of the service
# @return Service information or empty map ($[])
def Info name
def Info(name)
deprecate("not supported by systemd")

unit = SystemdService.find(name)
Expand All @@ -235,7 +235,7 @@ def Info name
# Get complete systemd unit id
# @param name name or alias of the unit
# @return (resolved) unit Id
def GetUnitId unit
def GetUnitId(unit)
deprecate("use SystemdService.find('service_name').id")

unit = SystemdService.find(unit)
Expand All @@ -247,7 +247,7 @@ def GetUnitId unit
# Get the name from a systemd service unit id without the .service suffix
# @param [String] name name or alias of the service
# @return (resolved) service name without the .service suffix
def GetServiceId name
def GetServiceId(name)
deprecate("use SystemdService.find('service_name').name")

unit = SystemdService.find(name)
Expand All @@ -261,7 +261,7 @@ def GetServiceId name
# It should conform to LSB. 0 means the service is running.
# @param [String] name name of the service
# @return init script exit status or -1 if it does not exist
def Status name
def Status(name)
deprecate("use `active?` instead")

unit = SystemdService.find(name)
Expand All @@ -274,7 +274,7 @@ def Status name
# Get service info and find out whether service is running.
# @param [String] name name of the service
# @return service map or empty map ($[])
def FullInfo name
def FullInfo(name)
deprecate("not supported by systemd")

return {} if !checkExists(name)
Expand All @@ -288,7 +288,7 @@ def FullInfo name
# @param [String] name service name
# @param [Boolean] force pass "--force" (workaround for #17608, #27370)
# @return success state
def serviceDisable name, _force
def serviceDisable(name, _force)
deprecate("use `disable` instead")

unit = SystemdService.find(name)
Expand All @@ -303,7 +303,7 @@ def serviceDisable name, _force
# no links, set default, otherwise do nothing, "default" -- set
# defaults.
# @return [Boolean] success state
def Adjust name, action
def Adjust(name, action)
deprecate("use `enable` or `disable` instead")

service = SystemdService.find(name)
Expand All @@ -329,7 +329,7 @@ def Adjust name, action
# @param [String] name name of service to adjust
# @param [Array] rl list of runlevels in which service should start
# @return success state
def Finetune name, rl
def Finetune(name, rl)
deprecate("use `enable` or `disable` instead")

service = SystemdService.find(name)
Expand All @@ -348,7 +348,7 @@ def Finetune name, rl
# @param [String] name init service name
# @param [String] param init script argument
# @return [Fixnum] exit value
def RunInitScript name, param
def RunInitScript(name, param)
deprecate("use the specific unit command instead")

service = SystemdService.find(name)
Expand Down Expand Up @@ -380,7 +380,7 @@ def RunInitScript name, param
# @param [String] name init service name
# @param [String] param init script argument
# @return [Fixnum] exit value
def RunInitScriptWithTimeOut name, param
def RunInitScriptWithTimeOut(name, param)
deprecate("use `start` or `stop` instead")

service = SystemdService.find(name)
Expand All @@ -396,7 +396,7 @@ def RunInitScriptWithTimeOut name, param
# @param [String] name init service name
# @param [String] param init script argument
# @return A map of $[ "stdout" : "...", "stderr" : "...", "exit" : int]
def RunInitScriptOutput name, param
def RunInitScriptOutput(name, param)
deprecate("use `start` or `stop` instead")

service = SystemdService.find(name)
Expand All @@ -414,7 +414,7 @@ def RunInitScriptOutput name, param
# Get list of enabled services in a runlevel
# @param [Fixnum] runlevel requested runlevel number (0-6, -1 = Single)
# @return [Array<String>] enabled services
def EnabledServices _runlevel
def EnabledServices(_runlevel)
deprecate("use `SystemdService.all.select(&:enabled?)`")

SystemdService.all.select(&:enabled?).map(&:name)
Expand All @@ -425,15 +425,15 @@ def EnabledServices _runlevel
# (has init script) or "" if none is.
# @param list<string> list of service names
# @return [String] the first found service
def Find services
def Find(services)
deprecate("use `SystemdService.find` instead")

services.find {|service_name| SystemdService.find(service_name) }
end

private

def failure event, service_name, error=""
def failure(event, service_name, error="")
case event
when :not_found
error << "Service '#{service_name}' not found"
Expand All @@ -445,7 +445,7 @@ def failure event, service_name, error=""
return false
end

def deprecate message
def deprecate(message)
log.warn "[DEPRECATION] #{caller[0].split.last} in \"#{caller[1]}\" is deprecated; #{message}"
end

Expand Down
2 changes: 1 addition & 1 deletion library/runlevel/test/service_test.rb
Expand Up @@ -8,7 +8,7 @@ module Yast
describe Service do
include SystemdServiceStubs

def stub_service_with method, result
def stub_service_with(method, result)
allow_any_instance_of(SystemdServiceClass::Service).to receive(method)
.and_return(result)
end
Expand Down

0 comments on commit cbf452f

Please sign in to comment.