Repository navigation
[beman-tidy] Implement cmake.target_names check - #326
vickgoodman merged 3 commits into
Conversation
There was a problem hiding this comment.
Thanks for implementing cmake.target_names — the logic correctly matches the standard and CI is green, so I'm approving to unblock.
That said, please address the feedback below before merging — especially point 1, which leaves the happy path untested.
1. (Medium) The "valid" test never exercises the positive path the rule is about.
tests/.../cmake/data/valid/CMakeLists-v1.txt only contains:
add_library(beman.exemplar INTERFACE)
add_library(beman::exemplar ALIAS beman.exemplar)Both are skipped by the library_name/library_alias guards, so the branch that validates the prefix (target_name.startswith(f"{self.library_name}.")) is never executed in the passing test — it passes vacuously. Since correctly-prefixed example/test targets are the whole point of the rule, a regression in the startswith branch would not be caught. Please add a valid fixture containing a properly-prefixed target, e.g. add_executable(beman.exemplar.examples.basic).
2. (Low, scope) The check only sees the top-level CMakeLists.txt.
get_cmake_target_names() uses parse_raw, which does not resolve add_subdirectory. In real Beman repos the example/test targets this rule governs typically live in subdirectory CMakeLists files added via add_subdirectory(...), so in practice the check will rarely see the targets it's meant to police and will silently pass. This is consistent with the other cmake.* checks and arguably out of scope here — but worth a TODO/comment or a follow-up issue noting the limitation.
3. (Low) Misleading message for misnamed library targets.
In check(), an add_library first-arg that isn't exactly library_name/library_alias is reported as "Invalid CMake target name ... expected prefix: '<library_name>.'". For invalid-target_names-v1.txt (add_library(beman.foobar)) and -v3.txt (add_library(beman.exemplar2 ...)), the offending line is really the library target itself, which is the domain of cmake.library_name. Not a bug (still returns False), but the diagnostic conflates two rules. Invalid fixtures for this check would be more on-point using add_executable example/test targets with a bad prefix (v2 already does this well).
…s check continuation
|
|
@neatudarius |
Uh oh!
There was an error while loading. Please reload this page.