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

Run clang-format for Examples and Tutorials #1464

Merged
merged 23 commits into from
Jul 30, 2024
Merged

Conversation

seladb
Copy link
Owner

@seladb seladb commented Jun 24, 2024

No description provided.

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 43.62374% with 893 lines in your changes missing coverage. Please review.

Project coverage is 81.15%. Comparing base (8841a3d) to head (9773453).

Files Patch % Lines
Examples/DnsSpoofing/main.cpp 0.00% 87 Missing ⚠️
Examples/IcmpFileTransfer/Common.cpp 0.00% 79 Missing ⚠️
Examples/HttpAnalyzer/main.cpp 53.74% 66 Missing and 2 partials ⚠️
...ples/IcmpFileTransfer/IcmpFileTransfer-pitcher.cpp 0.00% 64 Missing ⚠️
Examples/TcpReassembly/main.cpp 40.95% 62 Missing ⚠️
Examples/XdpExample-FilterTraffic/main.cpp 0.00% 57 Missing ⚠️
Examples/Arping/main.cpp 22.85% 54 Missing ⚠️
Examples/ArpSpoofing/main.cpp 0.00% 50 Missing ⚠️
Examples/DNSResolver/main.cpp 31.42% 48 Missing ⚠️
...ples/IcmpFileTransfer/IcmpFileTransfer-catcher.cpp 0.00% 48 Missing ⚠️
... and 14 more
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     
Flag Coverage Δ
fedora39 74.18% <37.86%> (-0.03%) ⬇️
macos-12 80.36% <51.01%> (+0.04%) ⬆️
macos-13 79.73% <50.19%> (+0.03%) ⬆️
macos-14 79.64% <50.19%> (+0.02%) ⬆️
mingw32 70.72% <ø> (+0.04%) ⬆️
mingw64 70.70% <ø> (ø)
npcap 83.96% <ø> (ø)
rhel94 73.89% <37.89%> (-0.06%) ⬇️
ubuntu2004 55.72% <23.78%> (-1.53%) ⬇️
ubuntu2004-zstd 55.87% <23.78%> (-1.50%) ⬇️
ubuntu2204 73.83% <37.73%> (-0.06%) ⬇️
ubuntu2204-icpx 55.85% <ø> (-0.04%) ⬇️
unittest 81.15% <43.62%> (-0.95%) ⬇️
windows-2019 83.97% <ø> (ø)
windows-2022 83.98% <ø> (ø)
winpcap 83.94% <ø> (ø)
xdp 48.72% <0.00%> (-0.08%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 26 to 31
{ "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 }
Copy link
Owner Author

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[] = {

Copy link
Owner Author

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 😕

Copy link
Collaborator

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.

Copy link
Owner Author

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 😕

Copy link
Collaborator

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
Copy link
Owner Author

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

Copy link
Collaborator

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.

Copy link
Owner Author

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

@tigercosmos
Copy link
Collaborator

@seladb precommit failed. did you check if your clang-format version correct?

@seladb
Copy link
Owner Author

seladb commented Jun 24, 2024

@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

@tigercosmos
Copy link
Collaborator

@seladb remember to update .pre-commit.config file for the tested files.

@seladb
Copy link
Owner Author

seladb commented Jun 28, 2024

@seladb remember to update .pre-commit.config file for the tested files.

Yes, that's a good point, thanks for the reminder!

@tigercosmos tigercosmos added this to the Augest 2024 Release milestone Jul 5, 2024
@tigercosmos tigercosmos mentioned this pull request Jul 7, 2024
9 tasks
Comment on lines +305 to +306
PTF_ASSERT_TRUE(std::any_of(ipAddresses.begin(), ipAddresses.end(),
[ipToSearch](pcpp::IPAddress const& addr) { return addr == ipToSearch; }));
Copy link
Owner Author

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

@seladb seladb marked this pull request as ready for review July 29, 2024 08:13
@@ -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)$
Copy link
Owner Author

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

@tigercosmos
Copy link
Collaborator

@seladb If you have gone through all the files, I will approve the PR.

@seladb
Copy link
Owner Author

seladb commented Jul 29, 2024

@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

Copy link
Collaborator

@tigercosmos tigercosmos left a 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.

@seladb seladb merged commit 09f479f into dev Jul 30, 2024
38 checks passed
@seladb seladb deleted the clang-format-for-examples branch July 30, 2024 03:07
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.

2 participants