Skip to content

Commit 28b350e

Browse files
committed
Change logic for autobuild failures
This is to account for multiple attempted rules that failed
1 parent dfcc57b commit 28b350e

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ BuildScript IntermediateAttempt(BuildScript s) =>
122122

123123
protected override void AutobuildFailureDiagnostic()
124124
{
125-
DiagnosticMessage message;
126-
127125
// if `ScriptPath` is not null here, the `BuildCommandAuto` rule was
128126
// run and found at least one script to execute
129127
if (this.buildCommandAutoRule is not null &&
130128
this.buildCommandAutoRule.ScriptPath is not null)
131129
{
130+
DiagnosticMessage message;
131+
132132
// if we found multiple build scripts in the project directory, then we can say
133133
// as much to indicate that we may have picked the wrong one;
134134
// otherwise, we just report that the one script we found didn't work
@@ -155,27 +155,23 @@ protected override void AutobuildFailureDiagnostic()
155155
"You can manually specify a suitable build command for your project."
156156
};
157157
}
158+
159+
message.Severity = DiagnosticMessage.TspSeverity.Error;
160+
Diagnostic(message);
158161
}
159162
// both dotnet and msbuild builds require project or solution files; if we haven't found any
160163
// then neither of those rules would've worked
161-
else if (this.ProjectsOrSolutionsToBuild.Count == 0)
164+
if (this.ProjectsOrSolutionsToBuild.Count == 0)
162165
{
163166
var source = GetDiagnosticSource("no-projects-or-solutions", "No project or solutions files found");
164-
message = new DiagnosticMessage(source)
167+
var message = new DiagnosticMessage(source)
165168
{
166-
PlaintextMessage = "CodeQL could not find any project or solution files in your repository."
169+
PlaintextMessage = "CodeQL could not find any project or solution files in your repository.",
170+
Severity = DiagnosticMessage.TspSeverity.Error
167171
};
168-
}
169-
else
170-
{
171-
// none of the above apply; produce a generic autobuild failure message
172-
base.AutobuildFailureDiagnostic();
173-
return;
174-
}
175172

176-
// all messages generated here are errors
177-
message.Severity = DiagnosticMessage.TspSeverity.Error;
178-
Diagnostic(message);
173+
Diagnostic(message);
174+
}
179175
}
180176

181177
/// <summary>

0 commit comments

Comments
 (0)