Incorrect triggering of java deprecated method usage, S1874

We suddenly got ~2k new issues in our java project which were all S1874 “use of deprecated methods”. The only problem is that these methods are not deprecated. However, the method names and classes are the same as some others that are deprecated. I’m wondering if the rule detection method resolution logic was somehow broken recently. Our builds are running in sonar cloud.

Hi,

Welcome to the community!

Can you check your job logs and make sure the class files and libraries are still available to analysis. This class confusion makes me think the binaries weren’t available.

 
HTH,
Ann

what exactly would i look for in the job logs?

for reference, nothing has changed recently in our build pipeline, so i’m unsure why libraries would suddenly be unavailable. not to mention, i’d think much more would go wrong if these libraries where not found.

Hi,

Can you post your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

sonar_analysis.log (38.2 KB)

Hi,

This is telling me there was a problem with the data provided to analysis (e.g. classes and/or libs):

[WARNING] 16:02:36.778 Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
...
[WARNING] 16:03:03.870 Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
...
[WARNING] 16:03:06.843 Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
...
[WARNING] 16:05:09.558 Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
...
[WARNING] 16:05:38.376 Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
...

 
HTH,
Ann

hmm, interesting. i’ll see if can get some debug output there.

1 Like

so i enabled debugging. i learned a couple of interesting things, but not sure it got me anywhere.

  1. the classes which weren’t found were not related to the deprecation warnings
  2. the classes which weren’t found were random classes which are part of our codebase. it seems as if those classes truly were not available, there would be a whole lot more problems. also, while not exclusively true, the types of classes which were not found tended towards records and inner classes.

Hi,

There is something weird going on with your build. I don’t know what it is, or where to point you beyond what I’ve already suggested, but this needs to be sorted out. I’m fairly confident that doing so will take care of the ‘deprecated methods’ problem.

 
HTH,
Ann

interestingly enough, with no changes on our end to how we run sonar, sonar closed all those deprecation warnings a few days ago.

1 Like