sonar-delphi
sonar-delphi copied to clipboard
Inconsitent unused const when using const inline
Prerequisites
- [X] This bug is in SonarDelphi, not SonarQube or my Delphi code.
- [X] This bug has not already been reported.
SonarDelphi version
1.8.0
SonarQube version
v10.5.1
Issue description
Plugin is raising an erroneous issue when using const inline.
Steps to reproduce
const lValue: integer = 0; //<-- unused const SomeMethod(lValue); //
Minimal Delphi code exhibiting the issue
const ldmServiceOrdemPagamento = TdmServiceOrdemPagamento.Create();
try
try
const lID = pRequest.Params.Field('id').AsString; //sonar plugin is raising an issue here saying unused const
if ldmServiceOrdemPagamento.Cancelar(lID) then
begin
pResponse.Status(THTTPStatus.Accepted);
end else
begin
raise EHorseException.New.Error('Não foi possivel cancelar a ordem de serviço.').Status(THTTPStatus.NotAcceptable);
end;
except
on E: EErrorBadRequest do
begin
Log.Error(E);
raise EHorseException.New.Error(E.Message).Title('Error').status(THTTPStatus.BadRequest);
end;
on E: Exception do
begin
Log.Error(E);
raise;
end;
end;
finally
ldmServiceOrdemPagamento.Free();
end;