Skip to content

Commit

Permalink
Fix analyzer severity defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Apr 30, 2021
1 parent 7b8deb3 commit b3e8554
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Expand Up @@ -4,6 +4,23 @@
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": "format @validate.rsp",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/dotnet-format/Debug/netcoreapp2.1/dotnet-format.dll",
"args": [
"@validate.rsp",
"--check"
],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false,
"justMyCode": false
},
{
"name": "format -f --check",
"type": "coreclr",
Expand Down
4 changes: 2 additions & 2 deletions src/FormatCommand.cs
Expand Up @@ -18,8 +18,8 @@ internal static class FormatCommand
bool noRestore,
bool folder,
bool fixWhitespace,
string? fixStyle,
string? fixAnalyzers,
string fixStyle,
string fixAnalyzers,
string[] diagnostics,
string? verbosity,
bool check,
Expand Down
9 changes: 5 additions & 4 deletions src/Program.cs
Expand Up @@ -48,8 +48,8 @@ private static async Task<int> Main(string[] args)
bool noRestore,
bool folder,
bool fixWhitespace,
string? fixStyle,
string? fixAnalyzers,
string fixStyle,
string fixAnalyzers,
string[] diagnostics,
string? verbosity,
bool check,
Expand Down Expand Up @@ -173,8 +173,8 @@ private static async Task<int> Main(string[] args)
noRestore,
logLevel,
fixType,
codeStyleSeverity: GetSeverity(fixStyle ?? FixSeverity.Error),
analyzerSeverity: GetSeverity(fixAnalyzers ?? FixSeverity.Error),
codeStyleSeverity: GetSeverity(fixStyle),
analyzerSeverity: GetSeverity(fixAnalyzers),
diagnostics: diagnostics.ToImmutableHashSet(),
saveFormattedFiles: !check,
changesAreErrors: check,
Expand Down Expand Up @@ -312,6 +312,7 @@ internal static DiagnosticSeverity GetSeverity(string? severity)
{
return severity?.ToLowerInvariant() switch
{
"" => DiagnosticSeverity.Error,
FixSeverity.Error => DiagnosticSeverity.Error,
FixSeverity.Warn => DiagnosticSeverity.Warning,
FixSeverity.Info => DiagnosticSeverity.Info,
Expand Down
2 changes: 2 additions & 0 deletions tests/Analyzers/ThirdPartyAnalyzerFormatterTests.cs
Expand Up @@ -45,6 +45,8 @@ public async Task InitializeAsync()
MSBuildRegistrar.RegisterInstance();
var analyzerWorkspace = await MSBuildWorkspaceLoader.LockedLoadAsync(workspacePath, WorkspaceType.Project, binaryLogPath: null, logWorkspaceWarnings: true, logger, CancellationToken.None);

TestOutputHelper.WriteLine(logger.GetLog());

// From this project we can get valid AnalyzerReferences to add to our test project.
_analyzerReferencesProject = analyzerWorkspace.CurrentSolution.Projects.Single();
}
Expand Down

0 comments on commit b3e8554

Please sign in to comment.