integrated-application-development / sonar-delphi

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

False positive in `UnusedVariable` #251

Closed zedxxx closed 5 months ago

zedxxx commented 5 months ago

Delphi IDE version: Delphi 12.1

DelphiLint version: 1.1.0

SonarDelphi version: 1.6.0

2

unit Unit1;

interface

uses
  GR32,
  GR32_Polygons,
  GR32_VectorUtils;

procedure DrawThickPolyLine(ABitmap: TBitmap32; const APoints: TArrayOfFloatPoint;
  const AColor: TColor32; const AWidth: Integer);

implementation

procedure DrawThickPolyLine(ABitmap: TBitmap32; const APoints: TArrayOfFloatPoint;
  const AColor: TColor32; const AWidth: Integer);
var
  VPoly: TArrayOfFloatPoint;
begin
  VPoly := BuildPolyLine(APoints, AWidth);

  if not ABitmap.MeasuringMode then begin
    PolygonFS(ABitmap, VPoly, AColor);
  end;

  ABitmap.Changed(MakeRect(PolygonBounds(VPoly), rrOutside));
end;

end.
Cirras commented 5 months ago

Hi @zedxxx,

I can't seem to reproduce this UnusedVariable FP. (See image below)

Here's what I did:

The analyzer requires source code to perform type & invocation resolution, and things can go quite haywire if dependency source code isn't in the search path (or debugger source path).

One potential thing - do you only have the Graphics32 DCUs on your search path, and not the source files?

Cirras commented 5 months ago

See: https://github.com/integrated-application-development/sonar-delphi/issues/250#issuecomment-2159971922