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

Code before:
            Path::new("ruff/RUF100_7.py"),
            &settings::LinterSettings::for_rules(vec![
                Rule::UnusedNOQA,
                Rule::FStringMissingPlaceholders,
                Rule::LineTooLong,
                Rule::UnusedVariable,
            ]),
        )?;
        assert_diagnostics!(diagnostics);
        Ok(())
    }

    #[test]
    fn invalid_rule_code_external_rules() -> Result<()> {
        let diagnostics = test_path(
            Path::new("ruff/RUF102.py"),
            &settings::LinterSettings {
                external: vec!["V".to_string()],
                ..settings::LinterSettings::for_rule(Rule::InvalidRuleCode)
            },
        )?;
        assert_diagnostics!(diagnostics);
        Ok(())
    }

    #[test]
    fn invalid_rule_code_external_rules_file_level() -> Result<()> {
        let diagnostics = test_path(
            Path::new("ruff/RUF102_1.py"),
            &settings::LinterSettings {
                external: vec!["V".to_string()],
                ..settings::LinterSettings::for_rule(Rule::InvalidRuleCode)
            },
        )?;
        assert_diagnostics!(diagnostics);
        Ok(())
    }

    #[test]
    fn ruff_per_file_ignores() -> Result<()> {
        let diagnostics = test_path(
            Path::new("ruff/ruff_per_file_ignores.py"),
            &settings::LinterSettings {
                per_file_ignores: CompiledPerFileIgnoreList::resolve(vec![PerFileIgnore::new(
                    "ruff_per_file_ignores.py".to_string(),
                    &["F401".parse().unwrap(), "RUF100".parse().unwrap()],
                    None,
                )])
                .unwrap(),
                ..settings::LinterSettings::for_rules(vec![Rule::UnusedImport, Rule::UnusedNOQA])
            },

Review comment (suggestion):
I'd probably make this a second `[test_case]` on the function above instead of introducing another function since it looks like the settings are the same.

Code after:
            Path::new("ruff/RUF100_7.py"),
            &settings::LinterSettings::for_rules(vec![
                Rule::UnusedNOQA,
                Rule::FStringMissingPlaceholders,
                Rule::LineTooLong,
                Rule::UnusedVariable,
            ]),
        )?;
        assert_diagnostics!(diagnostics);
        Ok(())
    }

    #[test_case(Path::new("ruff/RUF102.py"))]
    #[test_case(Path::new("ruff/RUF102_1.py"))]
    fn invalid_rule_code_external_rules(path: &Path) -> Result<()> {
        let snapshot = format!(
            "invalid_rule_code_external_rules_{}",
            path.to_string_lossy(),
        );
        let diagnostics = test_path(
            path,
            &settings::LinterSettings {
                external: vec!["V".to_string()],
                preview: PreviewMode::Enabled,
                ..settings::LinterSettings::for_rule(Rule::InvalidRuleCode)
            },
        )?;
        assert_diagnostics!(snapshot, diagnostics);
        Ok(())
    }

    #[test]
    fn ruff_per_file_ignores() -> Result<()> {
        let diagnostics = test_path(
            Path::new("ruff/ruff_per_file_ignores.py"),
            &settings::LinterSettings {
                per_file_ignores: CompiledPerFileIgnoreList::resolve(vec![PerFileIgnore::new(
                    "ruff_per_file_ignores.py".to_string(),
                    &["F401".parse().unwrap(), "RUF100".parse().unwrap()],
                    None,
                )])
                .unwrap(),
                ..settings::LinterSettings::for_rules(vec![Rule::UnusedImport, Rule::UnusedNOQA])
            },
        )?;
        assert_diagnostics!(diagnostics);
        Ok(())
    }

    #[test]
    fn ruff_per_file_ignores_empty() -> Result<()> {