views:

90

answers:

4

As a best practice, do you run code analysis on both debug and release builds, or just one or the other?

+1  A: 

I usually pick one and that one is the release build. I guess it doesn't really matter but I tend to think that when gather information about what will run in production it is best to test exactly what will go to production (this goes for analysis, profiling, benchmarking, etc.).

Andrew Hare
So in your project's build config, do you define CODE_ANALYSIS in the release build? Does that change the release build's output significantly or affect performance?
slolife
+1  A: 

Static Code Analysis will show the same results regardless of your build type.

Debug/Release only changes the resulting assembly and the inclusion or exclusion of debugging information at runtime.

Mitchel Sellers
right. and I guess you wouldn't care about the analysis of debug only code. makes sense.
scottmarlowe
This isn't completely true, a debug build will not be optimized by the compiler and may emit IL that will not be in a optimized release build.
Andrew Hare
@Andrew - True, I guess depending on how/where in the process the tool evaluates there could be some inlining and other optimizations that work in to release only builds.
Mitchel Sellers
+1  A: 

I don't have separate ‘debug’ and ‘release’ builds (see Separate ‘debug’ and ‘release’ builds?).

ChrisW
+1  A: 

If for some reason the two builds are different (and they really shouldn't be for static analysis purposes), you should ensure that your metrics are running against what's actually going out to production.

Ideally, you should have a CI server, and the commands that developers run to initiate such analysis are no different from what the CI server does.

John Feminella
Yep. The idea is to integrate the code analysis into the CI environment.
scottmarlowe