Manifest Checks: Macros#
Note
The below checks require manifest.json to be present.
Functions:
| Name | Description |
|---|---|
check_macro_arguments_description_populated |
Macro arguments must have a populated description. |
check_macro_code_does_not_contain_regexp_pattern |
The raw code for a macro must not match the specified regexp pattern. |
check_macro_description_populated |
Macros must have a populated description. |
check_macro_max_number_of_lines |
Macros may not have more than the specified number of lines. |
check_macro_name_matches_file_name |
Macros names must be the same as the file they are contained in. |
check_macro_property_file_location |
Macro properties files must follow the guidance provided by dbt here. |
check_macro_is_used |
Macros must be invoked by at least one other resource. |
check_macro_arguments_description_populated
#
Macro arguments must have a populated description.
Rationale
Macros are reusable across the entire dbt project, yet their arguments are often poorly documented. Without argument descriptions, developers must read the macro's Jinja source to understand what each parameter does, which slows adoption and increases the risk of misuse — especially for macros shared across teams or packages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_description_length
|
int | None
|
Minimum length required for the description to be considered populated. |
None
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
# Only "common" macros need to have their arguments populated
manifest_checks:
- name: check_macro_arguments_description_populated
include: ^macros/common
manifest_checks:
- name: check_macro_arguments_description_populated
min_description_length: 25 # Setting a stricter requirement for description length
Source code in src/dbt_bouncer/checks/manifest/check_macros.py
check_macro_code_does_not_contain_regexp_pattern
#
The raw code for a macro must not match the specified regexp pattern.
Rationale
Teams often settle on preferred SQL patterns — using COALESCE instead of IFNULL, or avoiding hardcoded warehouse-specific functions — but these conventions are easy to forget in macros that are written less frequently than models. This check provides a lightweight way to enforce banned patterns and flag code that uses deprecated or non-portable SQL constructs before they propagate across the project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regexp_pattern
|
str
|
The regexp pattern that should not be matched by the macro code. |
required |
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
manifest_checks:
# Prefer `coalesce` over `ifnull`: [https://docs.sqlfluff.com/en/stable/rules.html#sqlfluff.rules.sphinx.Rule_CV02](https://docs.sqlfluff.com/en/stable/rules.html#sqlfluff.rules.sphinx.Rule_CV02)
- name: check_macro_code_does_not_contain_regexp_pattern
regexp_pattern: .*[i][f][n][u][l][l].*
Source code in src/dbt_bouncer/checks/manifest/check_macros.py
check_macro_description_populated
#
Macros must have a populated description.
Rationale
Macros are reusable Jinja functions that can be called throughout a dbt project, but unlike models they are not rendered into the dbt documentation site unless explicitly described. Without a description, engineers must read the macro source to understand its purpose and usage, slowing onboarding and increasing the risk of misuse or duplication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_description_length
|
int | None
|
Minimum length required for the description to be considered populated. |
None
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
# Only "common" macros need to have a populated description
manifest_checks:
- name: check_macro_description_populated
include: ^macros/common
Source code in src/dbt_bouncer/checks/manifest/check_macros.py
check_macro_max_number_of_lines
#
Macros may not have more than the specified number of lines.
Rationale
Long macros are a code smell — they are harder to test, document, and review. Keeping macros concise encourages single-responsibility design and makes it easier to spot logic errors. Teams that enforce a line limit are nudged to decompose complex macros into smaller, composable units that are individually testable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_number_of_lines
|
int
|
The maximum number of permitted lines. |
100
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
Source code in src/dbt_bouncer/checks/manifest/check_macros.py
check_macro_name_matches_file_name
#
Macros names must be the same as the file they are contained in.
Generic tests are also macros, however to document these tests the "name" value must be preceded with "test_".
Rationale
When a macro name does not match its file name, developers searching the codebase for a macro by name will land in the wrong file, wasting time and creating confusion. Enforcing consistent naming makes macros immediately locatable by file path and helps static analysis tools resolve macro references reliably.
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
Source code in src/dbt_bouncer/checks/manifest/check_macros.py
check_macro_property_file_location
#
Macro properties files must follow the guidance provided by dbt here.
Rationale
dbt's official project structure guidance recommends placing macro property files in predictable, consistently named YAML files alongside the macros they describe. Projects that scatter .yml files arbitrarily make it harder to locate documentation, run automated checks, and onboard new engineers. Enforcing the standard naming convention keeps the project structure navigable and aligned with community best practices.
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
Source code in src/dbt_bouncer/checks/manifest/check_macros.py
check_macro_is_used
#
Macros must be invoked by at least one other resource.
Rationale
Similar to orphaned models, macros are often written for a specific purpose and later abandoned, leaving behind technical debt and confusion. This check parses the manifest to find macros that are defined in the project but are never actually invoked by any model, test, or other macro. Keeps the macro directory lean and reduces the cognitive load for developers trying to understand the codebase.
Receives at execution time:
| Name | Type | Description |
|---|---|---|
macro |
Macros
|
The Macros object to check. |
ctx |
CheckContext
|
The check context containing the manifest. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the macro path. Macro paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the macro path. Only macro paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):