Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleaning uses clauses in Delphi

Tags:

delphi

uses

I've been using cnPack and PascalAnalyzer Lite to clean up the uses clauses in some large projects, and I'm doing it rather conservatively. In particular I'm not removing anything that has an initialization section. PascalAnayser gives hints such as

  ==> COMMAND unnecessary (used by unit with init)

I assume this is saying that this unit is not used by the current unit, but it is used by a unit that has an initialization section.

Is this unit COMMAND completely safe to remove or is there some situation where removing it might cause some sort of run-time error?

like image 944
Alister Avatar asked Jun 17 '18 21:06

Alister


1 Answers

You can safely remove that unit.

That hint is just there out of consistency, to give you some more information - although that information is irrelevant to the decision whether that unit can be removed from the uses clause, can be moved to the implementation section or has to stay where it is.

In case you are trying to get rid of that unit, you now know that you have to check that unit with initialization: Does it actually need that unnecessary unit or can it perhaps be removed safely itself?

As you already mentioned: it is just a hint - it doesn't invalidate the unnecessary mark.

like image 160
Uwe Raabe Avatar answered Nov 10 '22 12:11

Uwe Raabe