Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding magic numbers using NDepend

Does anyone know how I could find magic numbers in the source code using the CQL queries in NDepend? This is the same problem as this question, but I don't want to use regex if possible.

So I want to find all statements like

Int32 someValue = 23;
Double anotherValue = 1;

but not

for (int i = 0; i < array.length; i++)
like image 346
Joel in Gö Avatar asked Apr 08 '26 07:04

Joel in Gö


2 Answers

I confirm, currently NDepend and CQLinq cannot help with that. I would advise you do a small app using Mono.Cecil, and search for magic numbers and strings. You'll see, Mono.Cecil API rocks!

like image 100
Patrick from NDepend team Avatar answered Apr 11 '26 00:04

Patrick from NDepend team


It's a nice idea but I'm pretty certain you can't do it as there is no way to query inititialisation values in CQL.

like image 40
Andy Dent Avatar answered Apr 11 '26 02:04

Andy Dent