File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -278,12 +278,12 @@ async function runCppcheckOnFileXML(
278278 const mainLoc = locations . length ? locations [ locations . length - 1 ] ?. $ : [ ] ;
279279
280280 // If main location is not current file, then skip displaying warning unless it is critical
281- if ( ! isCriticalError && ! filePath . endsWith ( mainLoc . file ) ) {
281+ if ( ! isCriticalError && ! filePath . endsWith ( mainLoc ? .file ) ) {
282282 continue ;
283283 }
284284
285285 // Cppcheck line number is 1-indexed, while VS Code uses 0-indexing
286- let line = Number ( mainLoc . line ) - 1 ;
286+ let line = Number ( mainLoc ? .line ?? 0 ) - 1 ;
287287 // Invalid line number usually means non-analysis output
288288 if ( isNaN ( line ) || line < 0 || line >= document . lineCount ) {
289289 if ( isCriticalError ) {
@@ -294,7 +294,7 @@ async function runCppcheckOnFileXML(
294294 }
295295
296296 // Cppcheck col number is 1-indexed, while VS Code uses 0-indexing
297- let col = Number ( mainLoc . column ) - 1 ;
297+ let col = Number ( mainLoc ? .column ?? 0 ) - 1 ;
298298 if ( isNaN ( col ) || col < 0 || col > document . lineAt ( line ) . text . length ) {
299299 col = 0 ;
300300 }
You can’t perform that action at this time.
0 commit comments