GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: allow same-directory header includes by PNHD · Pull Request #470 · cpplint/cpplint

Conversation

@PNHD

@PNHD PNHD commented Aug 31, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #375.

Summary

  • resolve bare quoted headers against the directory of the file being linted before emitting build/include_subdir
  • allow a bare include when a different header file actually exists alongside the source, including files under repository subdirectories
  • keep build/include_subdir enforcement when the bare header does not resolve locally, and keep self-includes subject to the existing warning
  • add regression coverage for both repository-root and nested same-directory headers, plus nested missing-header cases
  • update affected sample expectations and the unreleased changelog

Testing

  • regression test first reproduced the src/main.cpp + src/utils.hpp false positive from False positive for top-level header #375
  • pytest --no-cov cpplint_unittest.py -k testBuildInclude: passed after the fix
  • full test suite: passed
  • pylint cpplint.py: passed
  • repository pre-commit checks: passed

Summary by CodeRabbit

  • Bug Fixes

    • Improved include-subdirectory checks for files accessed through symlinks, hard links, and equivalent paths.
    • Prevented false warnings when source files include headers from the same directory without a directory prefix.
    • Corrected self-include detection across equivalent file paths.
    • Updated sample lint reports to reflect the reduced false-positive warning count.
  • Documentation

    • Clarified changelog wording for same-directory header includes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@PNHD
fix: allow top-level header includes
1a8a07f
@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e2fed310-149d-4547-b34d-58b9f853b9c0

📥 Commits

Reviewing files that changed from the base of the PR and between 508206a and d160830.

📒 Files selected for processing (1)
  • cpplint_unittest.py

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The build/include_subdir check now resolves bare headers against the source file’s physical directory and preserves warnings for missing or self-included headers. Tests cover path aliases and invalid paths. Sample reports and the changelog reflect the updated behavior.

Changes

Include-subdirectory behavior

Layer / File(s) Summary
Resolve same-directory headers
cpplint.py, cpplint_unittest.py
The check uses real paths and file identity checks for same-directory headers, symlink paths, symlink aliases, hardlink aliases, and invalid header paths.
Update documented and sample results
CHANGELOG.rst, samples/codelite-sample/simple.def, samples/vlc-sample/simple.def
The changelog describes same-directory header includes. Sample reports remove obsolete diagnostics and reduce their error counts.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: walidbi200

Merge Risk: ⚪ Minimal · up to d1608

No concrete correctness or merge-blocking risk remains for this focused change.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing same-directory header includes.
Linked Issues check ✅ Passed Issue #375 requires build/include_subdir to allow a quoted header when that header exists in the source file directory. The PR resolves the source path, checks the bare header in that directory, and…
Out of Scope Changes check ✅ Passed The code change, regression tests, sample expectation updates, and changelog update support the same-directory include fix in issue #375. No unrelated change is demonstrated.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PNHD
fix: allow same-directory header includes
1592d0b
@PNHD PNHD changed the title fix: allow top-level header includes fix: allow same-directory header includes Aug 31, 2026
@PNHD PNHD mentioned this pull request Aug 31, 2026
Looking for more maintainers #402
Open
walidbi200
walidbi200 suggested changes Sep 13, 2026
View reviewed changes

@walidbi200 walidbi200 left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Reviewed current head 1592d0b. The normal #375 case is fixed and the tests are green, but I found two path-handling cases that seem important to fix before merging.

One is a source path that goes through a symlink and then ... In that case cpplint can open one real file, while FileInfo.FullName() normalizes the path to a different lexical directory. The new same-directory header check can then look beside the wrong path. I reproduced both outcomes: it can warn even when the real sibling header exists, and it can suppress the warning when only an unrelated header exists in the normalized directory.

The other case is self-includes through filesystem aliases. If self.h includes alias.h and alias.h is a symlink or hard link to self.h, develop still reports build/include_subdir, but this PR suppresses it. os.path.samefile() confirms the two paths refer to the same file. The current normpath() / normcase() comparison only compares path strings, so it doesn't catch that identity case.

I also checked the ordinary same-directory behavior, missing headers, the sample-output changes, and the full test suite; those parts look good. I think these two filesystem cases should get regression tests and a fix before merge.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
PNHD added 2 commits September 18, 2026 11:01
@PNHD
fix: handle same-directory include path edge cases
508206a
@PNHD
test: gate symlink path case by filesystem semantics
d160830
walidbi200
walidbi200 approved these changes Sep 20, 2026
View reviewed changes

@walidbi200 walidbi200 left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Re-reviewed current head d160830. Both findings from my previous review are fixed: I reproduced the symlink+.. false positive/false negative and both alias suppressions on 1592d0b, and all four behave correctly on this head.

The realpath/samefile change is narrowly scoped, the new regression tests fail without the corresponding fixes, and I also checked normal same-directory includes, self-includes, missing and invalid paths, symlinked sources, broken symlinks, and the fallback path handling without finding a new correctness issue.

Focused and full suites pass locally (236 tests, 96.48% coverage), along with pylint, mypy, pre-commit, and git diff --check.

No remaining blocker from me on this head. LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
DanceoftheAurora
DanceoftheAurora suggested changes Nov 6, 2026
View reviewed changes

@DanceoftheAurora DanceoftheAurora left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

AI-assisted review of d160830. The full local suite passes (236 tests, Python 3.12/macOS), but I found a source-file symlink regression at cpplint.py:5859-5860.

With alias/main.cc -> physical/real.cc and #include "utils.hpp" in that source, Clang searches beside the supplied source pathname:

Header location Clang C++17 Base cpplint This head
Only alias/utils.hpp succeeds warns warns
Only physical/utils.hpp fails warns no warning

I reproduced this using clang++ -std=c++17 -fsyntax-only alias/main.cc and cpplint with --filter=-,+build/include_subdir. The second case is a new false negative: resolving the final source-file symlink makes an unrelated header suppress the diagnostic. The first is a remaining false positive.

Please resolve the parent directory for this lookup without dereferencing the final filename, while keeping the samefile self-include protection, and cover both header locations. A local experiment using realpath(dirname(filename)) restores both outcomes and passes the six existing include-path tests. This is distinct from the previously fixed directory-symlink-plus-.. case.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@DanceoftheAurora

DanceoftheAurora commented Nov 6, 2026

Copy link
Copy Markdown

Follow-up to the review: I prepared a minimal, AI-assisted fix on top of this exact head in e88a7dc.

It resolves the parent directory without following the final source-file symlink, preserving the existing self-include protection. Two parameterized regression cases cover a header beside only the alias and beside only the physical target. Both fail on the original implementation and pass with the fix.

Local validation on Python 3.12/macOS: all 8 include-path cases pass, the full suite passes (238 tests), and Pylint passes. The commit is based directly on d160830, so it can be cherry-picked or adapted into this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

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

Reviewers

2 more reviewers
@DanceoftheAurora DanceoftheAurora DanceoftheAurora requested changes
@walidbi200 walidbi200 walidbi200 approved these changes
Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

False positive for top-level header

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@PNHD @DanceoftheAurora @walidbi200
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.