summaryrefslogtreecommitdiff
path: root/.astgrep/rules/long-lambda.yml
blob: b2ba6120948aec8b8a0fa85683bab0fa66d063dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# SPDX-License-Identifier: Apache-2.0
# Flag lambdas whose body spans more than 10 lines. Long lambdas are hard to
# read and review; prefer extracting them into a named function.

id: long-lambda
language: cpp
severity: warning
message: >
    Lambda is longer than 10 lines. Extract it into a named function to keep
    async call sites readable per docs/COMMON_ERRORS.md.
rule:
    kind: lambda_expression
    # (?s) makes . match newlines. At least 10 newlines in the lambda node text
    # means it spans at least 11 lines, i.e. more than 10 lines.
    regex: '(?s)^.*(\n.*){10}'