Skip to content

Commit a44a86b

Browse files
committed
C#: Add alert suppression comments. Rename e to ex in catch clauses for consistency.
1 parent fb0cae8 commit a44a86b

File tree

14 files changed

+31
-31
lines changed

14 files changed

+31
-31
lines changed

csharp/autobuilder/Semmle.Autobuild/Project.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public Project(Autobuilder builder, string path) : base(builder, path)
3939
{
4040
projFile = builder.Actions.LoadXml(FullPath);
4141
}
42-
catch (Exception e) when (e is XmlException || e is FileNotFoundException)
42+
catch (Exception ex) when (ex is XmlException || ex is FileNotFoundException)
4343
{
4444
builder.Log(Severity.Info, $"Unable to read project file {path}.");
4545
return;

csharp/autobuilder/Semmle.Autobuild/Solution.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Solution(Autobuilder builder, string path, bool allowProject) : base(buil
6363
{
6464
solution = SolutionFile.Parse(FullPath);
6565
}
66-
catch (Exception e) when (e is InvalidProjectFileException || e is FileNotFoundException)
66+
catch (Exception ex) when (ex is InvalidProjectFileException || ex is FileNotFoundException)
6767
{
6868
// We allow specifying projects as solutions in lgtm.yml, so model
6969
// that scenario as a solution with just that one project

csharp/extractor/Semmle.Extraction.CIL/Entities/Assembly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static void ExtractCIL(Layout layout, string assemblyPath, ILogger logger
143143
}
144144
}
145145
}
146-
catch (Exception ex)
146+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
147147
{
148148
logger.Log(Severity.Error, string.Format("Exception extracting {0}: {1}", assemblyPath, ex));
149149
}

csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void AnalyseProjectFiles(FileInfo[] projectFiles)
283283
}
284284
++succeededProjects;
285285
}
286-
catch (Exception ex)
286+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
287287
{
288288
++failedProjects;
289289
progressMonitor.FailedProjectFile(proj.FullName, ex.Message);

csharp/extractor/Semmle.Extraction.CSharp.Standalone/NugetPackages.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ void RestoreNugetPackage(string package, IProgressMonitor pm)
183183
}
184184
}
185185
}
186-
catch (Exception e)
187-
when (e is System.ComponentModel.Win32Exception || e is FileNotFoundException)
186+
catch (Exception ex)
187+
when (ex is System.ComponentModel.Win32Exception || ex is FileNotFoundException)
188188
{
189-
pm.FailedNugetCommand(pi.FileName, pi.Arguments, e.Message);
189+
pm.FailedNugetCommand(pi.FileName, pi.Arguments, ex.Message);
190190
}
191191
}
192192

csharp/extractor/Semmle.Extraction.CSharp/Analyser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void SetReferencePaths()
9797
extractor.SetAssemblyFile(assemblyIdentity, refPath);
9898
}
9999
}
100-
catch (Exception ex)
100+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
101101
{
102102
extractor.Message(new Message
103103
{
@@ -272,7 +272,7 @@ void DoAnalyseAssembly(PortableExecutableReference r)
272272
ReportProgress(assemblyPath, trapWriter.TrapFile, stopwatch.Elapsed, skipExtraction ? AnalysisAction.UpToDate : AnalysisAction.Extracted);
273273
}
274274
}
275-
catch (Exception ex)
275+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
276276
{
277277
Logger.Log(Severity.Error, " Unhandled exception analyzing {0}: {1}", r.FilePath, ex);
278278
}
@@ -354,7 +354,7 @@ void DoExtractTree(SyntaxTree tree)
354354

355355
ReportProgress(sourcePath, trapPath, stopwatch.Elapsed, excluded ? AnalysisAction.Excluded : upToDate ? AnalysisAction.UpToDate : AnalysisAction.Extracted);
356356
}
357-
catch (Exception ex)
357+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
358358
{
359359
extractor.Message(new Message { exception = ex, message = string.Format("Unhandled exception processing {0}: {1}", tree.FilePath, ex), severity = Severity.Error });
360360
}

csharp/extractor/Semmle.Extraction.CSharp/Extractor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ public static ExitCode Run(string[] args)
165165

166166
return analyser.TotalErrors == 0 ? ExitCode.Ok : ExitCode.Errors;
167167
}
168-
catch (Exception e)
168+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
169169
{
170-
logger.Log(Severity.Error, " Unhandled exception: {0}", e);
170+
logger.Log(Severity.Error, " Unhandled exception: {0}", ex);
171171
return ExitCode.Errors;
172172
}
173173
}
@@ -354,9 +354,9 @@ public static void ExtractStandalone(
354354

355355
pm.MissingSummary(analyser.MissingTypes.Count(), analyser.MissingNamespaces.Count());
356356
}
357-
catch (Exception e)
357+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
358358
{
359-
analyser.Logger.Log(Severity.Error, " Unhandled exception: {0}", e);
359+
analyser.Logger.Log(Severity.Error, " Unhandled exception: {0}", ex);
360360
}
361361
}
362362
}

csharp/extractor/Semmle.Extraction.CSharp/Populators/Ast.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public static void Extract(this Context cx, CSharpSyntaxNode node, IExpressionPa
5454
{
5555
node.Accept(new Ast(cx, parent, child));
5656
}
57-
catch (System.Exception e)
57+
catch (System.Exception ex) // lgtm[cs/catch-of-all-exceptions]
5858
{
59-
cx.ModelError(node, "Exception processing syntax node of type {0}: {1}", node.Kind(), e);
59+
cx.ModelError(node, "Exception processing syntax node of type {0}: {1}", node.Kind(), ex);
6060
}
6161
}
6262
}

csharp/extractor/Semmle.Extraction.CSharp/Populators/Symbols.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public static IEntity CreateEntity(this Context cx, ISymbol symbol)
5555
{
5656
return symbol.Accept(new Symbols(cx));
5757
}
58-
catch (Exception e)
58+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
5959
{
60-
cx.ModelError(symbol, "Exception processing symbol '{2}' of type '{0}': {1}", symbol.Kind, e, symbol);
60+
cx.ModelError(symbol, "Exception processing symbol '{2}' of type '{0}': {1}", symbol.Kind, ex, symbol);
6161
return null;
6262
}
6363
}

csharp/extractor/Semmle.Extraction/Context.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ public void PopulateAll()
216216
{
217217
populateQueue.Dequeue()();
218218
}
219-
catch (InternalError e)
219+
catch (InternalError ex)
220220
{
221-
Extractor.Message(e.ExtractionMessage);
221+
Extractor.Message(ex.ExtractionMessage);
222222
}
223-
catch (Exception e)
223+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
224224
{
225-
Extractor.Message(new Message { severity = Severity.Error, exception = e, message = "Uncaught exception" });
225+
Extractor.Message(new Message { severity = Severity.Error, exception = ex, message = "Uncaught exception" });
226226
}
227227
}
228228
}
@@ -504,7 +504,7 @@ static public void Try(this Context context, SyntaxNode node, ISymbol symbol, Ac
504504
{
505505
a();
506506
}
507-
catch (Exception ex)
507+
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
508508
{
509509
var internalError = ex as InternalError;
510510
var message = internalError != null

0 commit comments

Comments
 (0)