Fix for missing results #234
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR suggests a fix for an issue some users are experiencing where results are missing from the 'problems' window in VS Code (#223).
Summary
There is loop with range
ito-1that I think should beito0(inclusive).Details
Sometimes linters (specifically cppcheck) return output for multiple files when asked to evaluate a specific file (e.g. evaluating a .c file returns issues with included .h files).
A loop in server.ts processes the results.
It loops over the array processing 1 file in each iteration.
After processing a result it is removed from the list (
result.splice(i, 1)).Eventually the list is empty.
There appears to be a bug with the loop range.
In
while (i-- >= 0)variableihas rangeresult.length-1to-1inclusive.When
iis-1it can remove a result from the list that is not marked for the current file (result.splice(-1, 1)).This causes missing items in the 'problems' window in VS Code.
Proposed fix: change the loop to
while (--i >= 0), then variableihas rangeresult.length-1to0inclusive.Simplified example
This is a simplified example of the loop in server.ts.
Output with
while (i-- >= 0)(misses 2 items):Output with
while (--i >= 0):Hotfix
You can easily apply this change to the release version (1.15.0) of the extension.
Open the following file:
~/.vscode/extensions/jbenden.c-cpp-flylint-1.15.0/server/out/server.js.vscodemight be.vscode-remoteor.vscode-server.Find: