summaryrefslogtreecommitdiff
path: root/.astgrep/rules/wildcard-lambda-capture.yml
blob: 50e33179dfbc18bb12b8b324f7d97e665e0ab520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# SPDX-License-Identifier: Apache-2.0
# Common Error #8: Wildcard reference captures in lambdas
# Machine-enforceable rules for patterns documented in docs/COMMON_ERRORS.md.

id: bmcweb.common-errors.wildcard-lambda-capture
language: cpp
severity: error
message: >
    Avoid wildcard lambda captures ([&] or [=]) in bmcweb async code. Capture
    variables explicitly by name per docs/COMMON_ERRORS.md.
rule:
    # ^ anchor prevents matching [&] inside a nested lambda when the outer
    # lambda_expression node text contains both.  The regex matches [&]( or [=](
    # at the very start of the lambda text.
    regex: '^\[\s*[&=]\s*\]\s*\('
    kind: lambda_expression