Class: Danger::DangerXcodeSummary
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerXcodeSummary
- Defined in:
- lib/xcode_summary/plugin.rb
Overview
Shows all build errors, warnings and unit tests results generated from xcodebuild. You need to use the xcresult produced by Xcode 11. It’s located in the Derived Data folder.
Defined Under Namespace
Classes: Location, Result, Warning
Instance Attribute Summary collapse
-
#collapse_parallelized_tests ⇒ Boolean
Defines if parallelized test runs from the same target should be collapsed into one message.
-
#ignored_files ⇒ [String]
A globbed string or array of strings which should match the files that you want to ignore warnings on.
-
#ignored_results(&block) ⇒ Block
A block that filters specific results.
-
#ignores_warnings ⇒ Boolean
Defines if warnings should be included or not Defaults to
false. -
#inline_mode ⇒ Boolean
Defines if using inline comment or not.
-
#project_root ⇒ Object
rubocop:disable Lint/DuplicateMethods.
-
#sort_warnings_by(&block) ⇒ Block
A block that sorts the warning results.
-
#sticky_summary ⇒ Boolean
Defines if the test summary will be sticky or not.
-
#strict ⇒ Boolean
Defines errors strict.
-
#test_summary ⇒ Boolean
Defines if the build summary is shown or not.
Instance Method Summary collapse
-
#plugin ⇒ void
Pick a Dangerfile plugin for a chosen request_source and cache it based on github.com/danger/danger/blob/master/lib/danger/plugin_support/plugin.rb#L31.
-
#report(file_path) ⇒ void
Reads a
.xcresultand reports it. -
#warning_error_count(file_path) ⇒ String
Reads a
.xcresultand reports its warning and error count.
Instance Attribute Details
#collapse_parallelized_tests ⇒ Boolean
Defines if parallelized test runs from the same target should be collapsed into one message. Defaults to false
89 90 91 |
# File 'lib/xcode_summary/plugin.rb', line 89 def collapse_parallelized_tests @collapse_parallelized_tests end |
#ignored_files ⇒ [String]
A globbed string or array of strings which should match the files that you want to ignore warnings on. Defaults to nil. An example would be ‘’/Pods/‘` to ignore warnings in Pods that your project uses.
38 39 40 |
# File 'lib/xcode_summary/plugin.rb', line 38 def ignored_files @ignored_files end |
#ignored_results(&block) ⇒ Block
A block that filters specific results. An example would be ‘lambda { |result| result.message.start_with?(’ld’) }‘ to ignore results for ld_warnings.
45 46 47 |
# File 'lib/xcode_summary/plugin.rb', line 45 def ignored_results @ignored_results end |
#ignores_warnings ⇒ Boolean
Defines if warnings should be included or not Defaults to false.
77 78 79 |
# File 'lib/xcode_summary/plugin.rb', line 77 def ignores_warnings @ignores_warnings end |
#inline_mode ⇒ Boolean
Defines if using inline comment or not. Defaults to false.
71 72 73 |
# File 'lib/xcode_summary/plugin.rb', line 71 def inline_mode @inline_mode end |
#project_root ⇒ Object
rubocop:disable Lint/DuplicateMethods
30 31 32 |
# File 'lib/xcode_summary/plugin.rb', line 30 def project_root @project_root end |
#sort_warnings_by(&block) ⇒ Block
A block that sorts the warning results. An example would be ‘lambda { |warning| warning.message.include?(“deprecated”) ? 1 : 0 }` to sort results for deprecated warnings.
65 66 67 |
# File 'lib/xcode_summary/plugin.rb', line 65 def sort_warnings_by @sort_warnings_by end |
#sticky_summary ⇒ Boolean
Defines if the test summary will be sticky or not. Defaults to false.
51 52 53 |
# File 'lib/xcode_summary/plugin.rb', line 51 def sticky_summary @sticky_summary end |
#strict ⇒ Boolean
Defines errors strict. If value is false, then errors will be reporting as warnings. Defaults to true
83 84 85 |
# File 'lib/xcode_summary/plugin.rb', line 83 def strict @strict end |
#test_summary ⇒ Boolean
Defines if the build summary is shown or not. Defaults to true.
57 58 59 |
# File 'lib/xcode_summary/plugin.rb', line 57 def test_summary @test_summary end |
Instance Method Details
#plugin ⇒ void
This method returns an undefined value.
Pick a Dangerfile plugin for a chosen request_source and cache it based on github.com/danger/danger/blob/master/lib/danger/plugin_support/plugin.rb#L31
138 139 140 141 |
# File 'lib/xcode_summary/plugin.rb', line 138 def plugin plugins = Plugin.all_plugins.select { |plugin| Dangerfile.essential_plugin_classes.include? plugin } @plugin ||= plugins.select { |p| p.method_defined? :html_link }.map { |p| p.new(@dangerfile) }.compact.first end |
#report(file_path) ⇒ void
This method returns an undefined value.
Reads a .xcresult and reports it.
148 149 150 151 152 153 154 155 |
# File 'lib/xcode_summary/plugin.rb', line 148 def report(file_path) if File.exist?(file_path) xcode_summary = XCResult::Parser.new(path: file_path) format_summary(xcode_summary) else fail 'summary file not found' end end |
#warning_error_count(file_path) ⇒ String
Reads a .xcresult and reports its warning and error count.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/xcode_summary/plugin.rb', line 161 def warning_error_count(file_path) if File.exist?(file_path) xcode_summary = XCResult::Parser.new(path: file_path) warning_count = 0 error_count = 0 xcode_summary.actions_invocation_record.actions.each do |action| warning_count += warnings(action).count error_count += errors(action).count end result = { warnings: warning_count, errors: error_count } result.to_json else fail 'summary file not found' end end |