False positive for "useless assignment"

I am getting a “useless assignment” for this chunk of code (class names have been renamed) on path which is clearly wrong:

            Path path = pathGenerator.get();
            return new AutoDeletingData(path, DataFactory.getData(path));
        catch (IOException e)
            throw e;
        catch (Exception e)
            throw new IOException("Unable to create path containing data", e);

This was in IDEA 2019.3 with SonarLint

I also see this on code like this as well for existingData.

            Data existingData = getData(itemPath);
            if (existingData != null)
                // Binary exists.
                return existingData;

Hello @sits, welcome to SonarSource community!

First, you are talking about RSPEC-1854 (Unused assignments), correct? I’m asking because RSPEC-1481 (Unused local variables) is closely related to this rule, and I want to make sure we are talking about the right one.

Then, I did not manage to reproduce on my side the issue you are facing, for none of the two examples. I’m afraid the example is missing some types (AutoDeletingData, Data). Could you try to provide a fully contained reproducer, raising the issue on your side?

In addition, are you using SonarLint connected mode (connected to a SonarQube instance)? If yes, what version of SonarQube are you using?