mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Fix a few alerts
This commit is contained in:
@@ -185,7 +185,7 @@ namespace Semmle.Extraction.Tests
|
||||
|
||||
class StringTrapEmitter : ITrapEmitter
|
||||
{
|
||||
string Content;
|
||||
readonly string Content;
|
||||
public StringTrapEmitter(string content)
|
||||
{
|
||||
Content = content;
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Semmle.Extraction.Tests
|
||||
[Fact]
|
||||
public void ArchiveArguments()
|
||||
{
|
||||
var sw = new StringWriter();
|
||||
using var sw = new StringWriter();
|
||||
var file = Path.GetTempFileName();
|
||||
|
||||
try
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
class GeneratedLocationFactory : ICachedEntityFactory<string?, GeneratedLocation>
|
||||
{
|
||||
public static GeneratedLocationFactory Instance = new GeneratedLocationFactory();
|
||||
public static readonly GeneratedLocationFactory Instance = new GeneratedLocationFactory();
|
||||
|
||||
public GeneratedLocation Create(Context cx, string? init) => new GeneratedLocation(cx);
|
||||
}
|
||||
|
||||
@@ -21,15 +21,7 @@ namespace SemmleTests.Semmle.Util
|
||||
// Change directories to a directory that is in canonical form.
|
||||
Directory.SetCurrentDirectory(cache.GetCanonicalPath(Path.GetTempPath()));
|
||||
|
||||
if (Win32.IsWindows())
|
||||
{
|
||||
root = @"X:\";
|
||||
}
|
||||
else
|
||||
{
|
||||
root = "/";
|
||||
}
|
||||
|
||||
root = Win32.IsWindows() ? @"X:\" : "/";
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
@@ -143,10 +135,10 @@ namespace SemmleTests.Semmle.Util
|
||||
Assert.Equal(0, cache.CacheSize);
|
||||
|
||||
// The file "ABC" will fill the cache with parent directory info.
|
||||
string cp = cache.GetCanonicalPath("ABC");
|
||||
cache.GetCanonicalPath("ABC");
|
||||
Assert.True(cache.CacheSize == 2);
|
||||
|
||||
cp = cache.GetCanonicalPath("def");
|
||||
string cp = cache.GetCanonicalPath("def");
|
||||
Assert.Equal(2, cache.CacheSize);
|
||||
Assert.Equal(Path.GetFullPath("def"), cp);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace SemmleTests.Semmle.Util
|
||||
Assert.Equal("def", File.ReadAllText(shortPath));
|
||||
}
|
||||
|
||||
byte[] buffer1 = new byte[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
readonly byte[] buffer1 = new byte[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
[Fact]
|
||||
public void CreateShortStream()
|
||||
|
||||
Reference in New Issue
Block a user