From reading your question I'd say it's because it's a difficult question to understand. Not impossible, but it takes a bit of effort on the readers part to interpret what information you want to know. That in itself can put potential answerers off. Let me explain:
In your question you refer often to Sonar, and talk about a "rule violation". Yet your question appears to be about run-time optimisation - specifically whether or not there is a difference in execution time between
public class MyClass{
MyType object;
public void myMethod(){
object= aMethod(arg); //Returns instance for the class MyType
}
}
and
public class MyClass{
public void myMethod(){
MyType object= aMethod(arg); //Returns instance for the class MyType
}
}
With a small follow-up question along the lines of "Sonar is telling me to do it the second way, why?"
Or at least that's what it reads to me like you're asking. But I cannot be sure because you don't even state what you're comparing your code to, you just saying that "Sonar is telling me to" etc etc. That's not a clear way to phrase your question.