Exit with a non-zero code when `bal scan` fails
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- cli, testing-qa
Research direction
Start by reading ScanCmd and tracing the early returns for the listed failure cases; inspect how scan failures and exit codes are currently handled. Replace those paths with an exception carrying the specified code, and check that each failure category returns its assigned code while completed scans return 0. Findings over a threshold are tracked separately in #111.
Written by the indexing model from the issue text.
Description
Current Limitation
Many failed runs print an error and exit with 0:
- the path does not exist or is not a Ballerina project (
bal scan nopeexits0) - the path is a
.balfile inside a package - the package is empty
Scan.tomlcannot be loaded or is invalid- both include and exclude rules are given
- an analyzer plugin fails to load
- a requested platform is not available
Only compilation errors and suppression requirement failures exit with a non-zero code. CI cannot detect a scan that never ran.
Suggested Improvement
Exit with a non-zero code on every failure, using a small fixed set of codes:
| Code | When |
|---|---|
| 0 | Scan completed |
| 1 | Runtime error: invalid Scan.toml, analyzer load failure, compilation errors, report write failure |
| 2 | Usage error: unknown or conflicting flags, invalid flag values, include and exclude rules together |
| 3 | Invalid target: path is not a package or standalone file, .bal file inside a package, empty package |
Implement it with one exception type that carries the exit code, thrown from every failure path, in place of the early returns in ScanCmd. The exit code for findings over a threshold is tracked separately in #111.
Version
0.13.0-SNAPSHOT
- Dominant language
- Java
- Stars
- 15
- Forks
- 12
- Avg merge
- 12h 17m
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ballerina-platform/static-code-analysis-tool
-
Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ballerina-platform/static-code-analysis-tool#140 ·
Maintainers usually reply within 1 day
-
Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ballerina-platform/static-code-analysis-tool#139 ·
Maintainers usually reply within 1 day
-
Type/Improvement
Difficulty 5/5 Over a week Newbie friendliness 35/100
ballerina-platform/static-code-analysis-tool#142 ·
Maintainers usually reply within 1 day
-
Type/Improvement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
ballerina-platform/static-code-analysis-tool#141 ·
Maintainers usually reply within 1 day
-
Type/Improvement
Difficulty 3/5 1-2 days Newbie friendliness 62/100
ballerina-platform/static-code-analysis-tool#138 ·
Maintainers usually reply within 1 day
All issues in ballerina-platform/static-code-analysis-tool
Similar issues
-
Component: Frontend Component: Web Component Type: Maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
it-at-m/refarch-templates#1944 ·
Maintainers usually reply within 2 days
-
priority: p2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
googleapis/java-genai#1372 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
-
GeoSeries scale and skew tests fail with pytest 9.2.0Possibly taken @jiayuasu claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Preventions: a dose saved without a unit reopens blank, and an unchanged save then erases itPossibly taken A pull request linked to this issue is open or already merged. Openpriority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
carlos-emr/carlos#5431 ·
Maintainers usually reply within 1 day