I got this warning on Sonar as a violation. I want proper solution to remove this warning from sonar.
My code is like this:
void method(){
try {
int x;
x=5;
}
catch{
//handling code
}
}
I got warning for this code like:
'5' is a magic number.
So, I want proper solution to remove such warning.
Magic number is the direct usage of the number in the code(i.e., hard-coded number in the code in your case using 5 directly)
to get rid of the warning try this: