fastlane-plugin-clang_tools 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/clang_tools/actions/clang_analyzer_action.rb +81 -52
- data/lib/fastlane/plugin/clang_tools/helper/clang_tools_helper.rb +32 -0
- data/lib/fastlane/plugin/clang_tools/version.rb +1 -1
- metadata +33 -5
- data/lib/fastlane/plugin/clang_tools/helper/clang_analyzer_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eef3741c5bbfce072759ccf54c9318e43e01afc07211871c8527d7952e94495
|
4
|
+
data.tar.gz: 77643735adb58fcc6c6da0cf2ba9e66e3c66b23b23f035a76328726126b6565d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9bb793e4eacfd8e83dc59c6deb716937f950038f1bf39ea5d33f2f3be94230e6658e3e2d6ef6a7838c24641b17368eaffcab323b26838624ac084bf3729f9b9
|
7
|
+
data.tar.gz: 4437a709b9848134501ea9f7cd3b624fd7c3f55999b6cd7a8ec0e00236d076bf896e8564df83e56cc2da1041fe6c993e96d503334563b9b3bcc38f9e85b92518
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
|
3
3
|
require 'fastlane/action'
|
4
|
-
require_relative '../helper/
|
4
|
+
require_relative '../helper/clang_tools_helper'
|
5
5
|
|
6
6
|
module Fastlane
|
7
7
|
module Actions
|
8
8
|
class ClangAnalyzerAction < Action
|
9
9
|
def self.run(params)
|
10
10
|
# Parse CLI parameters
|
11
|
-
analyze_params = prepare(params)
|
11
|
+
analyze_params, err_msg = prepare(params)
|
12
12
|
if analyze_params.nil?
|
13
|
-
puts('ERROR : Invalid parameters. Exiting ......')
|
13
|
+
puts(Helper::ClangToolsHelper.is_empty?(err_msg) ? 'ERROR : Invalid parameters. Exiting ......' : err_msg)
|
14
14
|
return
|
15
15
|
end
|
16
16
|
|
@@ -35,27 +35,42 @@ module Fastlane
|
|
35
35
|
def self.prepare(params)
|
36
36
|
if params.nil?
|
37
37
|
analyze_params = nil
|
38
|
+
err_msg = 'ERROR : No input parameters. Exiting ......'
|
38
39
|
else
|
39
40
|
analyze_params = {}
|
41
|
+
err_msg = nil
|
40
42
|
|
41
43
|
params.all_keys.each do |item|
|
42
|
-
unless
|
44
|
+
unless Helper::ClangToolsHelper.is_empty?(params[item])
|
43
45
|
analyze_params[item] = params[item]
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
49
|
+
# Check if only the .xcworkspace specified or only the .xcodeproj specified
|
50
|
+
if analyze_params.key?(:workspace) && analyze_params.key?(:project)
|
51
|
+
return [nil, 'ERROR : ".xcworkspace" and ".xcodeproj" cannot be specified at the same time. Exiting ......']
|
52
|
+
end
|
53
|
+
if !analyze_params.key?(:workspace) && !analyze_params.key?(:project)
|
54
|
+
return [nil, 'ERROR : ".xcworkspace" or ".xcodeproj" must be specified. Exiting ......']
|
55
|
+
end
|
56
|
+
|
57
|
+
unless analyze_params.key?(:configuration)
|
58
|
+
analyze_params[:configuration] = 'Debug'
|
59
|
+
end
|
60
|
+
|
47
61
|
# The default output_format is 'plist-html'
|
48
62
|
unless analyze_params.key?(:output_format)
|
49
63
|
analyze_params[:output_format] = 'plist-html'
|
50
64
|
end
|
51
65
|
# For CI/CD convenience, this action only supports 'plist' or 'plist-html' as output_format
|
52
66
|
unless analyze_params[:output_format].include?('plist')
|
53
|
-
return nil
|
67
|
+
return [nil, 'ERROR : Invalid "output_format". Exiting ......']
|
54
68
|
end
|
55
69
|
|
56
70
|
# The default output_dir is './static_analysis'
|
71
|
+
project = Helper::ClangToolsHelper.pick_non_empty(params[:workspace], params[:project])
|
57
72
|
unless analyze_params.key?(:output_dir)
|
58
|
-
analyze_params[:output_dir] =
|
73
|
+
analyze_params[:output_dir] = "#{File.dirname(File.realpath(project))}/static_analysis"
|
59
74
|
end
|
60
75
|
FileUtils.mkdir_p(analyze_params[:output_dir]) unless File.exist?(analyze_params[:output_dir])
|
61
76
|
analyze_params[:output_compile_commands] = "#{analyze_params[:output_dir]}/compile_commands.json"
|
@@ -63,10 +78,10 @@ module Fastlane
|
|
63
78
|
analyze_params[:output_report_dir] = "#{analyze_params[:output_dir]}/report-#{Time.new.strftime('%Y%m%d%H%M%S')}"
|
64
79
|
FileUtils.mkdir_p(analyze_params[:output_report_dir]) unless File.exist?(analyze_params[:output_report_dir])
|
65
80
|
|
66
|
-
analyze_params[:output_summary_file] = '
|
81
|
+
analyze_params[:output_summary_file] = 'clang_analysis_report.xml'
|
67
82
|
end
|
68
83
|
|
69
|
-
analyze_params
|
84
|
+
[analyze_params, err_msg]
|
70
85
|
end
|
71
86
|
|
72
87
|
def self.xcode_build(params)
|
@@ -77,23 +92,21 @@ module Fastlane
|
|
77
92
|
# xcodebuild executive
|
78
93
|
cmd_line << (params.key?(:xcodebuild) ? params[:xcodebuild] : 'xcodebuild')
|
79
94
|
|
95
|
+
# -workspace
|
96
|
+
if params.key?(:workspace)
|
97
|
+
cmd_line << "-workspace #{params[:workspace]}"
|
80
98
|
# -project
|
81
|
-
|
99
|
+
elsif params.key?(:project)
|
82
100
|
cmd_line << "-project #{params[:project]}"
|
83
|
-
|
84
|
-
# -workspace
|
85
|
-
if params.key?(:workspace)
|
86
|
-
cmd_line << "-workspace #{params[:workspace]}"
|
87
|
-
end
|
101
|
+
end
|
88
102
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
103
|
+
# -scheme
|
104
|
+
if params.key?(:scheme)
|
105
|
+
cmd_line << "-scheme #{params[:scheme]}"
|
93
106
|
end
|
94
107
|
|
95
108
|
# xcode configuration
|
96
|
-
cmd_line <<
|
109
|
+
cmd_line << "-configuration #{params[:configuration]}"
|
97
110
|
|
98
111
|
# build command
|
99
112
|
cmd_line << 'clean'
|
@@ -148,29 +161,45 @@ module Fastlane
|
|
148
161
|
issues = []
|
149
162
|
plist_files.each { |plist_file| parse_plist("#{params[:output_report_dir]}/#{plist_file}", issues) }
|
150
163
|
|
151
|
-
|
164
|
+
grouped_issues = parse_issues(issues)
|
152
165
|
builder = Nokogiri::XML::Builder.new do |xml|
|
153
|
-
xml.
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
xml.Category(issue['category'])
|
159
|
-
xml.Type(issue['type'])
|
160
|
-
xml.Message(issue['message'])
|
161
|
-
xml.Source(issue['source_file'])
|
162
|
-
xml.Line(issue['line'])
|
163
|
-
xml.Col(issue['col'])
|
164
|
-
xml.Context(issue['context'])
|
165
|
-
xml.ContextKind(issue['context_kind'])
|
166
|
-
xml.HtmlAttachments do
|
167
|
-
issue['html_details'].each do |html|
|
168
|
-
xml.Attachment(html)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
166
|
+
xml.Report do
|
167
|
+
xml.Summary do
|
168
|
+
project = Helper::ClangToolsHelper.pick_non_empty(params[:workspace], params[:project])
|
169
|
+
if project.nil?
|
170
|
+
raise 'ERROR : Invalid Project!'
|
172
171
|
end
|
172
|
+
|
173
|
+
xml.Project(project)
|
174
|
+
xml.ReportDirectory(params[:output_report_dir])
|
175
|
+
xml.ReportFormat(params[:output_format])
|
176
|
+
xml.IssueCount(grouped_issues.size)
|
173
177
|
end
|
178
|
+
|
179
|
+
next if Helper::ClangToolsHelper.is_empty?(grouped_issues)
|
180
|
+
|
181
|
+
xml.IssueList do
|
182
|
+
grouped_issues.values.each do |issue_entry|
|
183
|
+
issue_entry.each do |issue|
|
184
|
+
xml.Issue do
|
185
|
+
xml.Checker(issue['checker'])
|
186
|
+
xml.Category(issue['category'])
|
187
|
+
xml.Type(issue['type'])
|
188
|
+
xml.Message(issue['message'])
|
189
|
+
xml.Source(issue['source_file'])
|
190
|
+
xml.Line(issue['line'])
|
191
|
+
xml.Col(issue['col'])
|
192
|
+
xml.Context(issue['context'])
|
193
|
+
xml.ContextKind(issue['context_kind'])
|
194
|
+
xml.HtmlAttachments do
|
195
|
+
issue['html_details'].each do |html|
|
196
|
+
xml.Attachment(html)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end # xml.Issue
|
200
|
+
end # issue_entry
|
201
|
+
end # grouped_issues.values
|
202
|
+
end # xml.IssueList
|
174
203
|
end
|
175
204
|
end
|
176
205
|
|
@@ -256,12 +285,12 @@ module Fastlane
|
|
256
285
|
# The corresponding source file of the plist file
|
257
286
|
# Noted : the length of 'files' will always be 1 now
|
258
287
|
plist_files = plist['files']
|
259
|
-
if
|
288
|
+
if Helper::ClangToolsHelper.is_empty?(plist_files)
|
260
289
|
return
|
261
290
|
end
|
262
291
|
|
263
292
|
plist_diagnostics = plist['diagnostics']
|
264
|
-
if
|
293
|
+
if Helper::ClangToolsHelper.is_empty?(plist_diagnostics)
|
265
294
|
return
|
266
295
|
end
|
267
296
|
|
@@ -284,22 +313,22 @@ module Fastlane
|
|
284
313
|
end
|
285
314
|
|
286
315
|
def self.parse_issues(issues)
|
287
|
-
|
316
|
+
grouped_issues = {}
|
288
317
|
|
289
|
-
if
|
290
|
-
return
|
318
|
+
if Helper::ClangToolsHelper.is_empty?(issues)
|
319
|
+
return grouped_issues
|
291
320
|
end
|
292
321
|
|
293
322
|
issues.each do |issue|
|
294
323
|
issue_key = issue['checker']
|
295
324
|
|
296
|
-
unless
|
297
|
-
|
325
|
+
unless grouped_issues.key?(issue_key)
|
326
|
+
grouped_issues[issue_key] = []
|
298
327
|
end
|
299
|
-
|
328
|
+
grouped_issues[issue_key] << issue
|
300
329
|
end
|
301
330
|
|
302
|
-
|
331
|
+
grouped_issues
|
303
332
|
end
|
304
333
|
|
305
334
|
def self.description
|
@@ -321,14 +350,14 @@ module Fastlane
|
|
321
350
|
|
322
351
|
def self.available_options
|
323
352
|
[
|
324
|
-
FastlaneCore::ConfigItem.new(key: :project,
|
325
|
-
description: 'The xcode project',
|
326
|
-
optional: true,
|
327
|
-
type: String),
|
328
353
|
FastlaneCore::ConfigItem.new(key: :workspace,
|
329
354
|
description: 'The xcode workspace',
|
330
355
|
optional: true,
|
331
356
|
type: String),
|
357
|
+
FastlaneCore::ConfigItem.new(key: :project,
|
358
|
+
description: 'The xcode project',
|
359
|
+
optional: true,
|
360
|
+
type: String),
|
332
361
|
FastlaneCore::ConfigItem.new(key: :scheme,
|
333
362
|
description: 'The scheme of xcode project',
|
334
363
|
optional: true,
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?('UI')
|
5
|
+
|
6
|
+
module Helper
|
7
|
+
class ClangToolsHelper
|
8
|
+
def self.is_empty?(obj)
|
9
|
+
if obj.nil?
|
10
|
+
return true
|
11
|
+
end
|
12
|
+
|
13
|
+
case obj
|
14
|
+
when String
|
15
|
+
obj.empty?
|
16
|
+
when Array, Hash
|
17
|
+
obj.size.zero?
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.pick_non_empty(str1, str2)
|
24
|
+
if !is_empty?(str1)
|
25
|
+
str1
|
26
|
+
elsif !is_empty?(str2)
|
27
|
+
str2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-clang_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- squirrel-explorer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec_junit_formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rubocop
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +142,14 @@ dependencies:
|
|
114
142
|
requirements:
|
115
143
|
- - ">="
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
145
|
+
version: 2.138.0
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.
|
152
|
+
version: 2.138.0
|
125
153
|
description:
|
126
154
|
email: xvider.zx@gmail.com
|
127
155
|
executables: []
|
@@ -132,7 +160,7 @@ files:
|
|
132
160
|
- README.md
|
133
161
|
- lib/fastlane/plugin/clang_tools.rb
|
134
162
|
- lib/fastlane/plugin/clang_tools/actions/clang_analyzer_action.rb
|
135
|
-
- lib/fastlane/plugin/clang_tools/helper/
|
163
|
+
- lib/fastlane/plugin/clang_tools/helper/clang_tools_helper.rb
|
136
164
|
- lib/fastlane/plugin/clang_tools/version.rb
|
137
165
|
homepage: https://github.com/squirrel-explorer/fastlane-plugin-clang_tools
|
138
166
|
licenses:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'fastlane_core/ui/ui'
|
2
|
-
|
3
|
-
module Fastlane
|
4
|
-
UI = FastlaneCore::UI unless Fastlane.const_defined?('UI')
|
5
|
-
|
6
|
-
module Helper
|
7
|
-
class ClangToolsHelper
|
8
|
-
# class methods that you define here become available in your action
|
9
|
-
# as `Helper::ClangToolsHelper.your_method`
|
10
|
-
#
|
11
|
-
def self.show_message
|
12
|
-
UI.message('Hello from the clang_tools plugin helper!')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|