A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3686 below:

[java] ReturnEmptyCollectionRatherThanNull - false negative with conditioned returns · Issue #3686 · pmd/pmd · GitHub

Affects PMD Version:6.41.0

Rule:ReturnEmptyCollectionRatherThanNull

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull

Description:
Hi, I think this rule should have reported warning about the following case, but it doesn't. I think this problem is caused by wrapped return null statemnet and it could be solved by matching.

Code Sample demonstrating the issue:

public int[] foo() {  
  if(true) {
      return null;  // should report a warning here, but no warnings
  } else {
      return null;
  }
}

Expected outcome:

PMD should report a violation at line 3 or 5, but doesn't. This is a false-negative.

Running PMD through: [CLI]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4