Re:Why Don't Software Developers Use Static Analysis Tools t...
by kwhitefoot on Saturday June 27, 2015 @07:20AM
(#9789818)
The problem with contracts and static analysis is that large projects are often so tangled up by the time that someone (me) applies contracts to them that the static analysis takes days or weeks of execution time.
I add the contracts anyway because they really do help find bugs at run time too and also act as executable comments.
Re:Why Don't Software Developers Use Static Analysis Tools t...
by Alphasite_ on Friday June 26, 2015 @06:41AM
(#9783426)
I don't know about code contracts, but IntelliJ does have an equivilent, if less advanced version of these as well, using Java annotations. Although it's mostly used for nullability/taint detection ATM.
ReSharper: you've enumerated this enumerable multiple times. This if statement is redundant. Basically stuff within the scope of a single method.
Code Contracts: you've passed an integer to this function. The function asks that you check that the integer falls into the length of the array that you are also passing in and that it's a multiple of two. Also, the function doesn't promise that it won't return a null value and you are using the result without checking it first. Basically looks at your entire project and can work out code paths across methods.
There's worlds of a difference. ReSharper is definitely useful, but doesn't come close to what proper static analysis can do. If you like what ReSharper is doing for your codebase I thoroughly recommend having a look at Code Contracts (it's a free Microsoft Research project).