Reports any variable declarations that can be moved to a smaller scope.

This inspection is especially useful for Pascal style declarations at the beginning of a method. Moreover, variables with a too broad scope also often remain after refactorings.

Example of sb movement:


  StringBuilder sb = new StringBuilder();
  System.out.println();
  sb.append(1);

After quick-fix is applied:


  System.out.println();
  StringBuilder sb = new StringBuilder();
  sb.append(1);

Configure the inspection: