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
|
class StringTrapEmitter : ITrapEmitter
|
||||||
{
|
{
|
||||||
string Content;
|
readonly string Content;
|
||||||
public StringTrapEmitter(string content)
|
public StringTrapEmitter(string content)
|
||||||
{
|
{
|
||||||
Content = content;
|
Content = content;
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ namespace Semmle.Extraction.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void ArchiveArguments()
|
public void ArchiveArguments()
|
||||||
{
|
{
|
||||||
var sw = new StringWriter();
|
using var sw = new StringWriter();
|
||||||
var file = Path.GetTempFileName();
|
var file = Path.GetTempFileName();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Semmle.Extraction.Entities
|
|||||||
|
|
||||||
class GeneratedLocationFactory : ICachedEntityFactory<string?, GeneratedLocation>
|
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);
|
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.
|
// Change directories to a directory that is in canonical form.
|
||||||
Directory.SetCurrentDirectory(cache.GetCanonicalPath(Path.GetTempPath()));
|
Directory.SetCurrentDirectory(cache.GetCanonicalPath(Path.GetTempPath()));
|
||||||
|
|
||||||
if (Win32.IsWindows())
|
root = Win32.IsWindows() ? @"X:\" : "/";
|
||||||
{
|
|
||||||
root = @"X:\";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
root = "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
void IDisposable.Dispose()
|
||||||
@@ -143,10 +135,10 @@ namespace SemmleTests.Semmle.Util
|
|||||||
Assert.Equal(0, cache.CacheSize);
|
Assert.Equal(0, cache.CacheSize);
|
||||||
|
|
||||||
// The file "ABC" will fill the cache with parent directory info.
|
// The file "ABC" will fill the cache with parent directory info.
|
||||||
string cp = cache.GetCanonicalPath("ABC");
|
cache.GetCanonicalPath("ABC");
|
||||||
Assert.True(cache.CacheSize == 2);
|
Assert.True(cache.CacheSize == 2);
|
||||||
|
|
||||||
cp = cache.GetCanonicalPath("def");
|
string cp = cache.GetCanonicalPath("def");
|
||||||
Assert.Equal(2, cache.CacheSize);
|
Assert.Equal(2, cache.CacheSize);
|
||||||
Assert.Equal(Path.GetFullPath("def"), cp);
|
Assert.Equal(Path.GetFullPath("def"), cp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace SemmleTests.Semmle.Util
|
|||||||
Assert.Equal("def", File.ReadAllText(shortPath));
|
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]
|
[Fact]
|
||||||
public void CreateShortStream()
|
public void CreateShortStream()
|
||||||
|
|||||||
Reference in New Issue
Block a user