Skip to content

Commit c712886

Browse files
committed
Warnings.
1 parent 4f3b69e commit c712886

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

src/PostSharp.Engineering.McpApprovalServer/Mcp/Services/CommandHistoryService.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void Record(
9999
}
100100

101101
// Append to daily audit trail (outside lock - separate concern)
102-
this.AppendToAuditTrail( record );
102+
AppendToAuditTrail( record );
103103

104104
// Notify listeners
105105
this.HistoryUpdated?.Invoke( this, EventArgs.Empty );
@@ -119,14 +119,6 @@ public bool WasPreviouslyApproved( string sessionId, string command, string work
119119
}
120120
}
121121

122-
/// <summary>
123-
/// Clears a session. For compatibility - no-op since we use global history.
124-
/// </summary>
125-
public void ClearSession( string sessionId )
126-
{
127-
// No-op - we maintain global history now
128-
}
129-
130122
private void LoadHistory()
131123
{
132124
try
@@ -191,7 +183,7 @@ private void SaveHistory()
191183
return output[..maxOutputLength] + "... (truncated)";
192184
}
193185

194-
private void AppendToAuditTrail( CommandRecord record )
186+
private static void AppendToAuditTrail( CommandRecord record )
195187
{
196188
try
197189
{
@@ -211,9 +203,9 @@ private void AppendToAuditTrail( CommandRecord record )
211203
var exitCode = record.ExitCode?.ToString( CultureInfo.InvariantCulture ) ?? "N/A";
212204

213205
// Escape pipe characters in fields
214-
var command = record.Command.Replace( "|", "\\|" );
215-
var purpose = record.ClaimedPurpose.Replace( "|", "\\|" );
216-
var workingDir = record.WorkingDirectory.Replace( "|", "\\|" );
206+
var command = record.Command.Replace( "|", "\\|", StringComparison.Ordinal );
207+
var purpose = record.ClaimedPurpose.Replace( "|", "\\|", StringComparison.Ordinal );
208+
var workingDir = record.WorkingDirectory.Replace( "|", "\\|", StringComparison.Ordinal );
217209

218210
var logLine = $"{timestamp} | {status} | {command} | {purpose} | {workingDir} | {gitBranch} | {exitCode}";
219211

src/PostSharp.Engineering.McpApprovalServer/Mcp/Services/RegexRuleEngine.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public sealed class RegexRuleEngine
1717
/// <summary>
1818
/// Evaluates a command against regex-based rules, considering git context.
1919
/// </summary>
20-
public Task<RiskAssessment> EvaluateAsync(
20+
public static Task<RiskAssessment> EvaluateAsync(
2121
string command,
2222
string claimedPurpose,
2323
string workingDirectory,
2424
IReadOnlyList<CommandRecord> sessionHistory,
2525
CancellationToken cancellationToken = default )
2626
{
2727
// Build command context with git information
28-
var context = this.BuildContext( command, workingDirectory );
28+
var context = BuildContext( command, workingDirectory );
2929

3030
// Evaluate all rules in order
3131
foreach ( var rule in CommandRules.DefaultRules )
@@ -55,7 +55,7 @@ public Task<RiskAssessment> EvaluateAsync(
5555
} );
5656
}
5757

58-
private CommandContext BuildContext( string command, string workingDirectory )
58+
private static CommandContext BuildContext( string command, string workingDirectory )
5959
{
6060
var context = new CommandContext { Command = command, WorkingDirectory = workingDirectory };
6161

@@ -73,27 +73,27 @@ private CommandContext BuildContext( string command, string workingDirectory )
7373
}
7474

7575
// Try to get current branch
76-
if ( this.TryRunGitCommand( workingDirectory, "rev-parse --abbrev-ref HEAD", out var currentBranch ) )
76+
if ( TryRunGitCommand( workingDirectory, "rev-parse --abbrev-ref HEAD", out var currentBranch ) )
7777
{
7878
context = context with { CurrentBranch = currentBranch.Trim() };
7979
}
8080

8181
// Try to get remote URL
82-
if ( this.TryRunGitCommand( workingDirectory, "config --get remote.origin.url", out var remoteUrl ) )
82+
if ( TryRunGitCommand( workingDirectory, "config --get remote.origin.url", out var remoteUrl ) )
8383
{
8484
context = context with { RemoteUrl = remoteUrl.Trim() };
8585
}
8686

8787
// Try to check if merge is in progress
88-
if ( this.TryRunGitCommand( workingDirectory, "rev-parse -q --verify MERGE_HEAD", out _ ) )
88+
if ( TryRunGitCommand( workingDirectory, "rev-parse -q --verify MERGE_HEAD", out _ ) )
8989
{
9090
context = context with { IsMergeInProgress = true };
9191
}
9292

9393
return context;
9494
}
9595

96-
private bool TryRunGitCommand( string workingDirectory, string arguments, out string output )
96+
private static bool TryRunGitCommand( string workingDirectory, string arguments, out string output )
9797
{
9898
try
9999
{

src/PostSharp.Engineering.McpApprovalServer/Mcp/Tools/ExecuteCommandTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task<CommandResult> ExecuteCommand(
9090
sessionHistory,
9191
cancellationToken );
9292

93-
var regexTask = this._regexEngine.EvaluateAsync(
93+
var regexTask = RegexRuleEngine.EvaluateAsync(
9494
command,
9595
claimedPurpose,
9696
workingDirectory,

0 commit comments

Comments
 (0)