forked from square/spacecommander
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint.rb
More file actions
executable file
·59 lines (46 loc) · 1.88 KB
/
lint.rb
File metadata and controls
executable file
·59 lines (46 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env ruby
def check_oclint
workspace = ARGV[0]
scheme = ARGV[1]
changed_files_args = ARGV.drop(2)
changed_file_string = changed_files_args.join("\n")
puts "\n###############################################\n"
puts "\n#### OCLint ####\n"
puts "\n###############################################\n"
puts "\nChecking:\n"
puts "\n#{changed_file_string}\n"
changed_files = changed_file_string.split("\n")
file_filter_arguments = []
changed_files.each do |changed_file_string|
file_filter_arguments.push(changed_file_string)
end
if (!file_filter_arguments.empty?)
compilation_db_file_filter_argument = file_filter_arguments.join(" ")
oclint_analyze(workspace, scheme, compilation_db_file_filter_argument)
end
puts "\n#### Done ####\n"
end
def oclint_analyze(workspace, scheme, file_filter_argument)
puts "\nRunning OCLint Analysis. This may take a while...\n"
system_raise_failure("export LC_ALL=en_US.UTF-8 && xcodebuild CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO" +
" -workspace \"#{workspace}\" -scheme \"#{scheme}\" -configuration 'Debug' -sdk iphoneos clean build" +
" | xcpretty -t --report json-compilation-database --output compile_commands.json")
system_raise_failure("oclint -list-enabled-rules -report-type=text #{file_filter_argument}")
end
def check_space_commander
puts "\n###############################################\n"
puts "\n#### SpaceCommander ####\n"
puts "\n###############################################\n"
system_raise_failure("set -e && ./Pods/SpaceCommander/format-objc-mobuild #{ENV['MASTER_COMMIT_HASH']}")
end
def system_raise_failure(command)
system("set -o pipefail && #{command}")
exit_status = "#{$?.exitstatus}"
if (exit_status != "0")
exit(exit_status.to_i)
end
end
if (!(ENV['SKIP_SPACECOMMANDER'] == "YES"))
check_space_commander
end
check_oclint