-
Notifications
You must be signed in to change notification settings - Fork 684
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
Run clang-format
for Examples and Tutorials
#1464
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1464 +/- ##
==========================================
- Coverage 82.09% 81.15% -0.95%
==========================================
Files 273 273
Lines 43551 44230 +679
Branches 8997 9132 +135
==========================================
+ Hits 35753 35894 +141
- Misses 6982 7554 +572
+ Partials 816 782 -34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Examples/ArpSpoofing/main.cpp
Outdated
{ "interface", required_argument, nullptr, 'i' }, | ||
{ "victim", required_argument, nullptr, 'c' }, | ||
{ "gateway", required_argument, nullptr, 'g' }, | ||
{ "help", no_argument, nullptr, 'h' }, | ||
{ "version", no_argument, nullptr, 'v' }, | ||
{ nullptr, 0, nullptr, 0 } |
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.
@tigercosmos for some reason clang-format mixes tabs and spaces here, I have no idea why 🤷♂️
I tried different things but couldn't make it to work. Maybe you know?
It happens in other files also, like here:
static struct option IcmpFTOptions[] = { |
But in others it doesn't happen:
static struct option DNSResolverOptions[] = { |
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.
Apparently in some of the files, changing the order of the arguments fixes the issue, this is very weird 😕
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.
@seladb whenever you think clang-format is stupid, you can turn off the format for that part.
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's concerning that we can't rely on clang-format
and need to go over the code ourselves. This kind of beats the purpose of a code formatter 😕
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.
@seladb this kind of stuff rarely happens. We are formatting a bunch of code at once so there might be a few weird formatting. But overall, we will get the fruits after all formatting. :)
.clang-format
Outdated
@@ -1,6 +1,6 @@ | |||
--- | |||
BasedOnStyle: Microsoft | |||
UseTab: AlignWithSpaces | |||
UseTab: ForIndentation |
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.
@tigercosmos I think we should change this, it looks nicer, what do you think?
If you agree I can open a PR for Common++ as well
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 don't have a strong opinion about it. it's fine to me.
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.
ok, I'll open a separate PR for this change
@seladb precommit failed. did you check if your clang-format version correct? |
Hmm I'm using version 18.1.6 on Windows D:\seladb\PcapPlusPlus\Examples>D:\Apps\LLVM\bin\clang.exe --version
clang version 18.1.6
Target: x86_64-pc-windows-msvc
Thread model: posix |
@seladb remember to update |
Yes, that's a good point, thanks for the reminder! |
PTF_ASSERT_TRUE(std::any_of(ipAddresses.begin(), ipAddresses.end(), | ||
[ipToSearch](pcpp::IPAddress const& addr) { return addr == ipToSearch; })); |
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.
clang-format
failed after I included Tests
in pre-commit
@@ -24,7 +24,7 @@ repos: | |||
hooks: | |||
- id: clang-format | |||
args: ["--style=file"] # Use the .clang-format file for configuration | |||
files: ^Common\+\+/.*\.(cpp|h)$ | |||
files: ^(Common\+\+|Tests|Examples)/.*\.(cpp|h)$ |
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.
Updated to cover Common++
, Tests
and Examples
@seladb If you have gone through all the files, I will approve the PR. |
@tigercosmos I went through all the files and made updates where necessary. However feel free to do another pass and make sure I didn't miss anything |
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 did a quick overview. LGTM.
No description provided.