Private fields only used as local variables in methods should become local variables

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube * 8.9.7 (build 52159))
  • error observed ( “Private fields only used as local variables in methods should become local variables” code smells brings, when it shouldn’t be there)
  • steps to reproduce: Autowire any bean, and use it only in lambda expressions, you’ll get “code smell java:S1450”
  • potential workaround: we just mark it as a false positive, but it is preferable not to have this issue.

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Hi,

Welcome to the community!

Could you provide a self-contained code snipped to reproduce this with, please?

 
Ann