Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/danger_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down