SAP / ui5-linter

A static code analysis tool for UI5
Apache License 2.0
41 stars 0 forks source link

Line/column position of deprecations is inaccurate #94

Closed matz3 closed 1 month ago

matz3 commented 2 months ago

Expected Behavior

Findings should be reported at the exact place where they are in the code. More specifically, findings for different functions should not be reported at the exact same line/column position.

Background

Some tools or IDEs only display one finding per line/column, which currently prevents some findings from being displayed. One example of this are the tasks in VS Code, which can be used to display problems based on the output of a task, like running ui5lint.

Example

The code

sap.ui.getCore().attachInit(() => {});

should create two findings

[
  {
    "filePath": "webapp/Test.js",
    "messages": [
      {
        "ruleId": "ui5-linter-no-deprecated-api",
        "severity": 2,
        "line": 1,
        "column": 18,
        "message": "Call to deprecated function 'attachInit' of class 'Core'"
      },
      {
        "ruleId": "ui5-linter-no-deprecated-api",
        "severity": 2,
        "line": 1,
        "column": 8,
        "message": "Call to deprecated function 'getCore' (sap.ui.getCore)"
      }
    ],
    "errorCount": 2,
    "warningCount": 0,
    "fatalErrorCount": 0
  }
]

Current Behavior

Both findings point to column 1

[
  {
    "filePath": "webapp/Test.js",
    "messages": [
      {
        "ruleId": "ui5-linter-no-deprecated-api",
        "severity": 2,
        "line": 1,
        "column": 1,
        "message": "Call to deprecated function 'attachInit' of class 'Core'"
      },
      {
        "ruleId": "ui5-linter-no-deprecated-api",
        "severity": 2,
        "line": 1,
        "column": 1,
        "message": "Call to deprecated function 'getCore' (sap.ui.getCore)"
      }
    ],
    "errorCount": 2,
    "warningCount": 0,
    "fatalErrorCount": 0
  }
]

Steps to Reproduce the Issue

See example above.

Context

Log Output / Stack Trace

See above.

flovogt commented 1 month ago

Looks like this issue is related to https://github.com/SAP/ui5-linter/issues/103