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

Fix cppcheck postfix operator issues #1251

Merged
merged 20 commits into from
Dec 14, 2023
Merged

Conversation

egecetin
Copy link
Collaborator

@egecetin egecetin commented Dec 2, 2023

Most of the postfix warnings comes from old iterator based for loops so replaced them with auto to help #977

Copy link

codecov bot commented Dec 2, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (660843e) 82.42% compared to head (e38dfa1) 82.41%.
Report is 1 commits behind head on dev.

Files Patch % Lines
Pcap++/src/PcapLiveDeviceList.cpp 58.33% 6 Missing and 4 partials ⚠️
Pcap++/src/PcapRemoteDeviceList.cpp 0.00% 8 Missing ⚠️
Pcap++/src/PcapLiveDevice.cpp 37.50% 3 Missing and 2 partials ⚠️
Packet++/src/BgpLayer.cpp 84.00% 3 Missing and 1 partial ⚠️
Common++/header/PointerVector.h 83.33% 0 Missing and 1 partial ⚠️
Packet++/src/SdpLayer.cpp 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1251      +/-   ##
==========================================
- Coverage   82.42%   82.41%   -0.01%     
==========================================
  Files         161      161              
  Lines       20750    20737      -13     
  Branches     7832     7838       +6     
==========================================
- Hits        17103    17091      -12     
+ Misses       2979     2977       -2     
- Partials      668      669       +1     
Flag Coverage Δ
alpine317 72.22% <60.60%> (-0.02%) ⬇️
centos7 74.33% <61.45%> (-0.01%) ⬇️
fedora37 72.18% <60.60%> (-0.01%) ⬇️
macos-11 61.11% <50.98%> (-0.03%) ⬇️
macos-12 61.17% <50.98%> (-0.02%) ⬇️
macos-ventura 61.20% <50.00%> (+0.02%) ⬆️
mingw32 70.06% <57.00%> (-0.04%) ⬇️
mingw64 70.10% <57.00%> (-0.04%) ⬇️
npcap 83.15% <72.38%> (-0.05%) ⬇️
ubuntu1804 74.80% <62.24%> (+0.03%) ⬆️
ubuntu2004 72.99% <61.61%> (-0.02%) ⬇️
ubuntu2204 72.06% <61.00%> (-0.01%) ⬇️
ubuntu2204-icpx 59.11% <49.01%> (-0.02%) ⬇️
unittest 82.41% <73.63%> (-0.01%) ⬇️
windows-2019 83.20% <72.38%> (-0.01%) ⬇️
windows-2022 83.20% <72.38%> (-0.02%) ⬇️
winpcap 83.18% <72.38%> (+<0.01%) ⬆️
xdp 58.68% <47.00%> (-0.02%) ⬇️
zstd 73.56% <61.76%> (+<0.01%) ⬆️

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.

}

totalLen++;
int totalLen = std::accumulate(m_ColumnWidths.begin(), m_ColumnWidths.end(), m_ColumnWidths.size() * 3) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more clearer!

@tigercosmos
Copy link
Collaborator

@egecetin I would suggest not using iter directly. Instead, it would be better to use a meaningful name for each element.

@egecetin egecetin marked this pull request as ready for review December 9, 2023 17:20
@egecetin egecetin requested a review from seladb as a code owner December 9, 2023 17:20
@egecetin egecetin requested a review from clementperon December 9, 2023 17:20
Copy link
Owner

@seladb seladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see one small comment, otherwise approved!

}

totalLen++;
int totalLen = std::accumulate(m_ColumnWidths.begin(), m_ColumnWidths.end(), m_ColumnWidths.size() * 3) + 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe use auto for totalLen and for the for loop later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seladb What about this e38dfa1 ? I also removed for loop and use string constructor

@egecetin
Copy link
Collaborator Author

egecetin commented Dec 14, 2023

A not important note, I noticed there are still some postfix operators not generating warnings. For example you mentioned a for loop in #1251 (comment) which has index++ as increment operator. I try to fix all of I noticed but probably some of them will raise warning/error at a point where cppcheck or pre-commit updated.

@egecetin egecetin merged commit 5fa0f7d into seladb:dev Dec 14, 2023
39 checks passed
@egecetin egecetin deleted the fix-postfix branch December 14, 2023 11:37
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.

3 participants