mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Move nil check into FileDiagnosticsWriter implementation of WriteDiagnostic
This commit is contained in:
@@ -65,6 +65,10 @@ type FileDiagnosticsWriter struct {
|
||||
}
|
||||
|
||||
func (writer *FileDiagnosticsWriter) WriteDiagnostic(d diagnostic) {
|
||||
if writer == nil {
|
||||
return
|
||||
}
|
||||
|
||||
content, err := json.Marshal(d)
|
||||
if err != nil {
|
||||
slog.Error("Failed to encode diagnostic as JSON", slog.Any("err", err))
|
||||
@@ -142,9 +146,6 @@ func emitDiagnosticTo(writer DiagnosticsWriter, sourceid, sourcename, markdownMe
|
||||
|
||||
// Emits a diagnostic using the default `DiagnosticsWriter`.
|
||||
func emitDiagnostic(sourceid, sourcename, markdownMessage string, severity diagnosticSeverity, visibility *visibilityStruct, location *locationStruct) {
|
||||
if DefaultWriter == nil {
|
||||
return
|
||||
}
|
||||
emitDiagnosticTo(DefaultWriter, sourceid, sourcename, markdownMessage, severity, visibility, location)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user