# Copyright (c) 2026 MergeGuide, Inc. All rights reserved.
# SPDX-License-Identifier: Proprietary
"""MergeGuide Semgrep Rules.

This package contains custom Semgrep rules for MergeGuide detection.

Directory Structure:
    - common/: Rules that apply to all languages
    - python/: Python-specific rules
    - javascript/: JavaScript/TypeScript-specific rules
    - java/: Java-specific rules
    - go/: Go-specific rules
    - csharp/: C#-specific rules
    - php/: PHP-specific rules
    - terraform/: Terraform/HCL-specific rules
    - dockerfile/: Dockerfile-specific rules
    - cpp/: C/C++-specific rules
    - rust/: Rust-specific rules
    - ruby/: Ruby-specific rules
    - kotlin/: Kotlin-specific rules
    - swift/: Swift-specific rules

Note: Do NOT use Semgrep Registry rules (p/python, etc.) due to licensing.
All rules must be custom-written and placed in this directory.

DEV-475: Semgrep integration foundation
DEV-476: Custom rule implementation (follow-up)
DEV-480: Go language detection rules
DEV-484: C# language detection rules
DEV-485: PHP language detection rules
DEV-486: Terraform/HCL detection rules
DEV-487: Dockerfile detection rules
DEV-488: C/C++ language detection rules (Phase B)
DEV-489: Rust language detection rules (Phase B)
DEV-490: Ruby language detection rules (Phase B)
DEV-491: Kotlin language detection rules (Phase B)
DEV-492: Swift language detection rules (Phase C)
"""

from pathlib import Path

# Rules directory location
RULES_DIR = Path(__file__).parent


def get_rules_dir() -> Path:
    """Get the path to the rules directory."""
    return RULES_DIR


def list_rule_files() -> list[Path]:
    """List all rule files in the rules directory."""
    rule_files = []
    for lang_dir in RULES_DIR.iterdir():
        if lang_dir.is_dir():
            rule_files.extend(lang_dir.glob("*.yaml"))
            rule_files.extend(lang_dir.glob("*.yml"))
    return rule_files
