Merge pull request #7253 from Mailaender/utility-check-verbosity
Tweaked the StyleCop utility output
This commit is contained in:
@@ -27,30 +27,28 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
[Desc("DIRECTORY", "Check the *.cs source code files in a directory for code style violations.")]
|
[Desc("DIRECTORY", "Check the *.cs source code files in a directory for code style violations.")]
|
||||||
public void Run(ModData modData, string[] args)
|
public void Run(ModData modData, string[] args)
|
||||||
{
|
{
|
||||||
var projectPath = Path.GetFullPath(args[1]);
|
var relativePath = args[1];
|
||||||
|
var projectPath = Path.GetFullPath(relativePath);
|
||||||
|
|
||||||
var console = new StyleCopConsole(null, false, null, null, true);
|
var console = new StyleCopConsole(null, false, null, null, true);
|
||||||
var project = new CodeProject(0, projectPath, new Configuration(null));
|
var project = new CodeProject(0, projectPath, new Configuration(null));
|
||||||
foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories))
|
foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories))
|
||||||
console.Core.Environment.AddSourceCode(project, filePath, null);
|
console.Core.Environment.AddSourceCode(project, filePath, null);
|
||||||
|
|
||||||
console.OutputGenerated += OnOutputGenerated;
|
|
||||||
console.ViolationEncountered += OnViolationEncountered;
|
console.ViolationEncountered += OnViolationEncountered;
|
||||||
console.Start(new[] { project }, true);
|
console.Start(new[] { project }, true);
|
||||||
|
|
||||||
if (violationCount > 0)
|
if (violationCount > 0)
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
else
|
||||||
|
Console.WriteLine("No violations encountered in {0}.".F(relativePath));
|
||||||
void OnOutputGenerated(object sender, OutputEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.Output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnViolationEncountered(object sender, ViolationEventArgs e)
|
void OnViolationEncountered(object sender, ViolationEventArgs e)
|
||||||
{
|
{
|
||||||
violationCount++;
|
violationCount++;
|
||||||
Console.WriteLine("{0}:L{1}: [{2}] {3}", e.SourceCode.Path, e.LineNumber, e.Violation.Rule.CheckId, e.Message);
|
var path = e.SourceCode.Path.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, "");
|
||||||
|
Console.WriteLine("{0}:L{1}: [{2}] {3}", path, e.LineNumber, e.Violation.Rule.CheckId, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user