Skip to content

MD078 - Executable Quarto chunks should have a label

Aliases: missing-chunk-labels

Flavor: Quarto only. No-op for every other flavor.

What this rule does

Flags executable Quarto/RMarkdown code chunks (e.g. ```{r}, ```{python}) that have neither an inline label nor a #| label: hashpipe option.

Why this matters

Labels are required for:

  • Quarto figure and table cross-references (@fig-foo, @tbl-bar)
  • Stable HTML anchors that survive document re-renders
  • knitr cache hits across runs
  • Useful errors when a specific chunk fails

Unlabeled chunks render fine, but the document silently loses these capabilities.

Examples

Correct - inline positional label

```{r setup}
library(ggplot2)
### Correct - inline key label

```markdown
```{r, label=setup}
library(ggplot2)
### Correct - hashpipe label

```markdown
```{r}
#| label: setup
library(ggplot2)
### Incorrect

```markdown
```{r}
library(ggplot2)
```

What this rule does not flag

  • Plain display code blocks (```r, ```python) - these are non-executable.
  • Chunks with hashpipe options other than label - the rule only requires a label.

Automatic fixes

None. A chunk label is a human-chosen identifier; the right value depends on the chunk's intent and downstream cross-references.