11

アサーション (前提条件) で使用されているため、Eclipse が「未使用」変数を報告しないため、「隠れた」バグがありました。次に例を示します。

public void method(final String text, ...other parameters) {
  assert StringUtils.isNotBlank(text);
  ...
  // The text variable is never used in the method.
  // If Eclipse had reported the variable as 'unused' I would have noticed that something is wrong with the code.
  ...
}

未使用の変数をチェックするときにアサーションを無視するように Eclipse に指示したいと思います。アサーションを実行するためだけにパラメーターを渡す人がいるとは思えません...また、FindBugsまたは別のツールがこれを実行できるかどうかも教えてください。

4

1 に答える 1