Skip to content

Commit 3a4eab2

Browse files
committed
Fix lint errors
1 parent 9b7c34d commit 3a4eab2

2 files changed

Lines changed: 30 additions & 20 deletions

File tree

lib/xcode/install.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -465,24 +465,24 @@ def prereleases
465465
end
466466

467467
def compare_versions(first, second)
468-
# Sort by version number
469-
numeric_comparation = first.to_f <=> second.to_f
470-
return numeric_comparation if numeric_comparation != 0
471-
472-
# Return beta versions before others
473-
is_first_beta = first.include?('beta')
474-
is_second_beta = second.include?('beta')
475-
return -1 if is_first_beta && !is_second_beta
476-
return 1 if !is_first_beta && is_second_beta
477-
478-
# Return GM versions before others
479-
is_first_gm = first.include?('GM')
480-
is_second_gm = second.include?('GM')
481-
return -1 if is_first_gm && !is_second_gm
482-
return 1 if !is_first_gm && is_second_gm
483-
484-
# Sort alphabetically
485-
return first <=> second
468+
# Sort by version number
469+
numeric_comparation = first.to_f <=> second.to_f
470+
return numeric_comparation if numeric_comparation != 0
471+
472+
# Return beta versions before others
473+
is_first_beta = first.include?('beta')
474+
is_second_beta = second.include?('beta')
475+
return -1 if is_first_beta && !is_second_beta
476+
return 1 if !is_first_beta && is_second_beta
477+
478+
# Return GM versions before others
479+
is_first_gm = first.include?('GM')
480+
is_second_gm = second.include?('GM')
481+
return -1 if is_first_gm && !is_second_gm
482+
return 1 if !is_first_gm && is_second_gm
483+
484+
# Sort alphabetically
485+
first <=> second
486486
end
487487

488488
def hdiutil(*args)

spec/list_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,19 @@ def fake_installed_xcodes(*names)
4747
end
4848

4949
it 'lists all versions in the correct order' do
50-
fake_xcodes '12 beta 4', '12 beta 3', '12 beta 2', '12 for macOS Universal Apps beta 2', '12 beta', '12 for macOS Universal Apps beta', '12.0.1', '12', '12 beta 6', '12 beta 5', '12.1 GM seed', '12.2 beta 3', '12.2 beta', '12.2 beta 2'
50+
fake_xcodes(
51+
'12 beta 4', '12 beta 3', '12 beta 2', '12 for macOS Universal Apps beta 2',
52+
'12 beta', '12 for macOS Universal Apps beta', '12.0.1', '12', '12 beta 6',
53+
'12 beta 5', '12.1 GM seed', '12.2 beta 3', '12.2 beta', '12.2 beta 2'
54+
)
5155
fake_installed_xcodes
52-
installer.list.should == "12 beta\n12 beta 2\n12 beta 3\n12 beta 4\n12 beta 5\n12 beta 6\n12 for macOS Universal Apps beta\n12 for macOS Universal Apps beta 2\n12\n12.0.1\n12.1 GM seed\n12.2 beta\n12.2 beta 2\n12.2 beta 3"
56+
57+
versions = [
58+
'12 beta', '12 beta 2', '12 beta 3', '12 beta 4', '12 beta 5', '12 beta 6',
59+
'12 for macOS Universal Apps beta', '12 for macOS Universal Apps beta 2',
60+
'12', '12.0.1', '12.1 GM seed', '12.2 beta', '12.2 beta 2', '12.2 beta 3'
61+
]
62+
installer.list.split("\n").should == versions
5363
end
5464
end
5565

0 commit comments

Comments
 (0)