Skip to content

codebase_checks: make whitelist path matching OS-agnostic#3179

Open
xiaoyaoqilan wants to merge 1 commit into
dimensionalOS:mainfrom
xiaoyaoqilan:fix/codebase-checks-os-agnostic-whitelist
Open

codebase_checks: make whitelist path matching OS-agnostic#3179
xiaoyaoqilan wants to merge 1 commit into
dimensionalOS:mainfrom
xiaoyaoqilan:fix/codebase-checks-os-agnostic-whitelist

Conversation

@xiaoyaoqilan

Copy link
Copy Markdown
Contributor

The WHITELIST path comparisons in test_get_logger, test_no_sections, and test_no_dunder_new compare rel_path against "/"-hardcoded paths. But rel_path is built from os.path.relpath / Path.relative_to, which yield OS-native separators ("\" on Windows). On any OS where os.sep != "/", the comparison never matches, so the whitelist is dead code: it masks real violations and reports spurious ones.

test_no_get_logger currently fails on Windows with 8 false positives (the 8 whitelisted logging.getLogger usages all get flagged). The same latent bug affects test_no_sections (docker_module.py sentinel) and test_no_dunder_new (mujoco __new__).

Normalize rel_path to forward slashes before comparing. No-op on Linux/macOS, correct everywhere. Verified: the three checks now pass on Windows and are unchanged on POSIX.

The WHITELIST path comparisons in test_get_logger, test_no_sections,
and test_no_dunder_new compare `rel_path` against "/" - hardcoded paths.
But `rel_path` is built from `os.path.relpath` / `Path.relative_to`,
which yield OS-native separators ("\\" on Windows). On any OS where
`os.sep != "/"`, the comparison never matches, so the whitelist is
dead code: it masks real violations and reports spurious ones.

test_no_get_logger currently fails on Windows with 8 false positives
(the 8 whitelisted `logging.getLogger` usages all get flagged). The
same latent bug affects test_no_sections (docker_module.py sentinel)
and test_no_dunder_new (mujoco __new__).

Normalize `rel_path` to forward slashes before comparing. No-op on
Linux/macOS, correct everywhere. Verified: the three checks now pass
on Windows and are unchanged on POSIX.
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes three codebase-check whitelists portable across operating systems.

  • Normalizes repository-relative paths to forward slashes before matching logger-usage whitelist entries.
  • Applies the same normalization to the __new__ and section-marker checks.
  • Preserves existing path behavior on POSIX while enabling whitelist matches on Windows.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness or security issues identified.

The changes consistently convert OS-native separators in locally derived relative paths to the forward-slash format already used by the static whitelists, without changing scanned files or whitelist contents.

Important Files Changed

Filename Overview
dimos/codebase_checks/test_get_logger.py Normalizes os.path.relpath output before comparing it with forward-slash whitelist entries.
dimos/codebase_checks/test_no_dunder_new.py Normalizes the Path.relative_to string before checking the __new__ whitelist.
dimos/codebase_checks/test_no_sections.py Normalizes the joined relative path before matching section-marker whitelist entries.

Reviews (1): Last reviewed commit: "codebase_checks: make whitelist path mat..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

@@            Coverage Diff             @@
##             main    #3179      +/-   ##
==========================================
- Coverage   73.33%   71.78%   -1.56%     
==========================================
  Files        1038     1112      +74     
  Lines       94300   109849   +15549     
  Branches     8546    10576    +2030     
==========================================
+ Hits        69154    78850    +9696     
- Misses      22799    28235    +5436     
- Partials     2347     2764     +417     
Flag Coverage Δ
OS-ubuntu-24.04-arm 67.70% <100.00%> (+1.53%) ⬆️
OS-ubuntu-latest 69.77% <100.00%> (+1.02%) ⬆️
Py-3.10 69.76% <100.00%> (+1.02%) ⬆️
Py-3.11 69.77% <100.00%> (+1.04%) ⬆️
Py-3.12 69.76% <100.00%> (+1.03%) ⬆️
Py-3.13 69.76% <100.00%> (+1.02%) ⬆️
Py-3.14 69.77% <100.00%> (+1.03%) ⬆️
Py-3.14t 69.76% <100.00%> (+1.02%) ⬆️
SelfHosted-macOS ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
dimos/codebase_checks/test_get_logger.py 78.72% <100.00%> (+6.38%) ⬆️
dimos/codebase_checks/test_no_dunder_new.py 81.25% <100.00%> (+16.73%) ⬆️
dimos/codebase_checks/test_no_sections.py 78.33% <100.00%> (+6.66%) ⬆️

... and 175 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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