Class: Danger::DangerXcodeWarnings

Inherits:
Plugin
  • Object
show all
Defined in:
lib/xcode_warnings/plugin.rb

Overview

Parse the xcodebuild log file and convert warnings.

Examples:

Parse and show xcodebuild warnings.


danger-xcode_warnings.analyze_file 'logfile'

See Also:

  • Scior/danger-xcode_warnings

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#show_build_timing_summaryvoid

This method returns an undefined value.

Whether show build timing summary or not.



23
24
25
# File 'lib/xcode_warnings/plugin.rb', line 23

def show_build_timing_summary
  @show_build_timing_summary
end

#show_build_warningsObject

rubocop:disable Lint/DuplicateMethods



15
16
17
# File 'lib/xcode_warnings/plugin.rb', line 15

def show_build_warnings
  @show_build_warnings
end

#show_linker_warningsvoid

This method returns an undefined value.

Whether show linker warnings or not.



19
20
21
# File 'lib/xcode_warnings/plugin.rb', line 19

def show_linker_warnings
  @show_linker_warnings
end

Instance Method Details

#analyze(log_text, inline: false, sticky: true) ⇒ void

This method returns an undefined value.

Parses the log text from xcodebuild and show warnings.

Parameters:

  • log_text (String)

    Raw build log text.

  • inline (Boolean) (defaults to: false)

    Whether leave comments inline or not.

  • sticky (Boolean) (defaults to: true)

    Whether use sticky flag or not.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/xcode_warnings/plugin.rb', line 46

def analyze(log_text, inline: false, sticky: true)
  parser = LogParser.new
  parser.show_build_warnings = show_build_warnings
  parser.show_linker_warnings = show_linker_warnings
  parser.show_build_timing_summary = show_build_timing_summary

  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) ⇒ void

This method returns an undefined value.

Parses the log file from xcodebuild and show warnings.

Parameters:

  • file_path (String)

    Path for the log file.

  • inline (Boolean) (defaults to: false)

    Whether leave comments inline or not.

  • sticky (Boolean) (defaults to: true)

    Whether use sticky flag or not.



71
72
73
74
75
76
77
78
# File 'lib/xcode_warnings/plugin.rb', line 71

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