Skip to content

fix: generate proper PHP imports in duplicate function fixer#935

Merged
chubes4 merged 1 commit intomainfrom
fix/fixability-and-php-imports
Mar 23, 2026
Merged

fix: generate proper PHP imports in duplicate function fixer#935
chubes4 merged 1 commit intomainfrom
fix/fixability-and-php-imports

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 23, 2026

Summary

Cherry-picked from the stale fix/fixability-kind-key-mismatch branch. The other two commits on that branch (fixability key fix + test refactor) are already on main.

Problem

The DuplicateFunction fixer was generating JavaScript-style imports for all non-Rust files:

import { httpGet } from 'inc::Abilities::Fetch::FetchRssAbility.php';

This broke PHP files with syntax errors because PHP needs:

use DataMachine\Abilities\Fetch\FetchRssAbility;

Fix

  • generate_duplicate_import() dispatches on Language enum
  • For PHP, reads the canonical file's namespace and class declarations to produce correct use statements
  • New extract_php_fqcn() helper parses PHP namespace + class name

This was the root cause of data-machine's persistent CI lint failures — autofix was introducing PHP syntax errors via JS-style imports, blocking the autofix PR from ever passing.

Cleanup

The stale fix/fixability-kind-key-mismatch branch can be deleted — all its useful commits are now on main.

The DuplicateFunction fixer's generate_simple_duplicate_fixes() was
generating JavaScript-style imports for all non-Rust files:

  import { httpGet } from 'inc::Abilities::Fetch::FetchRssAbility.php';

This broke PHP files with syntax errors ('unexpected identifier from')
because PHP needs:

  use DataMachine\Abilities\Fetch\FetchRssAbility;

Add generate_duplicate_import() that dispatches on Language enum and
reads the canonical file's namespace/class declarations to produce
correct PHP use statements. Also add extract_php_fqcn() helper.

This was the root cause of data-machine's persistent CI lint failures —
autofix was introducing PHP syntax errors via JS-style imports, which
blocked the autofix PR from being created.
@chubes4 chubes4 merged commit 0a13928 into main Mar 23, 2026
1 check passed
@chubes4 chubes4 deleted the fix/fixability-and-php-imports branch March 23, 2026 01:09
@homeboy-ci
Copy link
Contributor

homeboy-ci bot commented Mar 23, 2026

Homeboy Results — homeboy

Audit

Failure Digest

Audit Failure Digest

  • Alignment score: 0.921
  • Severity counts: info: 4, unknown: 3, warning: 33
  • Outliers in current run: 3
  • Parsed outlier entries: 3
  • Drift increased: yes
  • New findings since baseline: 12
    1. intra-method-duplication — Duplicated block in compute_import_rewrite — 12 identical lines at line 348 and line 374 (intra-method-duplication::src/core/engine/symbol_graph.rs::IntraMethodDuplicate)
    2. intra-method-duplication — Duplicated block in move_items_with_options — 5 identical lines at line 371 and line 391 (intra-method-duplication::src/core/refactor/move_items.rs::IntraMethodDuplicate)
    3. intra-method-duplication — Duplicated block in run_fix_iteration — 8 identical lines at line 449 and line 479 (intra-method-duplication::src/core/refactor/plan/verify.rs::IntraMethodDuplicate)
    4. test_coverage — Method 'ext_generate_module_index' has no corresponding test (expected 'test_ext_generate_module_index') (test_coverage::src/core/refactor/move_items.rs::MissingTestMethod)
    5. test_coverage — Method 'move_items' has no corresponding test (expected 'test_move_items') (test_coverage::src/core/refactor/move_items.rs::MissingTestMethod)
  • Top actionable findings:
    1. src/core/engine/symbol_graph.rs — intra_method_duplicate — Duplicated block in compute_import_rewrite — 12 identical lines at line 348 and line 374
    2. src/core/refactor/move_items.rs — intra_method_duplicate — Duplicated block in move_items_with_options — 5 identical lines at line 371 and line 391
    3. src/core/refactor/move_items/whole_file_move.rs — intra_method_duplicate — Duplicated block in move_file — 5 identical lines at line 142 and line 181
    4. src/core/refactor/plan/generate/duplicate_fixes.rs — intra_method_duplicate — Duplicated block in generate_simple_duplicate_fixes — 5 identical lines at line 511 and line 522
    5. src/core/refactor/plan/generate/duplicate_fixes.rs — intra_method_duplicate — Duplicated block in is_used_by_binary_crate — 5 identical lines at line 632 and line 666
All parsed audit findings (40)
1. **src/core/engine/symbol_graph.rs** — intra_method_duplicate — Duplicated block in `compute_import_rewrite` — 12 identical lines at line 348 and line 374
2. **src/core/refactor/move_items.rs** — intra_method_duplicate — Duplicated block in `move_items_with_options` — 5 identical lines at line 371 and line 391
3. **src/core/refactor/move_items/whole_file_move.rs** — intra_method_duplicate — Duplicated block in `move_file` — 5 identical lines at line 142 and line 181
4. **src/core/refactor/plan/generate/duplicate_fixes.rs** — intra_method_duplicate — Duplicated block in `generate_simple_duplicate_fixes` — 5 identical lines at line 511 and line 522
5. **src/core/refactor/plan/generate/duplicate_fixes.rs** — intra_method_duplicate — Duplicated block in `is_used_by_binary_crate` — 5 identical lines at line 632 and line 666
6. **src/core/refactor/plan/generate/test_gen_fixes.rs** — intra_method_duplicate — Duplicated block in `build_inline_test_module` — 7 identical lines at line 173 and line 183
7. **src/core/refactor/plan/verify.rs** — intra_method_duplicate — Duplicated block in `run_fix_iteration` — 8 identical lines at line 449 and line 479
8. **src/core/refactor/move_items/whole_file_move.rs** — near_duplicate — Near-duplicate `resolve_root` — structurally identical to src/core/refactor/add.rs
9. **src/core/refactor/plan/generate/duplicate_fixes.rs** — parallel_implementation — Parallel implementation: `scan_dir_for_reference` has similar call pattern to `search_class_in_dir` in src/core/code_audit/docs_audit/verify.rs — shared calls: `Only`, `any_file_matches`, `read_to_string`
10. **src/core/engine/symbol_graph.rs** — unreferenced_export — Public function 'parse_imports' is not referenced by any other file
11. **src/core/engine/symbol_graph.rs** — unreferenced_export — Public function 'trace_symbol_callers' is not referenced by any other file
12. **src/core/engine/symbol_graph.rs** — missing_test_method — Method 'module_path_from_file' has no corresponding test (expected 'test_module_path_from_file')
13. **src/core/engine/symbol_graph.rs** — missing_test_method — Method 'parse_imports' has no corresponding test (expected 'test_parse_imports')
14. **src/core/engine/symbol_graph.rs** — missing_test_method — Method 'rewrite_imports' has no corresponding test (expected 'test_rewrite_imports')
15. **src/core/engine/symbol_graph.rs** — missing_test_method — Method 'trace_symbol_callers' has no corresponding test (expected 'test_trace_symbol_callers')
16. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_compute_rewrite_grouped_import' references 'compute_rewrite_grouped_import' which no longer exists in the source
17. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_compute_rewrite_simple_import' references 'compute_rewrite_simple_import' which no longer exists in the source
18. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_hello' references 'hello' which no longer exists in the source
19. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_parse_php_import' references 'parse_php_import' which no longer exists in the source
20. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_parse_rust_import_alias' references 'parse_rust_import_alias' which no longer exists in the source
21. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_parse_rust_import_grouped' references 'parse_rust_import_grouped' which no longer exists in the source
22. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_parse_rust_import_self' references 'parse_rust_import_self' which no longer exists in the source
23. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_parse_rust_import_simple' references 'parse_rust_import_simple' which no longer exists in the source
24. **src/core/engine/symbol_graph.rs** — orphaned_test — Test method 'test_parse_rust_import_wildcard' references 'parse_rust_import_wildcard' which no longer exists in the source
25. **src/core/refactor/move_items.rs** — missing_test_method — Method 'ext_generate_module_index' has no corresponding test (expected 'test_ext_generate_module_index')
26. **src/core/refactor/move_items.rs** — missing_test_method — Method 'move_items' has no corresponding test (expected 'test_move_items')
27. **src/core/refactor/move_items.rs** — missing_test_method — Method 'move_items_with_options' has no corresponding test (expected 'test_move_items_with_options')
28. **src/core/refactor/move_items/whole_file_move.rs** — missing_test_file — No test file found (expected 'tests/core/refactor/move_items/whole_file_move_test.rs') and no inline tests
29. **src/core/refactor/plan/generate/duplicate_fixes.rs** — missing_test_method — Method 'extract_function_name_from_unreferenced' has no corresponding test (expected 'test_extract_function_name_from_unreferenced')
30. **src/core/refactor/plan/generate/duplicate_fixes.rs** — missing_test_method — Method 'generate_duplicate_function_fixes' has no corresponding test (expected 'test_generate_duplicate_function_fixes')
31. **src/core/refactor/plan/generate/duplicate_fixes.rs** — missing_test_method — Method 'generate_unreferenced_export_fixes' has no corresponding test (expected 'test_generate_unreferenced_export_fixes')
32. **src/core/refactor/plan/generate/duplicate_fixes.rs** — missing_test_method — Method 'module_path_from_file' has no corresponding test (expected 'test_module_path_from_file')
33. **src/core/refactor/plan/generate/test_gen_fixes.rs** — missing_test_method — Method 'generate_test_file_fixes' has no corresponding test (expected 'test_generate_test_file_fixes')
34. **src/core/refactor/plan/generate/test_gen_fixes.rs** — missing_test_method — Method 'generate_test_method_fixes' has no corresponding test (expected 'test_generate_test_method_fixes')
35. **src/core/refactor/plan/verify.rs** — missing_test_file — No test file found (expected 'tests/core/refactor/plan/verify_test.rs') and no inline tests
36. **src/core/refactor/plan/generate/test_gen_fixes.rs** — compiler_warning — [dead_code] function `build_test_file_content` is never used
37. **src/core/refactor/plan/generate/test_gen_fixes.rs** — compiler_warning — [dead_code] function `extract_test_path_from_description` is never used
38. **src/commands/docs.rs** — outlier — (outlier)
39. **tests/commands/deploy_test.rs** — outlier — (outlier)
40. **src/core/engine/undo/snapshot.rs** — outlier — (outlier)
- Full audit log: https://github.com/Extra-Chill/homeboy/actions/runs/23417140688

Autofixability classification

  • Overall: auto_fixable
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Auto-fixable failed commands:
    • audit
  • Failed commands with available automated fixes:
    • audit

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

audit (changed files only)

Auto-refactor

ℹ️ Autofix enabled, but no fixable file changes were produced

Failure Digest

Autofixability classification

  • Overall: human_needed
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Human-needed failed commands:
    • refactor --from all

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

refactor --from all

Tooling versions
  • Homeboy CLI: homeboy 0.85.3+becb1de
  • Extension: rust from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v2

Homeboy Action v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant