Class: Fastlane::Actions::WarningAnalyzerAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::WarningAnalyzerAction
- Defined in:
- lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
138 139 140 141 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 138 def self. # So no one will ever forget your contribution to fastlane :) You are awesome btw! ["olgakn"] end |
.available_options ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 97 def self. # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :result_dir, env_name: "FL_WARNING_ANALYZER_RESULT_DIR", description: "Directory's name for storing analysis results", optional: true, type: String, default_value: 'artifacts'), FastlaneCore::ConfigItem.new(key: :xcode_project_name, env_name: "FL_WARNING_ANALYZER_PROJECT_NAME", description: "Xcode project name in work directory", optional: false, type: String, verify_block: proc do |value| UI.user_error!("No project name for WarningAnalyzerAction given, pass using `xcode_project_name` parameter") unless value and !value.empty? end), FastlaneCore::ConfigItem.new(key: :xcode_workspace_name, env_name: "FL_WARNING_ANALYZER_WORKSPACE_NAME", description: "Xcode workspace name in work directory. Set it if you use different project & workspace names", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :xcode_targets, env_name: "FL_WARNING_ANALYZER_TARGETS", description: "List of Xcode targets to inspect. By default used all project targets", optional: true, type: Array) ] end |
.description ⇒ Object
87 88 89 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 87 def self.description "This analyzer detect warnings in Xcode projects." end |
.details ⇒ Object
91 92 93 94 95 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 91 def self.details # Optional: # this is your chance to provide a more detailed description of this action # "You can use this action to do cool things..." end |
.is_supported?(platform) ⇒ Boolean
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 143 def self.is_supported?(platform) # you can do things like # # true # # platform == :ios # # [:ios, :mac].include?(platform) # [:ios, :mac].include?(platform) end |
.output ⇒ Object
127 128 129 130 131 132 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 127 def self.output # Define the shared values you are going to provide [ ['WARNING_ANALYZER_STATUS', 'Warning analyzer result status (0 - success, any other value - failed)'] ] end |
.return_value ⇒ Object
134 135 136 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 134 def self.return_value # If you method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fastlane/plugin/code_static_analyzer/actions/warning_analyzer.rb', line 8 def self.run(params) UI.header 'iOS warning analyzer' if Actions::CodeStaticAnalyzerAction.run_from_main_action work_dir = Actions::CodeStaticAnalyzerAction.work_dir # checking files for analysing workspace = params[:xcode_workspace_name] project = params[:xcode_project_name] targets = params[:xcode_targets] unless Actions::CodeStaticAnalyzerAction.run_from_main_action checked_params = Actions::CodeStaticAnalyzerAction.xcode_check_parameters(work_dir, project, workspace, targets) project = checked_params[0] workspace = checked_params[1] targets = checked_params[2] end is_workspace = false is_workspace = true if workspace and !workspace.empty? # prepare script and metadata for saving results result_dir_path = "#{work_dir}#{params[:result_dir]}" FileUtils.mkdir_p(result_dir_path) unless File.exist?(result_dir_path) # lib_path = File.join(Helper.gem_path('fastlane-plugin-code_static_analyzer'), "lib") # File.join(lib_path, "assets/code_analys.sh") run_script_path = File.join CodeStaticAnalyzer::ROOT, "assets/code_analys.sh" status_static_arr = [] xml_content = '' temp_result_file = "#{result_dir_path}/temp_warnings.log" result_file = "#{result_dir_path}/codeAnalysResults_warning.xml" # use analyzer and collect results project_workspace = project project_workspace = workspace if is_workspace Actions::CodeStaticAnalyzerAction.start_xml_content unless Actions::CodeStaticAnalyzerAction.run_from_main_action targets.each do |target| Formatter.xcode_format(target) run_script = "#{run_script_path} #{project_workspace} #{target} '#{temp_result_file}' #{is_workspace}" FastlaneCore::CommandExecutor.execute(command: run_script.to_s, print_all: false, print_command: false, error: proc do |error_output| # handle error here end) Actions::CodeStaticAnalyzerAction.start_xml_content unless Actions::CodeStaticAnalyzerAction.run_from_main_action if Dir.glob(temp_result_file).empty? Actions::CodeStaticAnalyzerAction.add_xml_content("#{result_dir_path}/", 'iOS Warning', temp_result_file, '') Actions::CodeStaticAnalyzerAction.create_analyzers_run_result("#{result_dir_path}/") unless Actions::CodeStaticAnalyzerAction.run_from_main_action status_static_arr.push(1) else file = File.read(temp_result_file) UI.important "wrong profiles. Code isn't checked" if file =~ /BCEROR/ is_warnings = file =~ /warning:|error:|BCEROR/ if is_warnings status_static_arr.push(1) else status_static_arr.push(0) end xml_content += JunitParser.parse_xcode_log(temp_result_file, target, is_warnings) end end # prepare results unless Dir.glob(temp_result_file).empty? junit_xml = JunitParser.add_testsuite('xcode warnings', xml_content) JunitParser.create_junit_xml(junit_xml, result_file) end status = if status_static_arr.any? { |x| x > 0 } 1 else 0 end Actions.lane_context[SharedValues::WARNING_ANALYZER_STATUS] = status end |