Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up test break. Mark doc comment warnings as silent for now. #2112

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_diagnostic.CS1570.severity = warning
dotnet_diagnostic.CS1572.severity = warning
dotnet_diagnostic.CS1573.severity = warning
dotnet_diagnostic.CS1574.severity = warning
dotnet_diagnostic.CS1591.severity = warning
dotnet_diagnostic.CS1712.severity = warning
dotnet_diagnostic.CS1734.severity = warning
dotnet_diagnostic.CS1570.severity = silent
dotnet_diagnostic.CS1572.severity = silent
dotnet_diagnostic.CS1573.severity = silent
dotnet_diagnostic.CS1574.severity = silent
dotnet_diagnostic.CS1591.severity = silent
dotnet_diagnostic.CS1712.severity = silent
dotnet_diagnostic.CS1734.severity = silent
13 changes: 9 additions & 4 deletions src/Sarif/FileSearcherHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ internal static class FileSearcherHelper
/// </summary>
/// <param name="environmentVariable">Environment variable that we will look for</param>
/// <param name="fileName">Name of the file that we will look for in the environment variable</param>
/// <param name="fileSystem">An object that provides access to the file system.</param>
/// <returns>Path to the file name or empty string.</returns>
public static string SearchForFileInEnvironmentVariable(string environmentVariable, string fileName)
public static string SearchForFileInEnvironmentVariable(string environmentVariable, string fileName, IFileSystem fileSystem = null)
{
fileSystem ??= new FileSystem();

string variable = Environment.GetEnvironmentVariable(environmentVariable);
if (string.IsNullOrEmpty(variable))
{
Expand All @@ -26,7 +29,7 @@ public static string SearchForFileInEnvironmentVariable(string environmentVariab
string[] paths = variable.Split(';');
foreach (string path in paths)
{
string returnedPath = SearchForFileNameInPath(path, fileName);
string returnedPath = SearchForFileNameInPath(path, fileName, fileSystem);
if (!string.IsNullOrEmpty(returnedPath))
{
return returnedPath;
Expand All @@ -41,11 +44,13 @@ public static string SearchForFileInEnvironmentVariable(string environmentVariab
/// </summary>
/// <param name="path">Path where it will search.</param>
/// <param name="fileName">Name of the file that it will search</param>
/// <param name="fileSystem">An object that provides access to the file system.</param>
/// <returns>Path to the file name or empty string.</returns>
public static string SearchForFileNameInPath(string path, string fileName)
public static string SearchForFileNameInPath(string path, string fileName, IFileSystem fileSystem = null)
{
fileSystem ??= new FileSystem();
string filePath = $@"{path}\{fileName}";
return File.Exists(filePath) ? filePath : null;
return fileSystem.FileExists(filePath) ? filePath : null;
}
}
}
8 changes: 4 additions & 4 deletions src/Sarif/GitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public GitHelper(IFileSystem fileSystem = null, ProcessRunner processRunner = nu
this.fileSystem = fileSystem ?? new FileSystem();
this.processRunner = processRunner ?? DefaultProcessRunner;

GitExePath = GetGitExePath();
GitExePath = GetGitExePath(this.fileSystem);
}

public string GitExePath { get; set; }
Expand Down Expand Up @@ -73,14 +73,14 @@ public void Checkout(string repoPath, string commitSha)
args: $"checkout {commitSha}");
}

internal string GetGitExePath()
internal static string GetGitExePath(IFileSystem fileSystem)
{
if (this.fileSystem.FileExists(s_expectedGitExePath))
if (fileSystem.FileExists(s_expectedGitExePath))
{
return s_expectedGitExePath;
}

return FileSearcherHelper.SearchForFileInEnvironmentVariable("PATH", "git.exe");
return FileSearcherHelper.SearchForFileInEnvironmentVariable("PATH", "git.exe", fileSystem);
}

public string GetCurrentBranch(string repoPath)
Expand Down
10 changes: 6 additions & 4 deletions src/Test.UnitTests.Sarif/GitHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public void GetGitExePath_WhenPathExistsInProgramFiles()

var gitHelper = new GitHelper(mockFileSystem.Object);

gitHelper.GetGitExePath().Should().NotBeNullOrEmpty();
gitHelper.GitExePath.Should().NotBeNullOrEmpty();
GitHelper.GetGitExePath(mockFileSystem.Object).Should().NotBeNullOrEmpty();
}

[Fact]
Expand All @@ -139,7 +140,8 @@ public void GetGitExePath_WhenPathDoesNotExistInProgramFiles()

var gitHelper = new GitHelper(mockFileSystem.Object);

gitHelper.GetGitExePath().Should().NotBeNull();
gitHelper.GitExePath.Should().BeNull();
GitHelper.GetGitExePath(mockFileSystem.Object).Should().BeNull();
}

[Fact]
Expand All @@ -149,7 +151,7 @@ public void SearchForFileInEnvironmentVariable_WhenVariableDoesNotExist()
}

[Fact]
public void SearchForFileInEnvironmentVariable_WhenVariableExistsButFileDoesnt()
public void SearchForFileInEnvironmentVariable_WhenVariableExistsButFileDoesNot()
{
// The error in the ntdll name here is intentional.
FileSearcherHelper.SearchForFileInEnvironmentVariable("PATH", "ntdll.dlll").Should().BeNull();
Expand All @@ -162,7 +164,7 @@ public void SearchForFileInEnvironmentVariable_WhenVariableAndFileExists()
}

[Fact]
public void GitExePath_WhenPathDoesntExist_SettingManuallyShouldWork()
public void GitExePath_WhenPathDoesNotExist_SettingManuallyShouldWork()
{
var mockFileSystem = new Mock<IFileSystem>();

Expand Down