java插件3.8 - S2583误报

时间:2015-12-03 10:33:47

标签: sonarqube

我认为我们发现了误报:

private static void copy(File from, File to) throws FileNotFoundException, IOException {
    FileChannel src = null;
    FileChannel dst = null;
    try {
        src = new FileInputStream(from).getChannel();
        dst = new FileOutputStream(to).getChannel();
        dst.transferFrom(src, 0, src.size());
    } finally {
        if (src != null) {
  

更改此条件,使其不会始终评估为“true”

还是我错过了什么? 另一个例子:

        if (lastUpdate == null|| lastUpdate != null && lastUpdate.before(new Date(System.currentTimeMillis() - 900000)))

1 个答案:

答案 0 :(得分:1)

你实际上是在问两个不同的案例:

  1. 你正在达到一个已知的限制https://jira.sonarsource.com/browse/SONARJAVA-1295我们计划在下一个java插件版本中修复这个(硬)。

  2. 这个实际上根本不是误报! :)如果您的变量lastUpdate为null,则条件为true而不评估||的右侧,如果为false,则lastUpdate != null将始终评估为true,因此您可以实际上删除它。