Java sonar qube规则的自动重构方法中仅用作局部变量的私有字段应成为局部变量

Java sonar qube规则的自动重构方法中仅用作局部变量的私有字段应成为局部变量,java,sonarqube,code-cleanup,automated-refactoring,Java,Sonarqube,Code Cleanup,Automated Refactoring,我们将SonarQube服务器用于一个大型java应用程序。(IDE=Eclipse+SonarLint插件)。大约有6000起案件违反了这项规定。是否有一种自动重构此问题的方法 例如: 实际情况: public class A { private JLabel lblText; ... public void foo() { lblText = new JLabel(); lblText.setText("Text"); mainPanel.addCompo

我们将SonarQube服务器用于一个大型java应用程序。(IDE=Eclipse+SonarLint插件)。大约有6000起案件违反了这项规定。是否有一种自动重构此问题的方法

例如:

实际情况:

public class A {
  private JLabel lblText;
  ...
  public void foo() {
    lblText = new JLabel();
    lblText.setText("Text");
    mainPanel.addComponent(lblText, 2, 1);
    ...
  }
...
}
重构后:

public class A {
  ...
  public void foo() {
    JLabel lblText = new JLabel();
    lblText.setText("Text");
    mainPanel.addComponent(lblText, 2, 1);
    ...
  }
...
}
我能自动做到这一点吗?手动处理6000个案例需要花费大量时间