integrated-application-development / sonar-delphi

Delphi language plugin for SonarQube
GNU Lesser General Public License v3.0
104 stars 17 forks source link

Scan errors when defining a type with the same name of an imported unit #161

Closed FLuzzi-csw closed 9 months ago

FLuzzi-csw commented 10 months ago

Prerequisites

SonarDelphi version

1.1.0

SonarQube version

9.9.3

Issue description

Problem

When defining a type called the same as an imported library, sonar-delphi scan crashes. This happens even if sonar.delphi.unitScopeNames is correctly populated.

Expected

A rule catching this code smell Related to #62

Steps to reproduce

type TSample = class(TObject) private end;

Windows = TSample;

begin try Writeln('Hello World!'); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.



- The execution will raise the exception:
  `au.com.integradev.delphi.symbol.scope.DuplicatedDeclarationException: Windows is already in the symbol table`

### Minimal Delphi code exhibiting the issue

[SonarQube_test.zip](https://github.com/integrated-application-development/sonar-delphi/files/13917240/SonarQube_test.zip)

Inside the zip there is a `sonar.log` file containing all the execution output in debug mode
Cirras commented 10 months ago

Hi @FLuzzi-csw,

Thanks for the bug report! @fourls actually ran across this problem just today while working on some new internal QA checks for the analyzer.

This one is high priority, so we'll have it fixed soon.

fourls commented 10 months ago

Can confirm I encountered this today! From my initial analysis, it shouldn't be too tricky to fix.

FLuzzi-csw commented 10 months ago

What a coincidence! Thanks for the fast response 👍