Exclude class name with wildcard from code inspection

Hi,

Is it possible to exclude specific names from code inspection? I have a C++ class that is a const pointer internally, but code inspection suggest that the local variable should be made const. It would be helpful to keep that suggestion for other local variables except the ones with a specific class name, such as FooConstPointer.

5 comments
Comment actions Permalink

Hello,

Unfortunately this is not possible right now. Could you please attach a snippet which demonstrates this problem? Does the code break if you make the local variable const, or do you not want to do that just because of stylistic reasons?

Thanks!

1
Comment actions Permalink

Hi,

A simplified version would be:

template <class T>

struct FooConstPointer {

const T* ptr;

};

The main reason we don't want to have the const keyword for this specific class is mostly readability and style, but I was surprised that there is no way to ignore certain rules for variables with a specific name in general.

0
Comment actions Permalink

ReSharper has a lot of different inspections that operate on different code entities, so it's not clear how a general suppression mechanism like you suggest would work. In your case you probably want to ignore variables of a specific type, not with a specific name. We probably could add a custom C++ class attribute to suppress immutability inspections similar to what was done in https://youtrack.jetbrains.com/issue/RSCPP-18764. Note that this custom attribute would be understood only by R++. Would that work for you?

0
Comment actions Permalink

Hi, what you suggested seems like a useful solution for this case. Hopefully it gets added.

0

Please sign in to leave a comment.