Run the PlatformIO-internal-usage checker. Args: warn_only: If True, always return True (warn mode). If False, return False when violations exist (error mode). If None, consult ``FASTLED_LINT_PLATFORMIO_ERROR`` (defaults to warn). Returns: True if cl
(warn_only: bool | None = None)
| 114 | |
| 115 | |
| 116 | def run_platformio_lint(warn_only: bool | None = None) -> bool: |
| 117 | """Run the PlatformIO-internal-usage checker. |
| 118 | |
| 119 | Args: |
| 120 | warn_only: If True, always return True (warn mode). If False, |
| 121 | return False when violations exist (error mode). If None, |
| 122 | consult ``FASTLED_LINT_PLATFORMIO_ERROR`` (defaults to warn). |
| 123 | |
| 124 | Returns: |
| 125 | True if clean OR warn-only mode is active. |
| 126 | """ |
| 127 | if warn_only is None: |
| 128 | warn_only = os.environ.get("FASTLED_LINT_PLATFORMIO_ERROR", "") != "1" |
| 129 | |
| 130 | files = _collect_files(PROJECT_ROOT) |
| 131 | if not files: |
| 132 | return True |
| 133 | |
| 134 | checkers: list[FileContentChecker] = [NoInternalPlatformIOChecker()] |
| 135 | processor = MultiCheckerFileProcessor() |
| 136 | processor.process_files_with_checkers(files, checkers) |
| 137 | |
| 138 | violations = _collect_violations(checkers) |
| 139 | if not violations: |
| 140 | print("✅ PlatformIO-internal-usage check: no violations") |
| 141 | return True |
| 142 | |
| 143 | total = sum(len(v) for v in violations.values()) |
| 144 | mode_label = "WARN" if warn_only else "ERROR" |
| 145 | print(f"\n{'=' * 80}") |
| 146 | print( |
| 147 | f"[PlatformIO-internal-usage] {mode_label} mode — " |
| 148 | f"found {total} violation(s) in {len(violations)} file(s):" |
| 149 | ) |
| 150 | print("=" * 80) |
| 151 | _print_violations(violations) |
| 152 | print(f"\n{'=' * 80}") |
| 153 | |
| 154 | if warn_only: |
| 155 | print( |
| 156 | f"⚠️ PlatformIO-internal-usage: {total} violation(s) (warn-only — " |
| 157 | f"not failing CI). See issue #2701." |
| 158 | ) |
| 159 | print("=" * 80) |
| 160 | return True |
| 161 | |
| 162 | print(f"❌ PlatformIO-internal-usage: {total} violation(s) (gating).") |
| 163 | print("=" * 80) |
| 164 | return False |
| 165 | |
| 166 | |
| 167 | def main() -> int: |
no test coverage detected