SonarJS icon indicating copy to clipboard operation
SonarJS copied to clipboard

Fix FP for S3800, return types `"stream".Readable` and `"stream".PassThrough` treated as unrelated.

Open andrey-tyukin-sonarsource opened this issue 4 years ago • 0 comments

A FP for S3800 is reported in the ruling integration tests in jshint/tests/helpers/browser/server.js for the following code snippet:

function(filename) {
      var faker;
      if (filename === mainPath) {
        includedFaker = true;
        faker = new Stream.Readable();                         
        faker._read = faker.write = function() {};
        faker.push("exports.JSHINT = window.JSHINT;");
        faker.push(null);
        return faker; // "stream".Readable
      }
      return new Stream.PassThrough(); // "stream".PassThrough <: "stream".Readable
    }

The return types are reported as "different", despite the fact that the least upper bound is "stream".Readable, which is much more specific than any.