mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
C#: Fix quality issues
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Semmle.Extraction
|
||||
// A recursion guard against writing to the trap file whilst writing an id to the trap file.
|
||||
private bool writingLabel = false;
|
||||
|
||||
private readonly Queue<IEntity> labelQueue = new();
|
||||
private readonly Queue<IEntity> labelQueue = [];
|
||||
|
||||
protected void DefineLabel(IEntity entity)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Semmle.Extraction
|
||||
default:
|
||||
wrapped.Write(c);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteSubId(IEntity entity)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Semmle.Extraction
|
||||
|
||||
// Roslyn framework has no apparent mechanism to associate assemblies with their files.
|
||||
// So this lookup table needs to be populated.
|
||||
private readonly Dictionary<string, string> referenceFilenames = new Dictionary<string, string>();
|
||||
private readonly Dictionary<string, string> referenceFilenames = [];
|
||||
|
||||
public void SetAssemblyFile(string assembly, string file)
|
||||
{
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Semmle.Extraction
|
||||
if (!Valid)
|
||||
throw new InvalidOperationException("Attempt to use an invalid label");
|
||||
|
||||
return "#" + Value;
|
||||
return $"#{Value}";
|
||||
}
|
||||
|
||||
public static bool operator ==(Label l1, Label l2) => l1.Value == l2.Value;
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Semmle.Extraction
|
||||
{
|
||||
var ret = value;
|
||||
if (ret.Length >= 2 && ret[1] == ':' && Char.IsLower(ret[0]))
|
||||
ret = Char.ToUpper(ret[0]) + "_" + ret.Substring(2);
|
||||
ret = $"{char.ToUpper(ret[0])}_{ret[2..]}";
|
||||
return ret.Replace('\\', '/').Replace(":", "_");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Semmle.Extraction
|
||||
|
||||
writerLazy = new Lazy<StreamWriter>(() =>
|
||||
{
|
||||
var tempPath = trap ?? FileUtils.GetTemporaryWorkingDirectory(out var _);
|
||||
var tempPath = trap ?? FileUtils.GetTemporaryWorkingDirectory(out _);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -139,7 +139,7 @@ namespace Semmle.Extraction
|
||||
// - the same file was compiled multiple times, or
|
||||
// - the file doesn't exist (due to wrong #line directive or because it's an in-memory source generated AST).
|
||||
// In any case, this is not a fatal error.
|
||||
logger.LogWarning("Problem archiving " + dest + ": " + ex);
|
||||
logger.LogWarning($"Problem archiving {dest}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user