MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / main

Function main

scripts/inspect-unity.py:232–302  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230
231
232def main() -> None:
233 parser = argparse.ArgumentParser(description="Run static analysis on Unity C# code")
234 parser.add_argument(
235 "--only",
236 choices=["inspect", "similarity"],
237 help="Run only the specified tool",
238 )
239 parser.add_argument(
240 "--severity",
241 default="WARNING",
242 help="inspectcode severity threshold (default: WARNING)",
243 )
244 parser.add_argument(
245 "--threshold",
246 type=float,
247 default=0.87,
248 help="similarity-csharp threshold (default: 0.87)",
249 )
250 parser.add_argument(
251 "--output-dir",
252 type=Path,
253 help="Report output directory (default: /tmp)",
254 )
255 parser.add_argument(
256 "--keep-sln",
257 action="store_true",
258 help="Keep generated .sln after analysis",
259 )
260 args = parser.parse_args()
261
262 run_inspect = args.only in (None, "inspect")
263 run_sim = args.only in (None, "similarity")
264
265 if not ensure_tools(run_inspect, run_sim):
266 sys.exit(1)
267
268 output_dir: Path = args.output_dir or Path(tempfile.gettempdir())
269 output_dir.mkdir(parents=True, exist_ok=True)
270
271 generated_sln = False
272 sln_path: Path | None = None
273 if run_inspect and not sln_exists():
274 if not find_csproj_files():
275 print("No .csproj files found in TestProject/. Open the project in Unity first.")
276 sys.exit(1)
277 sln_path = generate_sln()
278 generated_sln = True
279
280 has_issues = False
281
282 if run_inspect:
283 print("\n── inspectcode ──")
284 sarif_path, issue_count = run_inspectcode(sln_path or TEST_PROJECT, output_dir, args.severity)
285 print(f"\nInspectCode results ({sarif_path}):")
286 print_inspect_summary(sarif_path)
287 if issue_count > 0:
288 has_issues = True
289

Callers 1

inspect-unity.pyFile · 0.70

Calls 8

ensure_toolsFunction · 0.85
sln_existsFunction · 0.85
find_csproj_filesFunction · 0.85
generate_slnFunction · 0.85
run_inspectcodeFunction · 0.85
print_inspect_summaryFunction · 0.85
run_similarityFunction · 0.85
print_similarity_summaryFunction · 0.85

Tested by

no test coverage detected