CENTCOM-Analyzer (AI Code Reviewer)
Relevant source files
The following files were used as context for generating this wiki page:
CENTCOM-Analyzer operates as a suite of automated diagnostic and review tools integrated into the BandaStation development workflow. It enforces code standards, detects common mapping errors, and manages the reporting of unstable tests during Continuous Integration (CI) cycles. The system ensures that all contributions adhere to the project's technical requirements before they are merged into the main repository.
The analyzer primarily functions through automated shell scripts and JavaScript hooks that interact with GitHub Actions. It validates file formatting, identifies forbidden coding patterns, and provides structured feedback on pull requests to maintain repository health and stability.
Sources: tools/ci/check_grep.sh, tools/pull_request_hooks/rerunFlakyTests.js, README.md:3-6
Code and Content Validation
The validation engine uses grep or ripgrep to scan the codebase for specific patterns that violate project standards. This process covers DM code files, DMM map files, and various configuration assets.
Automated Linting Checks
The system performs several categories of checks to ensure code quality:
| Category | Description |
|---|---|
| Map Sanity | Detects non-TGM formats, unexpected comments, and invalid procs in .dmm files. |
| Whitespace | Identifies space indentation, mixed indentation, and CRLF line endings. |
| Common Mistakes | Flags unmanaged global variables, improper static list paths, and incorrect forceMove usage. |
| Naming Standards | Enforces lowercase naming for map JSON files and checks for common spelling errors like "Nanotransen" or "CentComm". |
Sources: tools/ci/check_grep.sh:42-260
Diagnostic Flow
The following diagram illustrates how the validation script processes different file types:
The script differentiates between standard grep and ripgrep (rg) to optimize search performance and capability, specifically enabling PCRE2 for complex regex patterns when available.
Sources: tools/ci/check_grep.sh:9-40
Flaky Test Analysis and Reporting
The system includes a specialized module to handle "flaky" tests—tests that fail intermittently without changes to the code. This prevents unstable tests from blocking development while ensuring that genuine regressions are tracked.
Identification Logic
The analyzer monitors GitHub Actions workflow runs. If a job within the Integration Tests or Alternate Tests suites fails, the system triggers a re-run. If the test passes on the second attempt, it is classified as "flaky".
The extractDetails function parses execution logs to strip timestamps and identify the specific failure headline, such as runtimes, hard delete timeouts, or invalid timers.
Sources: tools/pull_request_hooks/rerunFlakyTests.js:5-155
Error Detail Extraction
The analyzer categorizes failures using specific regex patterns to provide readable summaries in the issue tracker:
- Runtimes: Captures the specific error message and affected proc.
- Hard Deletes: Identifies objects that failed to delete within the time limit.
- Invalid Timers: Tracks failed timer delegates and their source objects.
Sources: tools/pull_request_hooks/rerunFlakyTests.js:59-122
Automated Documentation Management
The autowiki module synchronizes generated technical information with the external project wiki. It uses the mwbot library to interact with the MediaWiki API.
Wiki Update Process
- Authentication: The bot logs in using environment-provided
USERNAMEandPASSWORD. - Rate Limiting: Implements a retry strategy with exponential backoff for
ratelimitederrors. - Content Protection: Automatically wraps edited pages in
<noinclude>blocks to warn against manual edits. - Asset Handling: Uploads and replaces files, detecting exact duplicates to avoid unnecessary traffic.
Sources: tools/autowiki/autowiki.js:5-105, tools/autowiki/package.json:1-10
UI Consistency Checks
For frontend components developed in tgui, the analyzer supports development-time inspections. These include:
- Layout Debugger: Visualizes element outlines to identify alignment bugs.
- Re-render Monitoring: Prints performance logs to ensure interface updates remain under 16ms.
- TypeScript Validation: Uses
tgui-tscto perform static type checking across React interfaces.
Sources: tgui/README.md:54-135
CENTCOM-Analyzer centralizes the enforcement of the project's technical standards. By combining static pattern matching, automated test retries, and documentation synchronization, it reduces manual review overhead and ensures the long-term stability of the BandaStation repository.