class Danger::DangerXcodeWarnings

Parse the xcodebuild log file and convert warnings. @example Parse and show xcodebuild warnings.

danger-xcode_warnings.analyze_file 'logfile'

@see Scior/danger-xcode_warnings

Attributes

show_build_timing_summary[RW]

Whether show build timing summary or not. The default value is `false`. @return [void]

show_build_warnings[RW]

Whether show build warnings or not. @return [void]

show_linker_warnings[RW]

Whether show linker warnings or not. The default value is `false`. @return [void]

use_xcpretty[RW]

Whether use xcpretty for formatting logs. The default value is `false`. @return [void]

Public Instance Methods

analyze(log_text, inline: true, sticky: true) click to toggle source

Parses the log text from xcodebuild and show warnings.

@param [String] log_text Raw build log text. @param [Boolean] inline Whether leave comments inline or not. @param [Boolean] sticky Whether use sticky flag or not. @return [void]

# File lib/xcode_warnings/plugin.rb, line 56
def analyze(log_text, inline: true, sticky: true)
  if use_xcpretty
    parser = LogParserXCPretty.new
  else
    parser = LogParser.new
    parser.show_build_timing_summary = show_build_timing_summary
  end
  parser.show_build_warnings = show_build_warnings
  parser.show_linker_warnings = show_linker_warnings

  parsed = parser.parse_warnings(log_text)
  parsed.each do |warning|
    if inline
      warn(warning[:message], sticky: sticky, file: warning[:file], line: warning[:line])
    else
      warn MessageFormatter.new.format(warning)
    end
  end
  message "Detected #{parsed.count} build-time warnings." unless parsed.empty?
  message parser.parse_build_timing_summary(log_text)
end
analyze_file(file_path, inline: false, sticky: true) click to toggle source

Parses the log file from xcodebuild and show warnings.

@param [String] file_path Path for the log file. @param [Boolean] inline Whether leave comments inline or not. @param [Boolean] sticky Whether use sticky flag or not. @return [void]

# File lib/xcode_warnings/plugin.rb, line 85
def analyze_file(file_path, inline: false, sticky: true)
  File.open(file_path) do |f|
    puts "Opened #{file_path}"
    analyze(f.read, inline: inline, sticky: sticky)
  end
rescue Errno::ENOENT, Errno::EACCES => e
  puts "Couldn't open the file: #{e}"
end