private Uri ResolveFileLinkForFragment(DuplicateFragment fragment) { if (this.Settings?.FileLinkSettings == null) { return(null); } var issue = IssueBuilder .NewIssue(fragment.FilePath, fragment.FilePath, this) .InFile(fragment.FilePath, fragment.LineStart, fragment.LineEnd, null, null) .Create(); var resolvedPattern = this.Settings.FileLinkSettings.GetFileLink(issue); return(resolvedPattern); }
private string GetHtmlMessage(int cost, IReadOnlyCollection <DuplicateFragment> fragments, DuplicateFragment fragment) { var builder = new StringBuilder(); builder.Append($"Possible duplicate detected (cost {cost})."); builder.Append("<br/>The following fragments were found that might be duplicates:"); foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment))) { builder.Append("<br/>"); var link = this.ResolveFileLinkForFragment(possibleDuplicateFragment); builder.Append( link == null ? $"<code>{possibleDuplicateFragment.FilePath}</code> (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})" : $"<a href='{link}'>{possibleDuplicateFragment.FilePath}</a> (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"); } return(builder.ToString()); }
private static string GetIdentifier(int cost, IReadOnlyCollection <DuplicateFragment> fragments, DuplicateFragment fragment) { var otherFragments = fragments.Where(f => !f.Equals(fragment)).OrderBy(f => f.FilePath).Select(p => p.FilePath); return($"{fragment.FilePath}-{cost}-{string.Join("-", otherFragments)}"); }
private static string GetSimpleMessage(int cost, IReadOnlyCollection <DuplicateFragment> fragments, DuplicateFragment fragment) { var builder = new StringBuilder(); builder.Append($"Possible duplicate detected (cost {cost}).\r\n"); builder.Append("The following fragments were found that might be duplicates:"); foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment))) { builder.Append("\r\n"); builder.Append( $"\"{possibleDuplicateFragment.FilePath}\" (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"); } return(builder.ToString()); }
private string GetMarkdownMessage(int cost, IReadOnlyCollection <DuplicateFragment> fragments, DuplicateFragment fragment) { var builder = new StringBuilder(); builder.Append($"Possible duplicate detected (cost {cost}).\r\n"); builder.Append("The following fragments were found that might be duplicates:"); foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment))) { builder.Append("\r\n"); var link = this.ResolveFileLinkForFragment(possibleDuplicateFragment); builder.Append( link == null ? $"`{possibleDuplicateFragment.FilePath}` (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})" : $"[{possibleDuplicateFragment.FilePath}]({link}) (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"); } return(builder.ToString()); }