Main entry point for the linter.
()
| 119 | |
| 120 | |
| 121 | def main() -> int: |
| 122 | """Main entry point for the linter.""" |
| 123 | parser = argparse.ArgumentParser( |
| 124 | description='Check C++ files for common issues (relative includes, FastLED.h usage)', |
| 125 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 126 | epilog=""" |
| 127 | Examples: |
| 128 | uv run cpp_lint.py # Check all C++ files in project |
| 129 | uv run cpp_lint.py src/ # Check only src/ directory |
| 130 | uv run cpp_lint.py --exclude .pio # Exclude additional directories |
| 131 | """ |
| 132 | ) |
| 133 | parser.add_argument( |
| 134 | 'paths', |
| 135 | nargs='*', |
| 136 | default=['.'], |
| 137 | help='Paths to check (default: current directory)' |
| 138 | ) |
| 139 | parser.add_argument( |
| 140 | '--exclude', |
| 141 | action='append', |
| 142 | default=[], |
| 143 | help='Additional directories to exclude (can be specified multiple times)' |
| 144 | ) |
| 145 | |
| 146 | args = parser.parse_args() |
| 147 | |
| 148 | # Default exclusions |
| 149 | exclude_dirs: Set[str] = { |
| 150 | '.git', |
| 151 | '.pio', |
| 152 | 'build', |
| 153 | 'node_modules', |
| 154 | '__pycache__', |
| 155 | '.venv', |
| 156 | 'venv', |
| 157 | } |
| 158 | exclude_dirs.update(args.exclude) |
| 159 | |
| 160 | # Collect all files to check |
| 161 | all_files: List[Path] = [] |
| 162 | for path_str in args.paths: |
| 163 | path = Path(path_str) |
| 164 | if not path.exists(): |
| 165 | print(f"Error: Path does not exist: {path}", file=sys.stderr) |
| 166 | return 1 |
| 167 | |
| 168 | if path.is_file(): |
| 169 | all_files.append(path) |
| 170 | else: |
| 171 | all_files.extend(find_cpp_files(path, exclude_dirs)) |
| 172 | |
| 173 | if not all_files: |
| 174 | print("No C++ files found to check.", file=sys.stderr) |
| 175 | return 0 |
| 176 | |
| 177 | # Check all files |
| 178 | total_violations = 0 |
no test coverage detected