Edit BASIC heuristic to avoid false positives + new sample #6320
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.
There is currently at least 2 occurences of false positives with the BASIC heuristic (
'^\s*\d+'
) introduced in #5166:If a VBA file contains line numbers, it will automatically be identified as BASIC. It is not that common for VBA code to have line numbers, but some people like to use them to improve error reporting.
eg. https://github.com/Sven-Bo/Integrate-ChatGPT-in-Excel-using-VBA/blob/master/mChatGPT.bas#L34
In VBA (or VB6), an underscore can be used as a line continuation character which means that lines can be split and there is the possibility that a number ends up being the first thing on the second line thus matching with the heuristic.
eg. https://github.com/dragokas/hijackthis/blob/7560e67b5e0d14f53ea25bbfb88587cbfadca1c8/src/modPermissions.bas#L905
The good thing is that both of these issues can't happen at the start of the file because you can't have line numbering outside of a procedure in VBA and it can't be a line continuation if it's the start of the file (obviously).
Hence, I'm proposing to add
\A
at the start of the heuristic (which gives^\A\s*\d+
) and I also added a sample so that we have two samples for BASIC with the.bas
extension.Description
Checklist: