Skip to content

Commit 376f225

Browse files
SCAN4NET-257 Fix Quality Gate (#2328)
1 parent 85eaacd commit 376f225

File tree

6 files changed

+13
-61
lines changed

6 files changed

+13
-61
lines changed

Tests/SonarScanner.MSBuild.PreProcessor.Test/EmbeddedAnalyzerInstallerTests.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
22-
using System.Collections.Generic;
23-
using System.IO;
24-
using System.Linq;
25-
using FluentAssertions;
26-
using Microsoft.VisualStudio.TestTools.UnitTesting;
27-
using SonarScanner.MSBuild.Common;
2821
using SonarScanner.MSBuild.PreProcessor.Roslyn;
29-
using TestUtilities;
3022

3123
namespace SonarScanner.MSBuild.PreProcessor.Test;
3224

@@ -262,7 +254,7 @@ private MockSonarWebServer CreateServerWithDummyPlugin(string languageKey)
262254
private void AddPlugin(MockSonarWebServer server, Plugin plugin, params string[] files) =>
263255
server.Data.AddEmbeddedZipFile(plugin.Key, plugin.StaticResourceName, files);
264256

265-
private static IList<string> CalculateExpectedCachedFilePaths(string baseDir, int count, params string[] fileNames) =>
257+
private static List<string> CalculateExpectedCachedFilePaths(string baseDir, int count, params string[] fileNames) =>
266258
fileNames.Select(x => Path.Combine(baseDir, count.ToString(), x)).ToList();
267259

268260
private void AssertExpectedFilesReturned(IEnumerable<string> expectedFileNames, IEnumerable<AnalyzerPlugin> actualPlugins)

Tests/SonarScanner.MSBuild.PreProcessor.Test/JreResolution/JreResolverTests.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
22-
using System.Collections.Generic;
23-
using System.IO;
24-
using System.Linq;
25-
using System.Text;
26-
using System.Threading.Tasks;
27-
using FluentAssertions;
28-
using Microsoft.VisualStudio.TestTools.UnitTesting;
29-
using NSubstitute;
30-
using SonarScanner.MSBuild.Common;
3121
using SonarScanner.MSBuild.PreProcessor.JreResolution;
32-
using TestUtilities;
3322

3423
namespace SonarScanner.MSBuild.PreProcessor.Test.JreResolution;
3524

@@ -45,7 +34,7 @@ public class JreResolverTests
4534
private IJreCache cache;
4635
private TestLogger logger;
4736
private ISonarWebServer server;
48-
private IJreResolver sut;
37+
private JreResolver sut;
4938

5039
[TestInitialize]
5140
public void Initialize()

Tests/SonarScanner.MSBuild.PreProcessor.Test/ProcessedArgsTests.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
22-
using System.Collections.Generic;
23-
using System.IO;
24-
using FluentAssertions;
25-
using Microsoft.VisualStudio.TestTools.UnitTesting;
26-
using NSubstitute;
27-
using SonarScanner.MSBuild.Common;
28-
using TestUtilities;
29-
3021
namespace SonarScanner.MSBuild.PreProcessor.Test;
3122

3223
[TestClass]
@@ -535,6 +526,6 @@ private static void AssertExpectedValue(string key, string expectedValue, Proces
535526
actualValue.Should().Be(expectedValue, "Setting does not have the expected value. Key: {0}", key);
536527
}
537528

538-
private static IOperatingSystemProvider CreateOperatingSystemProvider() =>
539-
new OperatingSystemProvider(Substitute.For<IFileWrapper>(), Substitute.For<ILogger>());
529+
private static OperatingSystemProvider CreateOperatingSystemProvider() =>
530+
new(Substitute.For<IFileWrapper>(), Substitute.For<ILogger>());
540531
}

Tests/SonarScanner.MSBuild.PreProcessor.Test/Roslyn/PluginTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ namespace SonarScanner.MSBuild.PreProcessor.Test.Roslyn;
2525
[TestClass]
2626
public class PluginTests
2727
{
28+
[TestMethod]
2829
public void Plugin_IsValid()
2930
{
30-
var plugin = new Plugin() { Key = "pluginKey", Version = "42", StaticResourceName = "test.zip" };
31+
var plugin = new Plugin { Key = "pluginKey", Version = "42", StaticResourceName = "test.zip" };
3132
plugin.IsValid.Should().BeTrue();
3233
}
3334

@@ -41,7 +42,7 @@ public void Plugin_IsValid()
4142
[DataRow(null, null, null)]
4243
public void Plugin_Is_InValid(string key, string version, string resourceName)
4344
{
44-
var plugin = new Plugin() { Key = key, Version = version, StaticResourceName = resourceName };
45+
var plugin = new Plugin { Key = key, Version = version, StaticResourceName = resourceName };
4546
plugin.IsValid.Should().BeFalse();
4647
}
4748

@@ -63,9 +64,9 @@ public void Plugin_AddProperty_Populates_Correctly()
6364
public void XmlSerialization_SaveAndReload()
6465
{
6566
var tempFileName = Path.GetTempFileName();
66-
var original = new Plugin() { Key = "my key", Version = "MY VERSION", StaticResourceName = "my resource" };
67-
SonarScanner.MSBuild.Common.Serializer.SaveModel(original, tempFileName);
68-
var reloaded = SonarScanner.MSBuild.Common.Serializer.LoadModel<Plugin>(tempFileName);
67+
var original = new Plugin { Key = "my key", Version = "MY VERSION", StaticResourceName = "my resource" };
68+
Serializer.SaveModel(original, tempFileName);
69+
var reloaded = Serializer.LoadModel<Plugin>(tempFileName);
6970
reloaded.Key.Should().Be("my key");
7071
reloaded.Version.Should().Be("MY VERSION");
7172
reloaded.StaticResourceName.Should().Be("my resource");

Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarQubeWebServerTest.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,11 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
22-
using System.Collections.Generic;
23-
using System.IO;
24-
using System.Linq;
25-
using System.Net;
26-
using System.Net.Http;
27-
using System.Threading.Tasks;
28-
using FluentAssertions;
2921
using Google.Protobuf;
30-
using Microsoft.VisualStudio.TestTools.UnitTesting;
31-
using NSubstitute;
3222
using NSubstitute.ExceptionExtensions;
33-
using SonarScanner.MSBuild.Common;
3423
using SonarScanner.MSBuild.PreProcessor.JreResolution;
3524
using SonarScanner.MSBuild.PreProcessor.Protobuf;
3625
using SonarScanner.MSBuild.PreProcessor.WebServer;
37-
using TestUtilities;
3826

3927
namespace SonarScanner.MSBuild.PreProcessor.Test;
4028

@@ -732,7 +720,7 @@ private static Stream CreateCacheStream(IMessage message)
732720
return stream;
733721
}
734722

735-
private void MockStreamDownload(IDownloader downloader, Stream stream) =>
723+
private static void MockStreamDownload(IDownloader downloader, Stream stream) =>
736724
downloader.DownloadStream(Arg.Any<string>()).Returns(Task.FromResult(stream));
737725

738726
private static ProcessedArgs CreateLocalSettings(string projectKey, string branch, string organization = "placeholder", string token = "placeholder")
@@ -753,7 +741,7 @@ private static ProcessedArgs CreateLocalSettings(string projectKey, string branc
753741
return args;
754742
}
755743

756-
private SonarQubeWebServer CreateServer(IDownloader downloader = null, Version version = null, ILogger logger = null, string organization = null)
744+
private static SonarQubeWebServer CreateServer(IDownloader downloader = null, Version version = null, ILogger logger = null, string organization = null)
757745
{
758746
version ??= new("9.9");
759747
downloader ??= Substitute.For<IDownloader>();

Tests/SonarScanner.MSBuild.PreProcessor.Test/TargetsInstallerTests.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
22-
using System.Collections.Generic;
23-
using System.IO;
24-
using System.Linq;
2521
using System.Text.RegularExpressions;
26-
using FluentAssertions;
27-
using Microsoft.VisualStudio.TestTools.UnitTesting;
28-
using NSubstitute;
29-
using SonarScanner.MSBuild.Common;
30-
using TestUtilities;
3122

3223
namespace SonarScanner.MSBuild.PreProcessor.Test;
3324

@@ -308,7 +299,7 @@ private static void CleanupMsbuildDirectories()
308299
{
309300
// SONARMSBRU-149: we used to deploy the targets file to the 4.0 directory but this
310301
// is no longer supported. To be on the safe side we'll clean up the old location too.
311-
IList<string> cleanUpDirs = new MsBuildPathSettings(Substitute.For<ILogger>()).GetImportBeforePaths().ToList();
302+
var cleanUpDirs = new MsBuildPathSettings(Substitute.For<ILogger>()).GetImportBeforePaths().ToList();
312303

313304
var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
314305
cleanUpDirs.Add(Path.Combine(appData, "Microsoft", "MSBuild", "4.0", "Microsoft.Common.targets", "ImportBefore"));

0 commit comments

Comments
 (0)