Code Inspections in C++
In C++, ReSharper 2017.3 provides two kinds of code inspections: 207 inspections that detect errors such as broken syntax, unresolved symbols, compiler errors, etc. (you cannot configure or disable any of these inspections), and 1030 proprietary code inspections, any of which you can disable or change its severity level.
These code inspections help you detect code issues in design time in all open files, and additionally they allow you to find code issues in specific scope.
Configurable C++ inspections are listed below, grouped by their categories.
Clang Diagnostics (611 inspections)
Inspections in this category correspond to Clang compiler warnings integrated with ReSharper C++.Clang Static Analyzer Checks (78 inspections)
Inspections in this category are diagnostics from Clang Static Analyzer integrated with ReSharper C++.All static analyzer checks are disabled by default, since enabling them significantly slows down Clang-Tidy.
Clang-Tidy Checks (203 inspections)
Inspections in this category are provided by Clang-Tidy — a powerful open-source code analysis tool integrated with ReSharper C++.Common Practices and Code Improvements (15 inspections)
This category groups inspections that hunt for medium severity issues that mainly affect code readability.Inspection | Default Severity |
---|---|
Compile-time constant expression can be replaced with either 'true' or 'false' | Suggestion |
Constructor of smart pointer used instead of its make function | Suggestion |
C-style cast used instead of a C++ cast | Suggestion |
Function returns by const value | Suggestion |
Local variable may be 'const' | Suggestion |
Member function may be 'const' | Suggestion |
Member function may be 'static' | Suggestion |
Non-explicit conversion operator | Hint |
Non-explicit converting constructor | Hint |
Order of member initializers does not match the initialization order | Suggestion |
Overriding function without 'override' specifier | Suggestion |
Parameter may be 'const' | Hint |
Result of a postfix operator is discarded | Suggestion |
Throw expression can be replaced with a rethrow expression | Warning |
Zero constant can be replaced with nullptr | Suggestion |
Compiler Warnings (12 inspections)
Inspections in this category detect compiler warnings before you compile.Inspection | Default Severity |
---|---|
Default initialization of a const-qualified object of a type without a user-provided default constructor | Warning |
Explicit specialization in non-namespace scope | Warning |
Precompiled header is not found | Error |
Precompiled header is not included | Error |
Redeclaration of a template parameter from an outer scope | Warning |
Reference class member with 'mutable' specifier | Warning |
Static assertion failure | Error |
Unexpected syntax element | Warning |
Uninitialized dependent base class | Warning |
Union member of reference type | Warning |
Use of an incomplete type inside a template | Warning |
User-defined literal suffixes must start with an underscore | Warning |
Constraints Violations (1 inspection)
This category includes code inspections, mostly with the warning severity level, which detect violations related to symbol attributes, including ReSharper's code annotations, and other similar issues.Inspection | Default Severity |
---|---|
Inconsistent Naming | Hint |
Potential Code Quality Issues (84 inspections)
This category includes inspections that detect critical issues (code smells), mostly with Error or Warning level. This category also includes inspections that ensure localization assistance.Inspection | Default Severity |
---|---|
Adding cv-qualifiers to references has no effect | Warning |
Assigned value is never used | Warning |
Backslash and newline separated by space | Warning |
Bad format code for boost::format | Warning |
Binary operator acts on equal operands | Warning |
Binary operator acts on identical operands | Warning |
Binding r-value to l-value reference is non-standard Microsoft C++ extension | Warning |
Call to a virtual function inside a constructor/destructor will be statically resolved | Warning |
Call to a virtual function inside a constructor/destructor will result in a pure virtual function call | Error |
Casting from nullptr to pointer type with reinterpret_cast is non-standard Microsoft C++ extension | Warning |
Class is never used | Warning |
Class member function hiding a non-virtual function from a base class | Warning |
Class needs a user-defined constructor because of an uninitialized data member | Warning |
Declaration does not declare anything | Warning |
Declaration of a non-overriding virtual function in a final or sealed class | Warning |
Declaration specifier with no declarators | Warning |
Declarator disambiguated as a function declaration | Warning |
Declarator is never used | Warning |
Declarator is only assigned but never accessed | Warning |
Declarator is reassigned in all paths before being read | Warning |
Declarator is used only in unevaluated context | Warning |
Default case is not handled in a switch statement | Warning |
Deleting a void pointer | Warning |
Dependent template without 'template' keyword | Warning |
Dependent type without 'typename' keyword | Warning |
Deprecated register storage class specifier | Warning |
Dereference operator limit is exceeded | Warning |
Entity is deprecated | Warning |
Enumerator is never used | Warning |
Expression which evaluates to zero is used as a null pointer constant | Warning |
Function is not implemented | Warning |
Hiding local declaration | Warning |
Implicit conversion to incompatible pointer type | Warning |
Implicit conversion to less qualified pointer type | Warning |
Implicit default constructor is not available | Warning |
Implicit integer to pointer conversion | Warning |
Implicit pointer to integer conversion | Warning |
Incrementing expression of type bool | Warning |
Invalid printf format specifier | Warning |
Keyword 'default' is used as identifier | Warning |
Legacy format code for boost::format | Suggestion |
Local variable is never used, but may have side-effects in its destructor | Disabled |
Local variable might not be initialized | Warning |
Local variable used without being initialized | Error |
Mismatched class tags | Warning |
Missing function parameter description in a documentation comment | Suggestion |
Missing include guard | Warning |
Mixed serial and positional arguments for boost::format | Error |
More than one implicit conversion applied during copy-initialization. This is non-standard Microsoft C++ extension | Warning |
No return statement in a function returning non-void | Warning |
Non-consistent resource acquisition-reclaim pair | Warning |
Non-inline function definition in a header file | Warning |
Non-inline variable definition in a header file | Warning |
Non-reclaimed resource acquisition | Hint |
Non-safe resource acquisition | Hint |
Non-static data member is unitialized | Warning |
Non-virtual class member function hidden in a derived class | Warning |
Not all control paths return a value | Warning |
Not enough arguments in a call to boost::format | Error |
Not enough arguments in a call to printf | Error |
Object member might not be initialized | Warning |
Override function redefines a default parameter argument | Warning |
Parameter is always rewritten in function body before being read | Warning |
Parameter is never used | Hint |
Polymorphic class with non-virtual public destructor | Warning |
Possibly erroneous empty-statements | Warning |
Possibly erroneous expression without side-effects | Warning |
Possibly erroneous incomplete switch-statement | Warning |
Possibly uninitialized class member | Warning |
Possibly unintended object slicing | Warning |
Possibly unused #include directive | Warning |
Private special member function is not implemented | Warning |
Probably invalid printf format specifier | Warning |
Probably unintended incompatible reference type in range declaration | Warning |
Slash symbol used in #include directive doesn't match code style settings | Hint |
Some object members might not be initialized | Warning |
Static data member in an anonymous class is not allowed by the C++ standard | Warning |
Syntax error in doxygen comment | Warning |
Taking an address of class r-value is non-standard Microsoft C++ extension | Warning |
Too many arguments in a call to boost::format | Warning |
Too many arguments in a call to printf | Warning |
Unresolved reference in doxygen comment | Warning |
Unused result of a nodiscard function | Warning |
Using the result of an assignment as a condition | Warning |
Redundancies in Code (26 inspections)
Code inspections in this category look for redundancies and dead code, which affect code readability and style, and could be safely removed. Some code redundancies cannot be fixed automatically, and quick-fixes for them are performed in the interactive mode, requiring the user input. But the majority of the redundancies can be fixed without user interaction, using either fix in scope or code cleanup.Inspection | Default Severity |
---|---|
Access specifier does not affect any declaration | Suggestion |
Access specifier does not change accessibility level | Hint |
Const-qualified parameter in a function declaration | Suggestion |
Declaration and assignment can be joined | Suggestion |
Guarded header has already been included | Hint |
Move operation without noexcept specification | Warning |
Qualifier is redundant | Hint |
Redundant argument in conditional expression | Warning |
Redundant base class access specifier | Hint |
Redundant control flow jump statement | Hint |
Redundant 'else' keyword | Hint |
Redundant 'else' keyword inside compound statement | Hint |
Redundant empty declaration | Hint |
Redundant empty statement | Hint |
Redundant 'inline' specifier | Hint |
Redundant member initializer in constructor initialization list | Suggestion |
Redundant parentheses | Hint |
Redundant 'static' specifier on a member allocation/deallocation function | Hint |
Redundant 'static' specifier on an anonymous namespace member | Suggestion |
Redundant 'template' keyword | Warning |
Redundant 'typename' keyword | Warning |
Redundant 'virtual' specifier on an override function | Hint |
Redundant void argument list | Suggestion |
Unreachable code | Warning |
Use 'auto' | Hint |
Volatile-qualified parameter in a function declaration | Suggestion |