lint for D

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sun Jul 27 08:10:57 PDT 2008


Ary Borenszweig wrote:
> 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...

Ah, c'mon Ary, there is a reason why Eclipse IDE code is divided into 
.core and .ui plugins ;).

Yes, it is much better to see warnings while you are writing in the 
editor, instead of watching them all at once from the console.
But that doesn't invalidate the usefulness of being able to run some 
code analysis functionality from the command-line. One example is 
continuous integration, where one would like to automatically generate 
warnings for committed code, and them process that in some kind of 
report. It not one of those super-cool functionalities, but I do see 
some usefulness.



-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list