Looking for a regular expression to identify hard coded magic numbers in source code

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2008-12-03T15:07:06Z Indexed on 2010/03/09 5:06 UTC
Read the original article Hit count: 367

Filed under:
|
|
|

A frequent issue in code reviews is whether a numeric value should be hard-coded in the code or not. Does anyone know of a nice regular expression that can catch 'magic numbers' in code like:

int overDue = 30;
Money fee = new Money(5.25D);

without also getting a ton of false positives like for loop initialization code?

for (int i = 0; i < array.length; i++) {

}

© Stack Overflow or respective owner

Related posts about regex

Related posts about java