Skip to content

Fix/missing newline at end of file - #3514

Open
imanolpg wants to merge 2 commits into
Graphify-Labs:v8from
imanolpg:fix/missing-newline-at-end-of-file
Open

Fix/missing newline at end of file#3514
imanolpg wants to merge 2 commits into
Graphify-Labs:v8from
imanolpg:fix/missing-newline-at-end-of-file

Conversation

@imanolpg

Copy link
Copy Markdown

Description

This PR fixes #3513

If a C or C++ header finishes without a newline \n character, graphify will give a warning even if the file is valid and compiles.

Modifications

If the header file does not end with a newline character, adding a newline character in the read content at the end (graphify/extractors/engine.py ) fixes the warning. The file is not modified and the only addition is on the read content that will later be parsed.

Also, some tests have been added.

Tests

A new test file tests/test_trailing_newline_not_a_syntax_error.py was added. It tests that a header file with no newline char at the end does not raise the warning. Also, it checks that a file with a newline works as before. A header with functions and an empty file have also been tested to ensure they work as expected.

All tests pass correctly.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Appends a trailing newline to source before parsing when the file doesn't already end in one, so valid C/C++ headers without a final newline no longer produce spurious parse errors. Empty files are left untouched. Adds tests covering C/C++ headers with and without trailing newlines, empty files, and that functions are still extracted.

No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 665 functions depend on the 224 functions this change touches.

Health — this change adds coupling hotspots:

  • new: _extract_generic() — 18 callers, 26 callees
  • new: extract_js() — 85 callers, 4 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: extract_objc() — 27 callers, 9 callees
  • new: extract_julia() — 17 callers, 7 callees
  • new: extract_cpp() — 29 callers, 3 callees
  • new: extract_vue() — 10 callers, 7 callees
  • new: walk() — 1 callers, 59 callees
  • …and 8 more — each is listed as a finding

Verification — 665 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 605 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

22 of 269 test file(s) selected (8%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_build.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_extract.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_indirect_dispatch.py — impact
  • tests/test_indirect_dispatch_assign_return.py — impact
  • tests/test_indirect_dispatch_getattr.py — impact
  • tests/test_js_exported_scalar_bindings.py — impact
  • tests/test_languages.py — impact
  • tests/test_multilang.py — impact
  • tests/test_python_underscore_resolution.py — impact
  • tests/test_rationale.py — impact
  • tests/test_ruby_resolution.py — impact
  • tests/test_scala_self_type.py — impact
  • tests/test_swift_computed_properties.py — impact
  • tests/test_trailing_newline_not_a_syntax_error.py — impact, changed-test
  • tests/test_ts_new_expression_calls.py — impact
  • tests/test_typescript_module_extensions.py — impact
  • tests/test_vue_extraction.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Formal verification

Could not verify: Could not verify \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set

· 16 more finding(s) on lines outside this diff (see the check run).

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.

Incorrect "syntax errors" in C and C++ headers when they dont end with a newline character

1 participant