From 5615c895ec3cb7adde750296fa285da16c20cf19 Mon Sep 17 00:00:00 2001 From: Evan Anger Date: Wed, 8 Mar 2023 14:22:15 -0500 Subject: [PATCH 1/4] Slight correction on lint path --- lib/danger_plugin.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/danger_plugin.rb b/lib/danger_plugin.rb index 4b62a3f..a07d11e 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,12 @@ 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 = file_name.sub('.', '') + end message = "#{r['reason']}".dup # extended content here @@ -307,7 +314,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 From 3b2391a767f2feb2890052d3bf6219910f767aaf Mon Sep 17 00:00:00 2001 From: Evan Anger Date: Fri, 10 Mar 2023 17:54:09 -0500 Subject: [PATCH 2/4] Update danger_plugin.rb --- lib/danger_plugin.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/danger_plugin.rb b/lib/danger_plugin.rb index a07d11e..4f478e6 100755 --- a/lib/danger_plugin.rb +++ b/lib/danger_plugin.rb @@ -303,9 +303,9 @@ def send_inline_comment(results, method) raw_file_name = r['file'].gsub(dir, '') file_name = raw_file_name - if file_path_style == 'root' - file_name = file_name.sub('.', '') - end + #if file_path_style == 'root' + # file_name = file_name.sub('.', '') + #end message = "#{r['reason']}".dup # extended content here From 800d3637d695ea4d30e37f0c2c20ffea964853e7 Mon Sep 17 00:00:00 2001 From: Evan Anger Date: Fri, 10 Mar 2023 18:01:32 -0500 Subject: [PATCH 3/4] Update danger_plugin.rb --- lib/danger_plugin.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/danger_plugin.rb b/lib/danger_plugin.rb index 4f478e6..9900747 100755 --- a/lib/danger_plugin.rb +++ b/lib/danger_plugin.rb @@ -303,9 +303,10 @@ def send_inline_comment(results, method) raw_file_name = r['file'].gsub(dir, '') file_name = raw_file_name - #if file_path_style == 'root' - # file_name = file_name.sub('.', '') - #end + if file_path_style == 'root' && file_name.first != '/' + file_name = '/' + file_name + end + message = "#{r['reason']}".dup # extended content here From a0d3b74125d446cbf182285380e5648dfedc97e8 Mon Sep 17 00:00:00 2001 From: Evan Anger Date: Fri, 10 Mar 2023 18:06:33 -0500 Subject: [PATCH 4/4] Update danger_plugin.rb --- lib/danger_plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/danger_plugin.rb b/lib/danger_plugin.rb index 9900747..9d4af9a 100755 --- a/lib/danger_plugin.rb +++ b/lib/danger_plugin.rb @@ -303,7 +303,7 @@ def send_inline_comment(results, method) raw_file_name = r['file'].gsub(dir, '') file_name = raw_file_name - if file_path_style == 'root' && file_name.first != '/' + if file_path_style == 'root' && file_name[0] != '/' file_name = '/' + file_name end