Skip to content

Commit

Permalink
Add info about how to ignore warning message (#710)
Browse files Browse the repository at this point in the history
* Add info about how to ignore to warning message

fixes #709

* PR review updates
  • Loading branch information
ErikEJ authored Feb 4, 2025
1 parent 3c5615d commit 58ea619
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/DacpacTool/PackageAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Analyze(TSqlModel model, FileInfo outputFile, FileInfo[] analyzers)

if (!rules.Any(r => r.Namespace == "SqlServer.Rules" || r.Namespace == "Smells"))
{
_console.WriteLine("DacpacTool warning SQLPROJ0001: No additional well-known rules files found, consider adding more rules via PackageReference - see the readme here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/README.md#static-code-analysis");
_console.WriteLine("DacpacTool warning SQLPROJ0001: No additional well-known rules files found, consider adding more rules via PackageReference - see the readme here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/README.md#static-code-analysis. You can ignore this warning by adding '<NoWarn>$(NoWarn);SQLPROJ0001</NoWarn>' to your project file.");
}

_console.WriteLine("Using analyzers: " + string.Join(", ", rules.Select(a => a.Namespace).Distinct()));
Expand Down
2 changes: 1 addition & 1 deletion src/DacpacTool/VersionChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task CheckForPackageUpdateAsync()

if (latestVersion > _versionProvider.CurrentPackageVersion())
{
_console.WriteLine($"DacpacTool warning SQLPROJ0002: You are not using the latest version of this SDK, please update to get the latest bug fixes, features and support. Modify your project file: '<Project Sdk=\"MSBuild.Sdk.SqlProj/{latestVersion}\">')");
_console.WriteLine($"DacpacTool warning SQLPROJ0002: You are not using the latest version of this SDK, please update to get the latest bug fixes, features and support. Modify your project file: '<Project Sdk=\"MSBuild.Sdk.SqlProj/{latestVersion}\">'. You can ignore this warning by adding '<NoWarn>$(NoWarn);SQLPROJ0002</NoWarn>' to your project file.");
}
}
#pragma warning disable CA1031 // Do not catch general exception types
Expand Down
4 changes: 2 additions & 2 deletions test/DacpacTool.Tests/PackageAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void RunsAnalyzerWithWarningsAsErrorsUsingWildcard()

testConsole.Lines.Count(l => l.Contains("Using analyzers: ")).ShouldBe(1);
testConsole.Lines.ShouldContain($"Analyzing package '{result.fileInfo.FullName}'");
testConsole.Lines.ShouldNotContain("DacpacTool warning SQLPROJ0001: No additional well-known rules files found, consider adding more rules via PackageReference - see the readme here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/README.md#static-code-analysis");
testConsole.Lines.ShouldNotContain("DacpacTool warning SQLPROJ0001: No additional well-known rules files found, consider adding more rules via PackageReference - see the readme here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/README.md#static-code-analysis. You can ignore this warning by adding '<NoWarn>$(NoWarn);SQLPROJ0001</NoWarn>' to your project file.");
testConsole.Lines.ShouldContain($"proc1.sql(1,47): Error SRD0006 : SqlServer.Rules : Avoid using SELECT *.");
testConsole.Lines.ShouldContain($"-1(1,1): Error SRD0002 : SqlServer.Rules : Table does not have a primary key.");
testConsole.Lines.Count(l => l.Contains("): Error ")).ShouldBe(2);
Expand All @@ -137,7 +137,7 @@ public void RunsAnalyzerWithoutAdditionalAnalyzers()
// Assert
testConsole.Lines.Count.ShouldBe(6);

testConsole.Lines[1].ShouldBe("DacpacTool warning SQLPROJ0001: No additional well-known rules files found, consider adding more rules via PackageReference - see the readme here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/README.md#static-code-analysis");
testConsole.Lines[1].ShouldBe("DacpacTool warning SQLPROJ0001: No additional well-known rules files found, consider adding more rules via PackageReference - see the readme here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/README.md#static-code-analysis. You can ignore this warning by adding '<NoWarn>$(NoWarn);SQLPROJ0001</NoWarn>' to your project file.");
testConsole.Lines.ShouldContain($"Analyzing package '{result.fileInfo.FullName}'");
testConsole.Lines.Count(l => l.Contains("Using analyzers: ")).ShouldBe(1);
testConsole.Lines.Count(l => l.Contains("): Error ")).ShouldBe(0);
Expand Down

0 comments on commit 58ea619

Please sign in to comment.