Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Clang-Tidy outputs absolute filepaths #378

Open
JesseTatasciore opened this issue Sep 4, 2024 · 3 comments
Open

[Bug]: Clang-Tidy outputs absolute filepaths #378

JesseTatasciore opened this issue Sep 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@JesseTatasciore
Copy link
Member

What happened?

When running bazel lint //speller/... I am seeing absolute filepaths (which include the bazel output tree) with the linting results:

/private/var/tmp/_bazel_jesse/93d7e699c5e2019d94351d19b00be5a3/sandbox/darwin-sandbox/11/execroot/_main/speller/data_driven_tests/lookup-datatest.cc:16:8: warning: an exception may be thrown in function 'test_config' which should not throw exceptions [bugprone-exception-escape]

I expected to see relative filepaths outputed instead:

speller/data_driven_tests/lookup-datatest.cc:16:8: warning: an exception may be thrown in function 'test_config' which should not throw exceptions [bugprone-exception-escape]

Version

Development (host) and target OS/architectures:

Reproduceable on MacOS and Ubuntu

Output of bazel --version:

(This happens on all versions of the Aspect CLI)

Bazelisk version: 1.20.0
Aspect CLI Pro version: 5.11.0-alpha0.dev.150.g12ded54
Build label: 7.3.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Aug 19 16:41:27 2024 (1724085687)
Build timestamp: 1724085687
Build timestamp as int: 1724085687

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_bazel_lib", version = "2.7.7")
bazel_dep(name = "aspect_rules_cypress", version = "0.6.0")
bazel_dep(name = "aspect_rules_esbuild", version = "0.21.0")
bazel_dep(name = "aspect_rules_jasmine", version = "2.0.0")
bazel_dep(name = "aspect_rules_jest", version = "0.22.0")
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc9")
bazel_dep(name = "aspect_rules_swc", version = "2.0.0")
bazel_dep(name = "aspect_rules_ts", version = "3.0.0")
bazel_dep(name = "aspect_rules_webpack", version = "0.16.0")

Language(s) and/or frameworks involved:

Clang-Tidy

How to reproduce

Checkout: https://github.com/aspect-build/bazel-examples

Run: `bazel lint //speller/...`

Any other information?

We have solved this problem for eslint. Look into how we fixed it there and apply it to clang tidy as well

@JesseTatasciore JesseTatasciore added the bug Something isn't working label Sep 4, 2024
@alexeagle
Copy link
Member

eslint fix is https://github.com/aspect-build/rules_lint/blob/main/lint/eslint.stylish-formatter.js#L1-L4

Yes, this is important since you can't click the file in your terminal to navigate to the site you want to edit.
@jsharpe do you happen to know if this is easy to fix?

@jsharpe
Copy link
Contributor

jsharpe commented Sep 4, 2024

Not sure - a quick search shows this microsoft/vscode-cpptools#9555 which shows it definitely is possible to get relative outputs from clang-tidy though; maybe the wrapper for clang-tidy needs to ensure that its passing sources as relative paths in its input?

@alexeagle
Copy link
Member

Interesting, if I bypass Aspect CLI and run with vanilla Bazel, it's mostly relative paths but some absolute.

example % ./lint.sh src/cpp/...
src/cpp/main/hello-greet.h:6:13: error: function 'get_greet' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name,-warnings-as-errors]
std::string get_greet(const std::string &thing);
            ^
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/sandbox/darwin-sandbox/9/execroot/_main/src/cpp/main/hello-greet.cc:5:13: note: the definition seen here
std::string get_greet(const std::string& who) { return "Hello " + who; }
            ^
src/cpp/main/hello-greet.h:6:13: note: differing parameters are named here: ('thing'), in definition: ('who')
std::string get_greet(const std::string &thing);
            ^                            ~~~~~
                                         who

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants