-
Notifications
You must be signed in to change notification settings - Fork 292
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
[post build lint] Check for absolute paths #172
[post build lint] Check for absolute paths #172
Conversation
|
6caebcb
to
a21a9c5
Compare
Yeah possible, but theoretically one could pass the params |
I think I agree with @Neumann-A here; or at least, I think that'd be a better check. For here, I want to check for absolute paths generally, since someone might not set |
That was now also proposed in microsoft/vcpkg#20321 |
a21a9c5
to
2d4aab1
Compare
Same PR but now checks for absolute paths |
2d4aab1
to
67534e1
Compare
67534e1
to
863231d
Compare
@autoantwort would you mind not force pushing to one commit? It makes it really difficult to review, and we're going to squash and merge at the end anyways. |
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.
Some more things to make sure this works well.
Yeah sure. I normally use gitlab where you have |
Co-authored-by: nicole mazzuca <[email protected]>
0689e6b
to
326672e
Compare
# Conflicts: # locales/messages.en.json
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.
I agree with @vicroms that this needs e2e tests.
I prepared a commit with fixes for most of what I noticed I would like to see taken but it's enough change that I don't want to just push it on you:
https://github.com/BillyONeal/vcpkg-tool/tree/check-pkg-config-files /
@@ -218,6 +220,8 @@ namespace vcpkg::Strings | |||
|
|||
Optional<StringView> find_at_most_one_enclosed(StringView input, StringView left_tag, StringView right_tag); | |||
|
|||
bool contains_any_ignoring_c_comments(const std::string& source, View<StringView> to_find); |
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.
source
should be a StringView
src/vcpkg/postbuildlint.cpp
Outdated
for (size_t offset = 0;;) | ||
{ | ||
const auto index = path_and_contents.second.find(path, offset); | ||
if (index == std::string::npos) return false; | ||
{ // .py, .sh, .cmake or .pc file | ||
const auto before = path_and_contents.second.find_last_of("\n#", index); | ||
if (before == std::string::npos) return true; | ||
if (path_and_contents.second[before] == '\n') return true; // not a comment | ||
} | ||
offset = index + path.size(); | ||
} |
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.
This part looks extractable like contains_any_ignoring_c_comments
. And it should handle #
s not at the start of a line.
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.
It does that
include/vcpkg/base/messages.h
Outdated
@@ -1088,6 +1090,11 @@ namespace vcpkg | |||
"One or more {vendor} credential providers failed to authenticate. See '{url}' for more details " | |||
"on how to provide credentials."); | |||
DECLARE_MESSAGE(FeedbackAppreciated, (), "", "Thank you for your feedback!"); | |||
DECLARE_MESSAGE(FilesContainAbsolutePath, |
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.
This needs to tell the user about the policy now.
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.
I thought the policy should only be used internally to that merging this PR does the break the world. Imho we should not tell the users how to ignore warnings that warns before broken packages.
I have tested your patch. It gives a lot of false positives (probably a bug somewhere) and it is 4 times slower then the current implementation (500 ms vs 2.2 seconds for qtbase) |
For example? Note that the raw string literal bug effectively causes everything after the raw string literal to be considered part of it most of the time. I also didn't write tests around the python one so there are likely issues there.
Yeah I did no perf testing yet. What I did gives up on the potential simd that find_first_of does. I just spent over 4 hours trying to prove correctness of this PR yesterday and that's as far as I got. As written the cyclomatic complexity was ... high :) |
The problem was if (!file_contains_absolute_paths(fs, file, stringview_paths))
{
failing_files.push_back(file); // mark as failing file if it does not contains an absolute paths
}
Thank you for the effort :) ❤️ |
OMG I flipped the answer? 🤣😂🤣 |
@vicroms outstanding comment is that he wants an e2e test for the failing cases. |
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.
@vicroms Can you OK this?
7798f61
to
5222349
Compare
Thank you for your efforts in making a better package catalog, and a better vcpkg <3 |
Prevents microsoft/vcpkg#19720