From d85124e4822145f8764328d61970562fb7f4e6f8 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 11 Apr 2023 22:25:48 -0400 Subject: [PATCH] Add a lint for SuccessOrExit(CHIP_ERROR_*). (#26057) Since it's not changing state, it's identical to ExitNow(), but it _looks_ like it's going to somehow return the provided error code. --- .github/workflows/lint.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 17c31b004581d8..9b5de4ac637f40 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -221,3 +221,12 @@ jobs: if: always() run: | flake8 --extend-ignore=E501,W391 + + # git grep exits with 0 if it finds a match, but we want + # to fail (exit nonzero) on match. And we want to exclude this file, + # to avoid our grep regexp matching itself. + - name: Check for use of "SuccessOrExit(CHIP_ERROR_*)", which should probably be "SuccessOrExit(err = CHIP_ERROR_*)" + if: always() + run: | + git grep -n 'SuccessOrExit(CHIP_ERROR' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 +