Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubocop / Improve code style #34

Merged
merged 1 commit into from
Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/u3d/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def list_installed(options: {})
return
end
# version -> installations
arraym = list.map{|a| [a.version, a]}
arraym = list.map { |a| [a.version, a] }
map = Hash[*arraym.flatten]
# sorted versions
vcomparators = map.keys.map { |k| UnityVersionComparator.new(k) }
Expand Down Expand Up @@ -218,7 +218,7 @@ def credentials_actions
%w(add remove check)
end

def credentials(args: [], options: {})
def credentials(args: [], _options: {})
action = args[0]
raise "Please specify an action to perform, one of #{credentials_actions.join(',')}" unless action
raise "Unknown action '#{action}'. Use one of #{credentials_actions.join(',')}" unless credentials_actions.include? action
Expand Down
2 changes: 1 addition & 1 deletion lib/u3d/unity_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run(installation, args, raw_logs: false)
end

# Wait for tail_thread setup to be complete
sleep 0.5 while tail_thread.status!='sleep'
sleep 0.5 while tail_thread.status != 'sleep'
tail_thread.run

begin
Expand Down
2 changes: 1 addition & 1 deletion lib/u3d/unity_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def list_available
if response.kind_of? Net::HTTPSuccess
capt = response.body.match(LINUX_DOWNLOAD_RECENT_FILE)
if capt && capt[1] && capt[2]
versions[capt[2].gsub(/x/, '')] = capt[1]
versions[capt[2].delete('x')] = capt[1]
else
UI.error("Could not retrieve a fitting file from #{url}")
end
Expand Down
3 changes: 2 additions & 1 deletion lib/u3d_core/command_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def has_admin_privileges?
credentials = U3dCore::Credentials.new(user: ENV['USER'])
begin
result = system("sudo -k && echo #{credentials.password.shellescape} | sudo -S /usr/bin/whoami",
out: File::NULL, err: File::NULL)
out: File::NULL,
err: File::NULL)
rescue
result = false
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ def with_env_values(hash)
ENV.delete(k) unless old_vals.include?(k)
ENV[k] = old_vals[k]
end
end
end
8 changes: 6 additions & 2 deletions spec/u3d/log_analyzer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ class CustomExpectations
def phase_active(phases)
expect(phases).to have_key('TEST_ACTIVE')
end

def phase_not_active(phases)
expect(phases).not_to have_key('TEST_NOT_ACTIVE')
end

def silent_phase_use(phases)
expect(phases).to have_key('TEST')
end

def silent_phase_rules(phases)
expect(phases['TEST']['rules']).to be_empty
end

def phase_start_pattern_parsing(phases)
expect(phases['TEST']['phase_start_pattern']).to eql(/This is a pattern/)
end
Expand All @@ -48,7 +52,7 @@ def phase_start_pattern_parsing(phases)
describe U3d do
describe U3d::LogAnalyzer do
describe '.load_rules custom' do
data = JSON.parse(File.read(rules_data_file))
data = JSON.parse(File.read(rules_data_file))
data.each do |key, test_cases|
it test_cases['message'] do
file = double('file')
Expand All @@ -63,7 +67,7 @@ def phase_start_pattern_parsing(phases)
it "loads defaults rules without problem" do
gen, phases = U3d::LogAnalyzer.new.load_rules
expect(gen.keys.count).to be > 5
expect(phases.keys).to eq ['JENKINS','INIT','COMPILER','ASSET']
expect(phases.keys).to eq %w(JENKINS INIT COMPILER ASSET)
end

it "parses a simple file" do
Expand Down