Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Exit with a non-zero code when `bal scan` fails

Open
#131 0 comments 0 reactions 0 assignees View on GitHub

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

Type/Improvement
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 nope exits 0)
  • the path is a .bal file inside a package
  • the package is empty
  • Scan.toml cannot 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

  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.