Currently setting up a VB6 project to use SonarQube for Static Code Scanning and hitting a few VB Parser errors that look to be bugs.
Issue 1
The first issue is that the VB parser isn’t aware that in VB6 you can prefix a line of code with a line number and then use ErrLine when an error is raised to print what line had the error.
100 myVar = "some-text"
110 IF MyVar = "abc" THEN
120 'do somehting
130 END IF
Issue 2
The second issue is that the parser isn’t aware that the following line of VB6 code is valid and compiles:
"Close Files(i)"
Files(i) is an array element of type Long in my case. I had to substitute it for a variable I called lngFileNum to get the parser to parse the code file.
Issue 3
The thrid issue is the VB parser isn’t aware that you can use the colon ‘:’ char to write more than one stmt on same line. For example:
IF cond = True THEN: myVar = "some-text"
This again is valid and complies.
Issue 4
The forth issue is that the VB parser is unaware of special built-in graphic stmts you can do with a PictureBox control.
Scanner throws a parser error exception because of the use of the keyword step. This has a different meaning in the context of PictureBox graphics that’s different to the usage in a FOR loop.
Please can you advise how I go about raising a ticket to get the above issues fixed.
First things first, what version of SonarQube are you using?
Secondly, it would be a big help if you could separate your 4 concerns into 4 separate (individually, completely valid VB6) files that individually reproduce the parsing errors and upload that as a zip file.
I was able to reproduce all the parsing issue.
I have create a ticket for the first 2.
For the last 2 issues, I want to make sure I understand the syntaxes.
For issue 3, you can use the colon to separate any statements, is that correct?
For issue 4, is this syntax specific to the PictureBox control? Is there any other controls or types that have similar syntax? Is it always the same syntax?
I am not fluent in VB6 and I cannot figure out what is happening this example.
It would help us a lot, if you have any resources (e.g.: documentation) about those syntaxes!
Thanks for looking into the parser errors I reported.
There is this Microsoft page / resource that covers the VB6 language syntax and this specific page covers the Line syntax that was carried forward from the days of Basic before it became Visual Basic.
For issue 3, yes that’s correct as per the example I uploaded.
For issue 4, as per the link above will explain, Line is a special drawing function that can be applied objects that can be drawn on like PictureBox, Form, Image etc.
The SonarQube parser is able to accept the Line syntax, but it’s the use of the keyword Step that throws the parser. There is a link at the top of the page for the above web link that explains the Step keyword.
I did some more investigation on the statement separator, the parser should be aware of it. However, it does not expect it after an IF..THEN statement.
Anyway, I have created a ticket for each issues you reported.