From ed174c70c8a1de7aa22cbe5b4e0f734bd2977c7c Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Tue, 1 Mar 2016 11:09:03 +0300 Subject: [PATCH 01/10] Add PVS-Studio 6.01 inspections. #2 --- Plugin/agent/bin/PvsStudioIssueTypes.xml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Plugin/agent/bin/PvsStudioIssueTypes.xml b/Plugin/agent/bin/PvsStudioIssueTypes.xml index d943ac0..910268e 100644 --- a/Plugin/agent/bin/PvsStudioIssueTypes.xml +++ b/Plugin/agent/bin/PvsStudioIssueTypes.xml @@ -41,4 +41,19 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + From 34bf3f54b827a4ef2e75da4888b7a261b09221a3 Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Tue, 1 Mar 2016 11:16:02 +0300 Subject: [PATCH 02/10] Change editor config for c# code. #3 --- .editorconfig | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2b7c019..db932fc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,33 @@ root = true +[*] +end_of_line = CRLF + [*.{msbuild,xml}] charset = utf-8 -end_of_line = crlf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true [*.md] -indent_size = 4 \ No newline at end of file +indent_size = 4 + +[*.{config,cs,json}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{proj,props,sln,targets}] +indent_style = tab +trim_trailing_whitespace = true + +[*.{kproj,csproj,ps1,resx,rst}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[NuGet.Config] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true \ No newline at end of file From 570a1d4e886be85d5f76598ca6cd95f7e073f37a Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Tue, 1 Mar 2016 12:01:40 +0300 Subject: [PATCH 03/10] Add tests. #3 --- tests/TeamCity.PvsStudio.MetaRunner.Tests.sln | 28 ++++ ...PvsStudio.MetaRunner.Tests.sln.DotSettings | 2 + .../Class1.cs | 22 +++ .../Properties/AssemblyInfo.cs | 35 ++++ ...ty.PvsStudio.MetaRunner.TestProject.csproj | 55 +++++++ .../Helpers/PluginParameters.cs | 101 ++++++++++++ .../Helpers/PvsStudioExpectedErrorCode.cs | 15 ++ .../Properties/AssemblyInfo.cs | 35 ++++ .../PvsStudioTests.cs | 149 ++++++++++++++++++ .../App.config | 6 + .../Program.cs | 14 ++ .../Properties/AssemblyInfo.cs | 36 +++++ ...ty.PvsStudio.MetaRunner.TestProject.csproj | 61 +++++++ ...TeamCity.PvsStudio.MetaRunner.Tests.csproj | 89 +++++++++++ .../TestData/UnknownIssueTypeReport.xml | 113 +++++++++++++ .../packages.config | 11 ++ 16 files changed, 772 insertions(+) create mode 100644 tests/TeamCity.PvsStudio.MetaRunner.Tests.sln create mode 100644 tests/TeamCity.PvsStudio.MetaRunner.Tests.sln.DotSettings create mode 100644 tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Class1.cs create mode 100644 tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs create mode 100644 tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/App.config create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Program.cs create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.Tests.csproj create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml create mode 100644 tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/packages.config diff --git a/tests/TeamCity.PvsStudio.MetaRunner.Tests.sln b/tests/TeamCity.PvsStudio.MetaRunner.Tests.sln new file mode 100644 index 0000000..c3d7650 --- /dev/null +++ b/tests/TeamCity.PvsStudio.MetaRunner.Tests.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamCity.PvsStudio.MetaRunner.TestProject", "app\TeamCity.PvsStudio.MetaRunner.TestProject\TeamCity.PvsStudio.MetaRunner.TestProject.csproj", "{0C821208-FBE5-4421-826C-E9E22ADF7303}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamCity.PvsStudio.MetaRunner.Tests", "tests\TeamCity.PvsStudio.MetaRunner.Tests\TeamCity.PvsStudio.MetaRunner.Tests.csproj", "{282843E9-1846-4874-805A-5CCB59B3E633}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0C821208-FBE5-4421-826C-E9E22ADF7303}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C821208-FBE5-4421-826C-E9E22ADF7303}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C821208-FBE5-4421-826C-E9E22ADF7303}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C821208-FBE5-4421-826C-E9E22ADF7303}.Release|Any CPU.Build.0 = Release|Any CPU + {282843E9-1846-4874-805A-5CCB59B3E633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {282843E9-1846-4874-805A-5CCB59B3E633}.Debug|Any CPU.Build.0 = Debug|Any CPU + {282843E9-1846-4874-805A-5CCB59B3E633}.Release|Any CPU.ActiveCfg = Release|Any CPU + {282843E9-1846-4874-805A-5CCB59B3E633}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tests/TeamCity.PvsStudio.MetaRunner.Tests.sln.DotSettings b/tests/TeamCity.PvsStudio.MetaRunner.Tests.sln.DotSettings new file mode 100644 index 0000000..a038c82 --- /dev/null +++ b/tests/TeamCity.PvsStudio.MetaRunner.Tests.sln.DotSettings @@ -0,0 +1,2 @@ + + ExplicitlyExcluded \ No newline at end of file diff --git a/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Class1.cs b/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Class1.cs new file mode 100644 index 0000000..3ad86e9 --- /dev/null +++ b/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Class1.cs @@ -0,0 +1,22 @@ +namespace TeamCity.PvsStudio.MetaRunner.TestProject +{ + public class Class1 + { + public void Method() + { + //intentionally made mistakes for PVS-Studio testing + var s = "qwerty"; + + string f = null; + + var a = 0; + + if (f == string.Empty || f == string.Empty) + { + a = 5; + } + + s.Replace("s", a.ToString()); + } + } +} diff --git a/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs b/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8bf41d0 --- /dev/null +++ b/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TeamCity.PvsStudio.MetaRunner.TestProject")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TeamCity.PvsStudio.MetaRunner.TestProject")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0c821208-fbe5-4421-826c-e9e22adf7303")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj b/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj new file mode 100644 index 0000000..53edc62 --- /dev/null +++ b/tests/app/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {0C821208-FBE5-4421-826C-E9E22ADF7303} + Library + Properties + TeamCity.PvsStudio.MetaRunner.TestProject + TeamCity.PvsStudio.MetaRunner.TestProject + v4.6.1 + 512 + 1.0.0.0 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs new file mode 100644 index 0000000..e58651d --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs @@ -0,0 +1,101 @@ +using System; +using System.IO; +using System.Reflection; + +namespace TeamCity.PvsStudio.MetaRunner.Tests.Helpers +{ + public static class PluginParameters + { + public static string PvsStudioOutputPath + { + get { return Path.Combine(CurrentAssemblyPath, "temp", "result.xml"); } + } + + public static string XsltOutputPath + { + get { return Path.Combine(CurrentAssemblyPath, "temp", "resharperResult.xml"); } + } + + public static string PvsStudioConsolePath + { + get { return @"C:\Program Files (x86)\PVS-Studio\PVS-Studio_Cs.exe"; } + } + + public static string MsXslPath + { + get { return Path.Combine(PluginPath, "msxsl.exe"); } + } + + public static string PvsStudioParameters + { + get { return $"-r -o {PvsStudioOutputPath} -t {SolutionPath}"; } + } + + public static string MsXslParameters + { + get { return GenerateXsltParameters(PvsStudioOutputPath); } + } + + public static string GenerateXsltParameters(string inputPath) + { + return $"{inputPath} {XsltPath} -o {XsltOutputPath}"; + } + + public static string UnknownIssueTypeReportPath + { + get { return Path.Combine(CurrentAssemblyPath, "TestData", "UnknownIssueTypeReport.xml"); } + } + + private static string SolutionPath + { + get + { + var solutionDirectoryPath = GetParentDirectoryPath(CurrentAssemblyPath, 4); + + return Path.Combine(solutionDirectoryPath, "TeamCity.PvsStudio.MetaRunner.Tests.sln"); + } + } + + private static string PluginPath + { + get + { + var rootPath = GetParentDirectoryPath(CurrentAssemblyPath, 5); + + return Path.Combine(rootPath, "plugin", "agent", "bin"); + } + } + + private static string XsltPath + { + get { return Path.Combine(PluginPath, "ResharperReport.xslt"); } + } + + private static string CurrentAssemblyPath + { + get + { + var currentAssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); + + if (currentAssemblyPath == null) + { + throw new DirectoryNotFoundException(); + } + + return new Uri(currentAssemblyPath).LocalPath; + } + } + + private static string GetParentDirectoryPath(string directoryPath, int levelsUp) + { + var resultPath = directoryPath; + + for (var i = 0; i < levelsUp; i++) + { + resultPath = Directory.GetParent(resultPath).FullName; + } + + return resultPath; + } + } +} \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs new file mode 100644 index 0000000..5e8667e --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs @@ -0,0 +1,15 @@ +namespace TeamCity.PvsStudio.MetaRunner.Tests.Helpers +{ + public class PvsStudioExpectedErrorCode + { + public PvsStudioExpectedErrorCode(string errorCode, int occurrenceCount) + { + ErrorCode = errorCode; + OccurrenceCount = occurrenceCount; + } + + public string ErrorCode { get; private set; } + + public int OccurrenceCount { get; private set; } + } +} \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Properties/AssemblyInfo.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e4bb4f7 --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TeamCity.PvsStudio.MetaRunner.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TeamCity.PvsStudio.MetaRunner.Tests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("282843e9-1846-4874-805a-5ccb59b3e633")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs new file mode 100644 index 0000000..7991834 --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs @@ -0,0 +1,149 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Xml.Linq; +using JetBrains.Annotations; +using RunProcessAsTask; +using TeamCity.PvsStudio.MetaRunner.Tests.Helpers; +using Xunit; + +namespace TeamCity.PvsStudio.MetaRunner.Tests +{ + public class PvsStudioTests + { + public PvsStudioTests() + { + DeleteExistingFile(PluginParameters.PvsStudioOutputPath); + DeleteExistingFile(PluginParameters.XsltOutputPath); + } + + [Fact] + public async Task PvsStudioOutputTest() + { + var result = await ProcessEx.RunAsync(PluginParameters.PvsStudioConsolePath, PluginParameters.PvsStudioParameters); + AssertSuccessfulProcessCompletion(result); + + var expectedErrorCodes = new List + { + new PvsStudioExpectedErrorCode("V3001", 1), + new PvsStudioExpectedErrorCode("V3010", 1) + }; + + AssertValidPvsStudioAnalysisReport(PluginParameters.PvsStudioOutputPath, expectedErrorCodes); + } + + [Fact] + public async Task UnknownIssueTypeXsltOutputTest() + { + var xsltResult = await ProcessEx.RunAsync(PluginParameters.MsXslPath, PluginParameters.GenerateXsltParameters(PluginParameters.UnknownIssueTypeReportPath)); + AssertSuccessfulProcessCompletion(xsltResult); + + var expectedErrorCodes = new List + { + new PvsStudioExpectedErrorCode("V3001", 1), + new PvsStudioExpectedErrorCode("V9999", 2) + }; + + AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes); + } + + [Fact] + public async Task XsltOutputTest() + { + var pvsStudioResult = await ProcessEx.RunAsync(PluginParameters.PvsStudioConsolePath, PluginParameters.PvsStudioParameters); + AssertSuccessfulProcessCompletion(pvsStudioResult); + + var expectedErrorCodes = new List + { + new PvsStudioExpectedErrorCode("V3001", 1), + new PvsStudioExpectedErrorCode("V3010", 1) + }; + + AssertValidPvsStudioAnalysisReport(PluginParameters.PvsStudioOutputPath, expectedErrorCodes); + + var xsltResult = await ProcessEx.RunAsync(PluginParameters.MsXslPath, PluginParameters.MsXslParameters); + AssertSuccessfulProcessCompletion(xsltResult); + + AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes); + } + + private static void DeleteExistingFile(string filePath) + { + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + } + + [AssertionMethod] + private static void AssertFileExists(string filePath) + { + Assert.True(File.Exists(filePath)); + } + + [AssertionMethod] + private static void AssertSuccessfulProcessCompletion(ProcessResults result) + { + Assert.NotNull(result); + Assert.NotEqual(1, result.Process.ExitCode); + Assert.Empty(result.StandardError); + } + + [AssertionMethod] + private static void AssertValidPvsStudioAnalysisReport(string filePath, ICollection expectedErrorCodes) + { + AssertFileExists(filePath); + + var outputDocument = XDocument.Load(filePath); + Assert.NotNull(outputDocument); + + var analysisLogs = outputDocument.Descendants("PVS-Studio_Analysis_Log").ToList(); + + Assert.NotNull(analysisLogs); + Assert.Equal(expectedErrorCodes.Count, analysisLogs.Count); + + var errorCodes = analysisLogs.Select(analysisLog => analysisLog.Element("ErrorCode")).ToList(); + + var groupedCodesInReport = errorCodes.GroupBy(_ => _).ToList(); + + foreach (var expectedErrorCode in expectedErrorCodes) + { + var grouping = Assert.Single(groupedCodesInReport, _ => _.Key.Value == expectedErrorCode.ErrorCode); + Assert.NotNull(grouping); + Assert.Equal(expectedErrorCode.OccurrenceCount, grouping.Count()); + } + } + + [AssertionMethod] + private static void AssertValidResharperAnalysisReport(string filePath, ICollection expectedErrorCodes) + { + AssertFileExists(filePath); + + var resharperOutputDocument = XDocument.Load(filePath); + Assert.NotNull(resharperOutputDocument); + + var reportElement = resharperOutputDocument.Element("Report"); + Assert.NotNull(reportElement); + + var issueTypesElement = reportElement.Element("IssueTypes"); + Assert.NotNull(issueTypesElement); + + var issueTypeElements = issueTypesElement.Descendants("IssueType").ToList(); + + Assert.NotNull(issueTypeElements); + Assert.Equal(expectedErrorCodes.Count, issueTypeElements.Count); + + var issuesElement = reportElement.Element("Issues"); + Assert.NotNull(issuesElement); + + var projectElement = issuesElement.Element("Project"); + Assert.NotNull(projectElement); + + var issueElements = projectElement.Descendants("Issue").ToList(); + + Assert.NotNull(issueElements); + Assert.Equal(expectedErrorCodes.Select(_ => _.OccurrenceCount).Sum(), issueElements.Count); + } + } +} diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/App.config b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Program.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Program.cs new file mode 100644 index 0000000..af2557e --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Program.cs @@ -0,0 +1,14 @@ +namespace TeamCity.PvsStudio.MetaRunner.TestProject +{ + static class Program + { + static void Main() + { + var s = "qwerty"; + + //issue is made intentionally for testing PVS Studio + // ReSharper disable once ReturnValueOfPureMethodIsNotUsed + s.Replace("q", string.Empty); + } + } +} diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..29aecaf --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TeamCity.PvsStudio.MetaRunner.TestProject")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TeamCity.PvsStudio.MetaRunner.TestProject")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2850fbfa-1f9d-46be-a8e3-0ecf5fff7a75")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj new file mode 100644 index 0000000..84ecd98 --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.TestProject/TeamCity.PvsStudio.MetaRunner.TestProject.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {2850FBFA-1F9D-46BE-A8E3-0ECF5FFF7A75} + Exe + Properties + TeamCity.PvsStudio.MetaRunner.TestProject + TeamCity.PvsStudio.MetaRunner.TestProject + v4.6.1 + 512 + true + 1.0.0.0 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.Tests.csproj b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.Tests.csproj new file mode 100644 index 0000000..c261d6c --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TeamCity.PvsStudio.MetaRunner.Tests.csproj @@ -0,0 +1,89 @@ + + + + + Debug + AnyCPU + {282843E9-1846-4874-805A-5CCB59B3E633} + Library + Properties + TeamCity.PvsStudio.MetaRunner.Tests + TeamCity.PvsStudio.MetaRunner.Tests + v4.6.1 + 512 + 1.0.0.0 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\JetBrains.Annotations.10.0.0\lib\net20\JetBrains.Annotations.dll + True + + + ..\..\packages\RunProcessAsTask.1.1.0\lib\RunProcessAsTask.dll + True + + + + + + + + + + + ..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll + True + + + ..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll + True + + + ..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll + True + + + + + + + + + + + + + + Always + + + + + \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml new file mode 100644 index 0000000..79e5759 --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + D:\Projects\teamcity-pvs-studio-meta-runner\tests\TeamCity.PvsStudio.MetaRunner.Tests.sln + 14.0 + 3 + 2016-02-29T14:49:54.0332805Z + + + false + 1 + 1 + V3001 + There are identical sub-expressions 'f == string.Empty' to the left and to the right of the '||' operator. + TeamCity.PvsStudio.MetaRunner.TestProject + TRIAL RESTRICTION + 14 + false + 1 + 214879571 + 1629368839 + 123 + true + 4 + + false + + + false + 1 + 2 + V9999 + The return value of function 'Replace' is required to be utilized. + TeamCity.PvsStudio.MetaRunner.TestProject + TRIAL RESTRICTION + 21 + false + 2 + 1345105634 + 3418268110 + 125 + true + 4 + + false + + + false + 1 + 2 + V9999 + The return value of function 'Replace' is required to be utilized. + TeamCity.PvsStudio.MetaRunner.TestProject + TRIAL RESTRICTION + 23 + false + 2 + 1345105634 + 3418268110 + 125 + true + 4 + + false + + diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/packages.config b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/packages.config new file mode 100644 index 0000000..09efc5c --- /dev/null +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file From fe35f556e3ea04bb6b634db0f5544b94017dcb0d Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Tue, 1 Mar 2016 12:04:33 +0300 Subject: [PATCH 04/10] Fix issue with unknown inspections in report. #3 --- Plugin/agent/bin/ResharperReport.xslt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Plugin/agent/bin/ResharperReport.xslt b/Plugin/agent/bin/ResharperReport.xslt index a9a6c16..6f11365 100644 --- a/Plugin/agent/bin/ResharperReport.xslt +++ b/Plugin/agent/bin/ResharperReport.xslt @@ -55,6 +55,13 @@ - - + + + + + + + + + From 775092a8f4ad95f64c484aa3ceff697496a74e5d Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Fri, 4 Mar 2016 19:26:14 +0300 Subject: [PATCH 05/10] Add Project Rider generated files to .gitignore. #4 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 2ae903d..2e7885f 100644 --- a/.gitignore +++ b/.gitignore @@ -230,3 +230,6 @@ _Pvt_Extensions # FAKE - F# Make .fake/ + +.idea/ +*.sln.iml From 2c48ad9b55320b6cc61302d247404aa237685c91 Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Fri, 4 Mar 2016 19:27:37 +0300 Subject: [PATCH 06/10] Add group by priority behavior. #4 --- Plugin/agent/bin/PvsStudioIssueTypes.xml | 112 +++++++++--------- Plugin/agent/bin/ResharperReport.xslt | 26 +++- .../Helpers/PvsStudioExpectedErrorCode.cs | 8 +- .../PvsStudioTests.cs | 27 ++++- .../TestData/UnknownIssueTypeReport.xml | 4 +- 5 files changed, 109 insertions(+), 68 deletions(-) diff --git a/Plugin/agent/bin/PvsStudioIssueTypes.xml b/Plugin/agent/bin/PvsStudioIssueTypes.xml index 910268e..0f248d7 100644 --- a/Plugin/agent/bin/PvsStudioIssueTypes.xml +++ b/Plugin/agent/bin/PvsStudioIssueTypes.xml @@ -1,59 +1,59 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugin/agent/bin/ResharperReport.xslt b/Plugin/agent/bin/ResharperReport.xslt index 6f11365..4fa0cf9 100644 --- a/Plugin/agent/bin/ResharperReport.xslt +++ b/Plugin/agent/bin/ResharperReport.xslt @@ -55,12 +55,32 @@ + - - + + + + + + + + + + + + + + + + + + + + + - + diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs index 5e8667e..5cab4f6 100644 --- a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PvsStudioExpectedErrorCode.cs @@ -2,14 +2,20 @@ namespace TeamCity.PvsStudio.MetaRunner.Tests.Helpers { public class PvsStudioExpectedErrorCode { - public PvsStudioExpectedErrorCode(string errorCode, int occurrenceCount) + public PvsStudioExpectedErrorCode(string errorCode, string category, int priority, int occurrenceCount) { ErrorCode = errorCode; + Category = category; OccurrenceCount = occurrenceCount; + Priority = priority; } public string ErrorCode { get; private set; } + public string Category { get; private set; } + public int OccurrenceCount { get; private set; } + + public int Priority { get; private set; } } } \ No newline at end of file diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs index 7991834..8f60619 100644 --- a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs @@ -12,6 +12,13 @@ namespace TeamCity.PvsStudio.MetaRunner.Tests { public class PvsStudioTests { + private const string CategoryGeneralAnalysis = "General Analysis"; + private const string CategoryMissing = "Unknown Inspections"; + + private const string ErrorCode3001 = "V3001"; + private const string ErrorCode3010 = "V3010"; + private const string ErrorCodeMissing = "V9999"; + public PvsStudioTests() { DeleteExistingFile(PluginParameters.PvsStudioOutputPath); @@ -26,8 +33,8 @@ public async Task PvsStudioOutputTest() var expectedErrorCodes = new List { - new PvsStudioExpectedErrorCode("V3001", 1), - new PvsStudioExpectedErrorCode("V3010", 1) + new PvsStudioExpectedErrorCode(ErrorCode3001, CategoryGeneralAnalysis, 1, 1), + new PvsStudioExpectedErrorCode(ErrorCode3010, CategoryGeneralAnalysis, 1, 1) }; AssertValidPvsStudioAnalysisReport(PluginParameters.PvsStudioOutputPath, expectedErrorCodes); @@ -41,8 +48,8 @@ public async Task UnknownIssueTypeXsltOutputTest() var expectedErrorCodes = new List { - new PvsStudioExpectedErrorCode("V3001", 1), - new PvsStudioExpectedErrorCode("V9999", 2) + new PvsStudioExpectedErrorCode(ErrorCode3001, CategoryGeneralAnalysis, 1, 1), + new PvsStudioExpectedErrorCode(ErrorCodeMissing, CategoryMissing, 2, 2) }; AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes); @@ -56,8 +63,8 @@ public async Task XsltOutputTest() var expectedErrorCodes = new List { - new PvsStudioExpectedErrorCode("V3001", 1), - new PvsStudioExpectedErrorCode("V3010", 1) + new PvsStudioExpectedErrorCode(ErrorCode3001, CategoryGeneralAnalysis, 1, 1), + new PvsStudioExpectedErrorCode(ErrorCode3010, CategoryGeneralAnalysis, 1, 1) }; AssertValidPvsStudioAnalysisReport(PluginParameters.PvsStudioOutputPath, expectedErrorCodes); @@ -134,6 +141,14 @@ private static void AssertValidResharperAnalysisReport(string filePath, ICollect Assert.NotNull(issueTypeElements); Assert.Equal(expectedErrorCodes.Count, issueTypeElements.Count); + foreach (var expectedErrorCode in expectedErrorCodes) + { + var issueType = Assert.Single(issueTypeElements, _ => _.Attribute("Id").Value == expectedErrorCode.ErrorCode); + Assert.NotNull(issueType); + Assert.Equal($"PVS-Studio {expectedErrorCode.Category}. Priority: {expectedErrorCode.Priority}", issueType.Attribute("Category").Value); + Assert.Equal($"{issueType.Attribute("Id").Value}. {issueType.Attribute("Description").Value}", issueType.Attribute("SubCategory").Value); + } + var issuesElement = reportElement.Element("Issues"); Assert.NotNull(issuesElement); diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml index 79e5759..6e6fb41 100644 --- a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/TestData/UnknownIssueTypeReport.xml @@ -74,7 +74,7 @@ false - 1 + 2 2 V9999 The return value of function 'Replace' is required to be utilized. @@ -93,7 +93,7 @@ false - 1 + 2 2 V9999 The return value of function 'Replace' is required to be utilized. From ee5d9395d4225c6fe895615f0b491b83ce63b169 Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Mon, 7 Mar 2016 11:47:32 +0300 Subject: [PATCH 07/10] Add built releases to git ignore. #1 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2e7885f..bb50c2a 100644 --- a/.gitignore +++ b/.gitignore @@ -233,3 +233,4 @@ _Pvt_Extensions .idea/ *.sln.iml +*.zip \ No newline at end of file From c25d79526922cba114d721125bfebc6cecc1efe6 Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Mon, 7 Mar 2016 12:32:46 +0300 Subject: [PATCH 08/10] Add possibility to treat priority 1 issues as errors. #1 --- Plugin/agent/bin/PvsStudioIssueTypes.xml | 112 +++++++++--------- Plugin/agent/bin/ResharperReport.xslt | 26 ++-- .../MRPLUGIN_PvsStudioBuildRunnerPlugin.xml | 4 +- .../Helpers/PluginParameters.cs | 6 +- .../PvsStudioTests.cs | 47 ++++++-- 5 files changed, 117 insertions(+), 78 deletions(-) diff --git a/Plugin/agent/bin/PvsStudioIssueTypes.xml b/Plugin/agent/bin/PvsStudioIssueTypes.xml index 0f248d7..b1eff14 100644 --- a/Plugin/agent/bin/PvsStudioIssueTypes.xml +++ b/Plugin/agent/bin/PvsStudioIssueTypes.xml @@ -1,59 +1,59 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugin/agent/bin/ResharperReport.xslt b/Plugin/agent/bin/ResharperReport.xslt index 4fa0cf9..ee4b3e1 100644 --- a/Plugin/agent/bin/ResharperReport.xslt +++ b/Plugin/agent/bin/ResharperReport.xslt @@ -1,6 +1,7 @@  + @@ -14,10 +15,10 @@ Solution - - + + @@ -56,6 +57,7 @@ + @@ -63,7 +65,7 @@ - + @@ -71,16 +73,20 @@ - - - - - - + + + ERROR + + + + + + + - + diff --git a/Plugin/server/metaRunners/MRPLUGIN_PvsStudioBuildRunnerPlugin.xml b/Plugin/server/metaRunners/MRPLUGIN_PvsStudioBuildRunnerPlugin.xml index d7c5aba..35e880d 100644 --- a/Plugin/server/metaRunners/MRPLUGIN_PvsStudioBuildRunnerPlugin.xml +++ b/Plugin/server/metaRunners/MRPLUGIN_PvsStudioBuildRunnerPlugin.xml @@ -6,12 +6,14 @@ + + diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs index e58651d..8a0bb1d 100644 --- a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/Helpers/PluginParameters.cs @@ -33,12 +33,12 @@ public static string PvsStudioParameters public static string MsXslParameters { - get { return GenerateXsltParameters(PvsStudioOutputPath); } + get { return GenerateXsltParameters(PvsStudioOutputPath, false); } } - public static string GenerateXsltParameters(string inputPath) + public static string GenerateXsltParameters(string inputPath, bool treatPriority1IssuesAsErrors) { - return $"{inputPath} {XsltPath} -o {XsltOutputPath}"; + return $@"{inputPath} {XsltPath} -o {XsltOutputPath} treatPriority1IssuesAsErrors=""{Convert.ToInt32(treatPriority1IssuesAsErrors)}"""; } public static string UnknownIssueTypeReportPath diff --git a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs index 8f60619..30f6563 100644 --- a/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs +++ b/tests/tests/TeamCity.PvsStudio.MetaRunner.Tests/PvsStudioTests.cs @@ -43,7 +43,7 @@ public async Task PvsStudioOutputTest() [Fact] public async Task UnknownIssueTypeXsltOutputTest() { - var xsltResult = await ProcessEx.RunAsync(PluginParameters.MsXslPath, PluginParameters.GenerateXsltParameters(PluginParameters.UnknownIssueTypeReportPath)); + var xsltResult = await ProcessEx.RunAsync(PluginParameters.MsXslPath, PluginParameters.GenerateXsltParameters(PluginParameters.UnknownIssueTypeReportPath, false)); AssertSuccessfulProcessCompletion(xsltResult); var expectedErrorCodes = new List @@ -52,7 +52,22 @@ public async Task UnknownIssueTypeXsltOutputTest() new PvsStudioExpectedErrorCode(ErrorCodeMissing, CategoryMissing, 2, 2) }; - AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes); + AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes, false); + } + + [Fact] + public async Task TreatPriority1IssuesAsErrorsXsltOutputTest() + { + var xsltResult = await ProcessEx.RunAsync(PluginParameters.MsXslPath, PluginParameters.GenerateXsltParameters(PluginParameters.UnknownIssueTypeReportPath, true)); + AssertSuccessfulProcessCompletion(xsltResult); + + var expectedErrorCodes = new List + { + new PvsStudioExpectedErrorCode(ErrorCode3001, CategoryGeneralAnalysis, 1, 1), + new PvsStudioExpectedErrorCode(ErrorCodeMissing, CategoryMissing, 2, 2) + }; + + AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes, true); } [Fact] @@ -72,7 +87,7 @@ public async Task XsltOutputTest() var xsltResult = await ProcessEx.RunAsync(PluginParameters.MsXslPath, PluginParameters.MsXslParameters); AssertSuccessfulProcessCompletion(xsltResult); - AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes); + AssertValidResharperAnalysisReport(PluginParameters.XsltOutputPath, expectedErrorCodes, false); } private static void DeleteExistingFile(string filePath) @@ -123,7 +138,7 @@ private static void AssertValidPvsStudioAnalysisReport(string filePath, ICollect } [AssertionMethod] - private static void AssertValidResharperAnalysisReport(string filePath, ICollection expectedErrorCodes) + private static void AssertValidResharperAnalysisReport(string filePath, ICollection expectedErrorCodes, bool treatPriority1IssuesAsErrors) { AssertFileExists(filePath); @@ -143,10 +158,7 @@ private static void AssertValidResharperAnalysisReport(string filePath, ICollect foreach (var expectedErrorCode in expectedErrorCodes) { - var issueType = Assert.Single(issueTypeElements, _ => _.Attribute("Id").Value == expectedErrorCode.ErrorCode); - Assert.NotNull(issueType); - Assert.Equal($"PVS-Studio {expectedErrorCode.Category}. Priority: {expectedErrorCode.Priority}", issueType.Attribute("Category").Value); - Assert.Equal($"{issueType.Attribute("Id").Value}. {issueType.Attribute("Description").Value}", issueType.Attribute("SubCategory").Value); + AssertResharperIssueTypes(issueTypeElements, expectedErrorCode, treatPriority1IssuesAsErrors); } var issuesElement = reportElement.Element("Issues"); @@ -160,5 +172,24 @@ private static void AssertValidResharperAnalysisReport(string filePath, ICollect Assert.NotNull(issueElements); Assert.Equal(expectedErrorCodes.Select(_ => _.OccurrenceCount).Sum(), issueElements.Count); } + + [AssertionMethod] + private static void AssertResharperIssueTypes(IEnumerable issueTypeElements, PvsStudioExpectedErrorCode expectedErrorCode, bool treatPriority1IssuesAsErrors) + { + var issueType = Assert.Single(issueTypeElements, _ => _.Attribute("Id").Value == expectedErrorCode.ErrorCode); + Assert.NotNull(issueType); + + Assert.Equal($"PVS-Studio {expectedErrorCode.Category}. Priority: {expectedErrorCode.Priority}", issueType.Attribute("Category").Value); + Assert.Equal($"{issueType.Attribute("Id").Value}. {issueType.Attribute("Description").Value}", issueType.Attribute("SubCategory").Value); + + AssertSeverity(expectedErrorCode, issueType, treatPriority1IssuesAsErrors); + } + + [AssertionMethod] + private static void AssertSeverity(PvsStudioExpectedErrorCode expectedErrorCode, XElement issueType, bool treatPriority1IssuesAsErrors) + { + var expectedSeverity = treatPriority1IssuesAsErrors && expectedErrorCode.Priority == 1 ? "ERROR" : "WARNING"; + Assert.Equal(expectedSeverity, issueType.Attribute("Severity").Value); + } } } From 74225171a8fdc025c4a0193e22b0fcca4c7d3398 Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Mon, 7 Mar 2016 12:38:15 +0300 Subject: [PATCH 09/10] Update version number. #5 --- Plugin/teamcity-plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugin/teamcity-plugin.xml b/Plugin/teamcity-plugin.xml index 7adf9f1..5764c8e 100644 --- a/Plugin/teamcity-plugin.xml +++ b/Plugin/teamcity-plugin.xml @@ -4,7 +4,7 @@ PvsStudioBuildRunnerPlugin PVS Studio Build Runner - snapshot + 1.1.0.0 Adds a PVS Studio Build Step option to TeamCity Ales Buzhynsky From 111f3e873ce86ef5355b78e83c15091931eec981 Mon Sep 17 00:00:00 2001 From: a_buzhynsky <3566526@gmail.com> Date: Mon, 7 Mar 2016 12:51:04 +0300 Subject: [PATCH 10/10] Add release notes. #5 --- documents/releaseNotes/1.1.0.0.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 documents/releaseNotes/1.1.0.0.md diff --git a/documents/releaseNotes/1.1.0.0.md b/documents/releaseNotes/1.1.0.0.md new file mode 100644 index 0000000..67bb1c3 --- /dev/null +++ b/documents/releaseNotes/1.1.0.0.md @@ -0,0 +1,18 @@ +#TeamCity PVS Studio Meta-Runner v1.1.0.0 + +##Changes: + +###Added grouping by category name and priority (e.g. PVS-Studio General Analysis Priority: 1) + +###Added possibility to treat priority 1 issues as errors +Now there is a checkbox in build step to toggle this behaviour. + +###Added PVS-Studio 6.01 inspections support + +###Added support of PVS-Studio next releases inspections +They will be displayed without category name in build results but with inspection Id and inspection message. + +##Update instructions: +1. Download 'pvs-studio-build-runner.zip' from the [latest release](https://github.com/abuzhynsky/teamcity-pvs-studio-meta-runner/releases/latest) +2. Copy this file into the _[Team City Data Directory]\plugins_ directory on the TeamCity Server, by default this is _C:\ProgramData\JetBrains\TeamCity\plugins_ or upload it using TeamCity 'Plugins List' tab (_Administration-Plugins List_) +3. Restart the Team City server \ No newline at end of file