Chore/sonarqube src dedup #20
@@ -361,13 +361,7 @@ public class ExpressionGenerator : IVisitor<string>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static string TruncateText(string text, int maxLength)
|
private static string TruncateText(string text, int maxLength)
|
||||||
{
|
=> Internal.MarkdownTextHelpers.TruncateText(text, maxLength);
|
||||||
if (string.IsNullOrWhiteSpace(text) || text.Length <= maxLength)
|
|
||||||
{
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
return string.Concat(text.AsSpan(0, maxLength), "...");
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IVisitor Implementation
|
#region IVisitor Implementation
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Strata.SqlTools.Markdown.Internal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Small text utilities shared by the Markdown generators.
|
||||||
|
/// Kept <c>internal</c> so they don't widen the public surface of this assembly.
|
||||||
|
/// </summary>
|
||||||
|
internal static class MarkdownTextHelpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Truncates a string to <paramref name="maxLength"/> characters, appending an ellipsis when truncated.
|
||||||
|
/// Returns the input unchanged when null/whitespace or already short enough.
|
||||||
|
/// </summary>
|
||||||
|
public static string TruncateText(string text, int maxLength)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text) || text.Length <= maxLength)
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
return string.Concat(text.AsSpan(0, maxLength), "...");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -191,17 +191,7 @@ public static class QueryBreakdownGenerator
|
|||||||
.Replace(">", ">");
|
.Replace(">", ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Truncates text to a maximum length and adds ellipsis if needed.
|
|
||||||
/// </summary>
|
|
||||||
private static string TruncateText(string text, int maxLength)
|
private static string TruncateText(string text, int maxLength)
|
||||||
{
|
=> Internal.MarkdownTextHelpers.TruncateText(text, maxLength);
|
||||||
if (string.IsNullOrWhiteSpace(text) || text.Length <= maxLength)
|
|
||||||
{
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Concat(text.AsSpan(0, maxLength), "...");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,18 +112,8 @@ public static class SqlStatementGenerator
|
|||||||
.Replace("\r", "");
|
.Replace("\r", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Truncates text to a maximum length.
|
|
||||||
/// </summary>
|
|
||||||
private static string TruncateText(string text, int maxLength)
|
private static string TruncateText(string text, int maxLength)
|
||||||
{
|
=> Internal.MarkdownTextHelpers.TruncateText(text, maxLength);
|
||||||
if (string.IsNullOrWhiteSpace(text) || text.Length <= maxLength)
|
|
||||||
{
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Concat(text.AsSpan(0, maxLength), "...");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cleans table name for use in Mermaid diagrams.
|
/// Cleans table name for use in Mermaid diagrams.
|
||||||
|
|||||||
Reference in New Issue
Block a user