Module file paths in the JSON report are only file names

Open Beginner friendly
#152 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
devtools

Research direction

The bug is in the JSON scan report at target/report/scan_results.json, where location.filePath holds only the file name for module documents. Reproduce it with a package that has modules/db/db.bal and check the output. Compare with how the SARIF report builds its module-relative path, and make the JSON location use the same package-relative path. Done when location.filePath reads modules/db/db.bal and two same-named files in different modules are distinct.

Written by the indexing model from the issue text.

Description

Area/Reports Type/Bug
Description

In target/report/scan_results.json, location.filePath holds only the file name for documents of non-default modules, while the issue's top-level filePath holds the full path. Two modules with a file of the same name, such as modules/db/main.bal and modules/cache/main.bal, give issues with the same location.filePath, so a consumer that reads location cannot tell them apart. The SARIF report uses the module path.

Steps to Reproduce
  1. Create a package with a module db containing modules/db/db.bal, and add code that reports any issue in it.
  2. Run bal build and bal scan.
  3. Open target/report/scan_results.json.

Actual, for an issue in modules/db/db.bal:

"location": {"filePath": "db.bal", ...},
"filePath": "/path/to/package/modules/db/db.bal"
Expected Behavior

location.filePath gives the path relative to the package root, modules/db/db.bal, as the SARIF report does.

Version

0.13.0-SNAPSHOT

Environment Details (with versions)

Ballerina 2201.14.0, macOS

Dominant language
Java
Stars
15
Forks
12
Avg merge
2d 7h
Merged PRs (30d)
10

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ballerina-platform/static-code-analysis-tool

All issues in ballerina-platform/static-code-analysis-tool

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.