Closed mohammadv184 closed 1 year ago
@mohammadv184 By convention, Golang analysis/singlechecker and internal/checker package return non-zero exit codes as below:
// It returns the exitcode: in plain mode, 0 for success, 1 for analysis
// errors, and 3 for diagnostics. We avoid 2 since the flag package uses
// it. JSON mode always succeeds at printing errors and diagnostics in a
// structured form to stdout.
As long as there is more suggestions, exit code of 3 will be returned. When there are no suggestions/diagnostics of any kind, exit code of 0 will be returned.
Yes, but regarding the -apply option of betteralign, it's important to note that according to the GNU Bash documentation, a command should return an exit code of 0 if it's executed successfully and without errors. The documentation can be found at: https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
Thus, in the case of betteralign -apply, the expected behaviour should be to return an exit code of 0 if there are no errors or warnings and the code is successfully aligned. However, it's worth noting that the convention for analysis/singlechecker and internal/checker is to return an exit code of 3 when suggestions are available in diagnostic mode. In apply mode, betteralign should be adhered to this convention by returning an exit code of 0 if there are no errors or warnings.
Dear @mohammadv184 , you are absolutely right in regards to standard exit codes. However, again, we are calling singlechecker in main() and all exit codes are coming from analysis/singlechecker
and internal/checker
. There is simply nothing here to do and it's not a bug, at least not in betteralign.
Description:
I am using the
betteralign
tool to align the code in my project automatically. When I run the commandbetteralign -apply ./...
in my project CI, the tool successfully aligns the code, but it returns an exit code of 3, which causes my CI to fail.Expected behaviour:
I expect
betteralign
to return an exit code of 0 when it successfully aligns my code with the-apply
flag.