Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit 96220e4

Browse files
Refactor SecretsCheck output handling and improve formatting
1 parent b601a08 commit 96220e4

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

RepositoryLinter/Checks/SecretsCheck.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,22 @@ public override string ToString()
4040
var outputBuilder = new StringBuilder(base.ToString());
4141
outputBuilder.Append('\n');
4242

43-
if (Status == CheckStatus.Green)
43+
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
44+
switch (Status)
4445
{
45-
outputBuilder.Append($"Ran Trufflehog with command \"{_lastRunCommand}\" and no secrets where found.");
46-
return outputBuilder.ToString();
47-
}
48-
49-
if (Status == CheckStatus.Yellow)
50-
{
51-
outputBuilder.Append(_additionalInfo);
52-
return outputBuilder.ToString();
46+
case CheckStatus.Green:
47+
outputBuilder.Append($"Ran Trufflehog with command \"{_lastRunCommand}\" and no secrets where found.");
48+
return outputBuilder.ToString();
49+
case CheckStatus.Yellow:
50+
outputBuilder.Append(_additionalInfo);
51+
return outputBuilder.ToString();
5352
}
5453

5554
outputBuilder.Append("\nSecrets found:\n");
5655

5756
foreach (var secret in _foundSecretsJson)
5857
{
59-
var formatted = TrufflehogJsonToString(secret);
58+
string formatted = TrufflehogJsonToString(secret);
6059

6160
if (formatted == null)
6261
{
@@ -67,12 +66,12 @@ public override string ToString()
6766
}
6867

6968
// Number of secrets found
70-
outputBuilder.Append($"Total number of secrets found: {_foundSecretsJson.Count}\n");
69+
outputBuilder.Append($"Total number of secrets found: {_foundSecretsJson.Count}");
7170

72-
if (_fileHasBeenIgnored)
73-
{
74-
outputBuilder.Append(_additionalInfo);
75-
}
71+
if (!_fileHasBeenIgnored) return outputBuilder.ToString();
72+
73+
outputBuilder.Append(Environment.NewLine);
74+
outputBuilder.Append(_additionalInfo);
7675

7776
return outputBuilder.ToString();
7877
}

0 commit comments

Comments
 (0)