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

Improve existing code quality #85

Closed
bokket opened this issue Mar 17, 2021 · 1 comment
Closed

Improve existing code quality #85

bokket opened this issue Mar 17, 2021 · 1 comment

Comments

@bokket
Copy link

bokket commented Mar 17, 2021

C++ has some static detection tools, I use the open source cppcheck to check the current code quality.It is not satisfactory, it will cause some performance loss,at least we have to be able to achieve effective c++ in some aspects.I'm already working and researching this,I will list a few rules,but I will follow the contribution guidelines #7, if you have no objections, please allow me to do this.@hsluoyz @xcaptain

1.Class object has a constructor with 1 argument that should use Keyword:explicit.
2.Exception should be caught by reference.
https://stackoverflow.com/questions/2522299/c-catch-blocks-catch-exception-by-value-or-reference
3.Prefer prefix ++/-- operators for non-primitive types.
https://stackoverflow.com/questions/631506/does-pre-and-post-increment-decrement-operators-in-c-have-same-performance-in
4.Variable is assigned in constructor body. Consider performing initialization in initialization list.
https://stackoverflow.com/questions/9903248/initializing-fields-in-constructor-initializer-list-vs-constructor-body
5.Function parameter value should be passed by reference.
https://stackoverflow.com/questions/10231349/are-the-days-of-passing-const-stdstring-as-a-parameter-over
6.Applying size_type as a subscript when using string and vector or use the Keyword auto
https://stackoverflow.com/questions/1181079/stringsize-type-instead-of-int
7.The byte defined in the ip_parse folder has been implemented in the std library as std::byte, which is recommended to be written as Byte
8.Avoiding c-style type casting
https://stackoverflow.com/questions/3278441/c-type-casting
https://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-const-cast-and-reinterpret-cast-be-used/332086#332086
and so on...

There are some things not mentioned, I will continue to add, submit pr after the test

@xcaptain
Copy link

I think we can following modern C++ coding guide line, no need to keep compatible with old C style.

This was referenced Mar 23, 2021
@bokket bokket closed this as completed Apr 4, 2021
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

No branches or pull requests

2 participants