VB Parser Scanner Bugs

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.

"picCalendar.Line (x, Y)-Step(szX, szY), vbWhite, BF"

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.

Thanks.

1 Like

Hey there.

Thanks for the reports!

  • 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.

Hi Colin,

I’m using the following:

  • SonarScanner CLI 7.0.2.4839
  • SonarQube Server 2025.1.0.102418

I’ll prepare you the 4 sample files for you to test with as soon as I can.

Paul.

1 Like

Hi Colin,

As promised, I’ve prepared and uploaded 4 zip files covering the 4 Issues I outlined in my initial post.

I’ve tested the 4 examples and the parser raises an “Unable to parse file” error per each file.

Happy testing.
ModCloseFileArrayIssue2.zip (426 Bytes)
ModErrLineNumberIssue1.zip (585 Bytes)
ModStmtJoinIssue3.zip (387 Bytes)
PictureBoxLineStepIssue4.zip (732 Bytes)

2 Likes

Thanks. I’m passing them onto the right team (who I’m sure will be just tickled to touch this analyzer :sweat_smile:)

Many thanks Colin.

1 Like

Hello @pmaguire,

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!

Thank you,

Hi sebastien,

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.

Drawing Lines and Shapes | Microsoft Learn

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.

This should hopefully explain what you need.

Thank you @pmaguire! :pray:

I have all the information I needed.

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.

Have a good day!

1 Like