SAP / ui5-linter

A static code analysis tool for UI5
Apache License 2.0
47 stars 4 forks source link

Missing detection of dependency to deprecated modules that export an interface #86

Closed matz3 closed 1 month ago

matz3 commented 5 months ago

Expected Behavior

Declaring a dependency to a deprecated module (e.g. via sap.ui.define) should yield an error, even when no API of that module is being used.

Current Behavior

Declaring a dependency to a deprecated module which exports an interface (e.g. sap.ui.core.Configuration) does not yield an error.

I suspect that this is related to check for symbol.valueDeclaration and the different behavior for interfaces. The valueDeclaration can be undefined. This happens when there are no declarations associated with a symbol that could hold a value. If a symbol only represents an interface declaration, valueDeclaration would be undefined because an interface itself cannot hold a value. The code should probably check for all declarations of the symbol (symbol.getDeclarations()).

Steps to Reproduce the Issue

Run ui5lint for this code:

sap.ui.define(["sap/ui/core/Configuration"]);

Context

Log Output / Stack Trace

UI5 linter report:

0 problems (0 errors, 0 warnings)
flovogt commented 4 months ago

@matz3 created https://github.com/SAP/ui5-linter/compare/main...improve-import-declaration-deprecation-checks which is a PoC to tackle this. Lets discuss this in the team and discuss missing steps.

matz3 commented 4 months ago

No exactly. It might contain details that are also relevant in here, but it tries to solve a different issue (which is not reported in this repo yet). That issue is: library modules are not detected as deprecated when all their exports are deprecated (e.g. sap/ui/commons/library) and I would rank it's priority a bit lower than this issue here about exported interfaces.