diff --git a/lib/danger_plugin.rb b/lib/danger_plugin.rb index 4b62a3f..9d4af9a 100755 --- a/lib/danger_plugin.rb +++ b/lib/danger_plugin.rb @@ -53,6 +53,8 @@ class DangerSwiftlint < Plugin # Whether all issues or ones in PR Diff to be reported attr_accessor :filter_issues_in_diff + attr_accessor :file_path_style + # Lints Swift files. Will fail if `swiftlint` cannot be installed correctly. # Generates a `markdown` list of warnings for the prose in a corpus of # .markdown and .md files. @@ -298,7 +300,13 @@ def markdown_issues(results, heading) def send_inline_comment(results, method) dir = "#{Dir.pwd}/" results.each do |r| - github_filename = r['file'].gsub(dir, '') + + raw_file_name = r['file'].gsub(dir, '') + file_name = raw_file_name + if file_path_style == 'root' && file_name[0] != '/' + file_name = '/' + file_name + end + message = "#{r['reason']}".dup # extended content here @@ -307,7 +315,7 @@ def send_inline_comment(results, method) message << "`#{r['rule_id']}`" # helps writing exceptions // swiftlint:disable:this rule_id message << " `#{filename}:#{r['line']}`" # file:line for pasting into Xcode Quick Open - send(method, message, file: github_filename, line: r['line']) + send(method, message, file: file_name, line: r['line']) end end