# dbt™️ Macro checks

## `check-macro-has-description`

{% hint style="info" %}
**What it does**

Ensures that the macro has a description in the properties file (usually `macro.yml`).

**When to use it**

You want to make sure that all macros have a description.
{% endhint %}

**Arguments**

`--manifest`: location of `manifest.json` file. Usually `target/manifest.json`. This file contains a full representation of dbt project. **Default: `target/manifest.json`** `--exclude`: Regex pattern to exclude files.

**Example**

```yaml
repos:
  - repo: https://github.com/dbt-checkpoint/dbt-checkpoint
    rev: v1.0.0
    hooks:
      - id: check-macro-has-description
```

**Requirements**

|          Macro exists in `manifest.json` *1*          | Macro exists in `catalog.json` *2* |
| :---------------------------------------------------: | :--------------------------------: |
| ❌ Not needed since it also validates properties files |            ❌ Not needed            |

1 It means that you need to run `dbt parse` before run this hook (dbt >= 1.5).\
2 It means that you need to run `dbt docs generate` before run this hook.

**How it works**

* Hook takes all changed `yml` and `SQL` files.
* The macro name is obtained from the `SQL` file name.
* The manifest is scanned for a macro.
* Modified `yml` files are scanned for a macro.
* If any macro (from a manifest or `yml` files) does not have a description, the hook fails.
* The macro description must be in either the yml file **or** the manifest.

**Known limitations**

If you `run` and then you delete the description from a properties file, the hook success since the description is still present in `manifest.json`.

***

## `check-macro-arguments-have-desc`

{% hint style="info" %}
**What it does**

Ensures that the macro has arguments with descriptions in the properties file (usually `schema.yml`).

**When to use it**

You want to make sure that all specified arguments in the properties files (usually `schema.yml`) have some description. **This hook does not validate if all macro arguments are also present in a properties file.**
{% endhint %}

**Arguments**

`--manifest`: location of `manifest.json` file. Usually `target/manifest.json`. This file contains a full representation of dbt project. **Default: `target/manifest.json`**

**Example**

```yaml
repos:
  - repo: https://github.com/dbt-checkpoint/dbt-checkpoint
    rev: v0.1.1
    hooks:
      - id: check-macro-arguments-have-desc
```

**Requirements**

|          Macro exists in `manifest.json` *1*          | Macro exists in `catalog.json` *2* |
| :---------------------------------------------------: | :--------------------------------: |
| ❌ Not needed since it also validates properties files |            ❌ Not needed            |

1 It means that you need to run `dbt parse` before run this hook (dbt >= 1.5).\
2 It means that you need to run `dbt docs generate` before run this hook.

**How it works**

* Hook takes all changed `yml` and `SQL` files.
* The macro name is obtained from the `SQL` file name.
* The manifest is scanned for a macro.
* Modified `yml` files are scanned for a macro.
* If any argument in the found macro does not contain a description, the hook fails.
* The description must be in either the yml file **or** the manifest.

**Known limitations**

If you `run` and then you delete argument description from a properties file, the hook success since the description is still present in `manifest.json`.

***

<br>
