Repository: astral-sh/ruff
File: crates/ruff_linter/src/suppression.rs (Rust)

Code before:
                        TextRange::new(
                            comment.codes[code_index - 1].end(),
                            comment.codes[code_index].end(),
                        )
                    };
                    Edit::range_deletion(code_range)
                };

                let codes = if context.is_rule_enabled(rule) {
                    UnusedCodes {
                        unmatched: vec![suppression.code.to_string()],
                        ..Default::default()
                    }
                } else {
                    UnusedCodes {
                        disabled: vec![suppression.code.to_string()],
                        ..Default::default()
                    }
                };

                let mut diagnostic = context.report_diagnostic(
                    UnusedNOQA {
                        codes: Some(UnusedCodes {
                            unmatched: vec![suppression.code.to_string()],
                            ..UnusedCodes::default()
                        }),
                        kind: UnusedNOQAKind::Suppression,
                    },
                    range,
                );
                diagnostic.set_fix(Fix::safe_edit(edit));
            }
        }

        for error in self
            .errors
            .iter()
            .filter(|error| error.kind == ParseErrorKind::MissingCodes)
        {
            let mut diagnostic = context.report_diagnostic(
                UnusedNOQA {
                    codes: Some(UnusedCodes::default()),
                    kind: UnusedNOQAKind::Suppression,
                },
                error.range,
            );
            diagnostic.set_fix(Fix::safe_edit(delete_comment(error.range, locator)));
        }
    }
}


Review comment (suggestion):
Should this use `codes`?

```suggestion
                        codes: Some(codes),
```

Code after:
                };

                let codes = if context.is_rule_enabled(rule) {
                    UnusedCodes {
                        unmatched: vec![suppression.code.to_string()],
                        ..Default::default()
                    }
                } else {
                    UnusedCodes {
                        disabled: vec![suppression.code.to_string()],
                        ..Default::default()
                    }
                };

                let mut diagnostic = context.report_diagnostic(
                    UnusedNOQA {
                        codes: Some(codes),
                        kind: UnusedNOQAKind::Suppression,
                    },
                    range,
                );
                diagnostic.set_fix(Fix::safe_edit(edit));
            }
        }

        for error in self
            .errors
            .iter()
            .filter(|error| error.kind == ParseErrorKind::MissingCodes)
        {
            let mut diagnostic = context.report_diagnostic(
                UnusedNOQA {
                    codes: Some(UnusedCodes::default()),
                    kind: UnusedNOQAKind::Suppression,
                },
                error.range,
            );
            diagnostic.set_fix(Fix::safe_edit(delete_comment(error.range, locator)));
        }
    }
}

#[derive(Default)]
pub(crate) struct SuppressionsBuilder<'a> {
    source: &'a str,

    valid: Vec<Suppression>,
    invalid: Vec<InvalidSuppression>,
    errors: Vec<ParseError>,

    pending: Vec<PendingSuppressionComment<'a>>,