lint for D

Ary Borenszweig ary at esperanto.org.ar
Thu Jul 10 03:53:54 PDT 2008


Bruce Adams a écrit :
> On Thu, 10 Jul 2008 02:44:07 +0100, Ary Borenszweig 
> <ary at esperanto.org.ar> wrote:
> 
>> Bruce Adams a écrit :
>>>  Hi all,
>>>        Alas this is not an announcement. It should be relatively easy 
>>> to knock up a few noddy scripts that can detect some kinds
>>> of potential problem.
>>
>> It should be relatively easy to write a plugin for Descent to do that. 
>> Something similar to FindBugs for Java ( 
>> http://findbugs.sourceforge.net/ ). Given a source file, you can ask 
>> Descent for it's AST with complete type resolution. You can apply the 
>> visitor pattern, which is supported by the AST nodes. You can store in 
>> a list which variables are declared, and then if they are used in a 
>> function or are written too, you eliminate them. The remaining entries 
>> in the list are the unused variables. It's a little harder for 
>> class/struct members, but it's still relatively easy.
>>
>> It is both helpful for a developer and for Descent, because the code 
>> that support that is kind of finished, but it isn't tested much (it's 
>> only used in highlighting code, which seems to work fine). Of course I 
>> could do that, but atm I'm adding support for D2, plus it would be 
>> interesting if anyone else could join the project.
> 
> This is a pet hate of mine. Tool should not be plug-ins for IDEs.

The thing is, you write all the code, then, from time to time you run 
that lint tool. You get 200 warnings. Will you want to correct them? 
Come on, those are just warnings, and 200 of them! Maybe there's no 
time, maybe it doesn't worth the effort. And you'd have to open up the 
code, remember what it was about, understanding it...

In an IDE: you finish writing a method. Even while writing at it, you 
get the warnings. It's easy to correct, you are there, staring at the 
code. It won't take your time, you have the code in your head, you know 
why the warning is there and how to remove it. And you do it.

Just my thought...



More information about the Digitalmars-d mailing list