Code Inspections in C++
In C++, ReSharper 2017.1 provides two kinds of code inspections: 183 inspections that detect errors such as broken syntax, unresolved symbols, compiler errors, etc. (you cannot configure or disable any of these inspections), and 118 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 in the following categories:
- Common Practices and Code Improvements (13 inspections)
- Compiler Warnings (9 inspections)
- Potential Code Quality Issues (73 inspections)
- Redundancies in Code (23 inspections)
Common Practices and Code Improvements (13 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 |
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 |
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 (9 inspections)
Inspections in this section 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 |
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 |
Potential Code Quality Issues (73 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 |
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 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 |
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 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-reclaimed resource acquisition | Hint |
Non-safe resource acquisition | Hint |
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 |
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-statements 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 |
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 |
Using the result of an assignment as a condition | Warning |
Redundancies in Code (23 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 |
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 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 |