Static Analysis Tooling / Effective D

Walter Bright newshound2 at digitalmars.com
Tue Jan 21 01:28:54 PST 2014


On 1/20/2014 8:34 PM, Brian Schott wrote:
> I've checked in code to the DScanner project that gives it some basic static
> analysis capabilities. When run with the --styleCheck option, it will warn about
> a few things like empty declarations, implicit string concatenation, classes
> with lowercase_names, catching "Exception", and a few other things.
>
> There's a small feature wishlist in the project's README, but I'd like to get
> some opinions from the newsgroup: What kinds of errors have you seen in your
> code that you think a static analysis tool could help with?

Sooner or later, you're going to want to add data flow analysis. DFA will open 
up a universe of useful checks it can do. For example, you can do things like:

class C { int x; }
C foo() { return null; }
int bar(int i) {
     auto c = i ? foo() : new C();
     return c.x;        // error, path to null dereference
}

and a heckuva lot more.

For a laundry list, google Coverity and look at the bug reports it generates. 
Many of the reports have no meaning for D, as D has defined them out of 
existence, but there are plenty of others.


More information about the Digitalmars-d mailing list