Accessing static member variables through class instances can give the impression that the member belongs to the instance, which is incorrect. This can lead to confusion and make the code harder to understand and maintain. To fix this issue, simply replace the instance access with the class name followed by the member variable. This clearly indicates that the member is a static member of the class and avoids any confusion.
Local variable declarations with more than one variable in a single statement can lead to confusion and make the code harder to read. It is recommended to refactor the code to have one declaration per statement, with each statement on a separate line.
Incorrect indentation and missing braces can lead to code that is difficult to read and understand which can result in developers spending more time identifying issues in the code.
Classes, structs, and unions containing redundant member (field and method) access specifiers can lead to code that is more difficult to read and maintain.
Found a subscript expressions on the STL container that can be further simplified directly using subscript operator.
std:string
or std::string_view
is redundant CXX-C2023Initializing std::string
or std::string_view
with an empty string is unnecessary and can be considered redundant. This is redundant because both types already have a default constructor that performs necessary initialization. Also, by removing the redundant initialization, the code becomes cleaner and more concise.
std::string
to C-style string CXX-C2024Found conversion of a std::string
to a C-style string using the c_str()
or data() methods. This is unnecessary and can lead to potential memory issues while also being less efficient. To fix this issue, use
std::string` directly without converting it to a C-style string.
std::unique_ptr
's raw pointer while deleting the pointer CXX-C2020Accessing the raw pointer of a std::unique_ptr
and calling delete
on it is unnecessary as std::unique_ptr
provides API to do it safely. To fix this issue, replace delete <unique_ptr>.release()
with <unique_ptr> = nullptr
. This is a shorter and simpler way to reset the std::unique_ptr
and ensures that the object is properly deallocated.