Resharper: How to hide suppressed warnings in Inspection Results? - vb.net

I suppressed a Resharper warning in a VB.NET class file (*.vb). As expected, the warning is not highlighted at the border of the text editor.
If I show all Resharper warnings for my project I would expect that the suppressed warning is neither shown in the Inspection Results view. However, it is shown, see screen shot.
How to I hide warnings in the InspectionResults that are suppressed in the code with an annotation?
I am using Resharper 8.2.3
(If you have issues with public properties in respect to xaml bindings also see this related question: Resharper says OnPropertyChange set member can be private while not true)

This appears to be a bug in ReSharper. It works as expected (that is, the suppressed warning does not appear in the find results) if you use the disable and restore style comments, rather than the disable once comments. I.e.:
' ReSharper disable MemberCanBePrivate.Global
Public Property Foo As String
' ReSharper restore MemberCanBePrivate.Global
I've raised an issue that you can track and vote on: https://youtrack.jetbrains.com/issue/RSRP-444615

Related

Where is the setting for highlighting unused variables and constants in Visual Studio 2022?

I am working in a C# project where this has been turned off.
I can't find out how to turn it on again.
It's pretty hard to google as it's default behavior, and no sane person would turn it off...
Did you perhaps change your compiler warning level?
Unused variables should have the warning of CS0168. If you look at that page, the title is "Compiler Warning (level 3) CS0168".
In solution explorer, right click your project and go to Build and check your Warning Level:
If you set it to anything lower than three, then the CS0168 warnings will never be shown. Also, just below the drop down is a suppress warnings text box. Make sure you don't have CS0168 in that text box.
Are you using an .editorconfig file?
If you are using an .editorconfig file, you may have suppressed this particular warning. Removing that suppression should resolve this as well. It would look something like this in your .editorconfig file:
[*.cs]
# CS0168: Variable is declared but never used
dotnet_diagnostic.CS0168.severity = none

Highlight things marked as obsolete

I recently did some refactoring in our code and marked some widely-used functions as obsolete. The problem now is, that I get not visual indicator when I use an obsolete function right away. I have to hover over the function call to get the popup with further information about that function, and even there the "deprecated" warning is not very prominent. As these functions are to widely-used and cause no real treat, setting the isError property is not an option.
I know that somewhere I saw obsolete functions that were highlighted with some kind of underlining, but I can not find an option that does that. Where is that option, or how else can I achieve a more eye-catching indication?
I have created a simple toy VB.Net console application in MSVS, as you can see in the image the items marked obsolete are underlined in green where they are used.
If you are not seeing this then you will need to provide some more details on your solution's settings - what type of project is it, what version of visual studio are you opening it in, is it the same version it was created in, do you have any third party code linter (eg ReSharper) in use... etc
EDIT: As you mention in your comment, the project's properties, including the Code Analysis settings, will affect whether this underlining show's correctly or not; you will need to ensure the correct rule-set is selected there.

suppress an unused variable warning

How can I suppress the inspection in Kotlin for an unused variable
val xyz = abc
I get the squiggly line but ALT-ENTER is useless for this, I tried also to create in another method several variables unused and they also lack the ALT-ENTER ability to ignore the warning. Although I have definitely used ALT-ENTER for this in the past, although maybe it was only in java, can't remember.
So I must manually construct it by hand. I've been trying several variations but I can't get anything to work. Please tell me the correct //noinspection or #SupressWarnings to use, thanks
In IntelliJ IDEA, a right-side arrow on an ALT+ENTER context menu (like this: ) means that you can use your arrow keys to navigate further along the menu. In this case, it leads to your answer:
#Suppress("UNUSED_VARIABLE")
val unused = ""
If you do not get the initial context menu (Remove variable '...'), you may have disabled the "Unused assignment" inspection in your current project. You can fix this by going to Settings -> Editor -> Inspections.

Resharper: how to suppress warning "Field xy is never used" in XAML

I want to suppress a warning in my xaml file. I applied the corresponding quick fix option to "Disable once warning by comment". However, the warning
is still active. How do I correctly suppress the warning? I would like to keep the name because it tells something about the purpose of the element. (An alternative would be to remove the name and use a comment.)
Edit
The issue is only valid vor Resharper version Build 8.2.0.2160.
After updating to 8.2.3 the suppression works correctly. (And in version 9 the warning does not seem to be active by default.) Thanks to citizenmatt.
The issue is still shown in the Inspection Results view, see related question Resharper: How to hide suppressed warnings in Inspection Results?
In this special case it makes more sense to use the Tag attribute (thanks to Mike Eason) or to use a comment to write the name instead of using a comment to suppress the warning.
This looks like an issue with an older version of ReSharper. You can update to the latest version of 8.x (8.2.3) or ReSharper 9 (the 9.2 EAP has just released EAP3). It appears to have fixed the issue.

Disable IntelliJ Warnings

It really annoys me that IntelliJ highlights certain 'errors' (that don't prevent successful compilation) the same way that real errors are highlighted. For example, a magic number is not really an error, but it will be flagged in exactly the same way as an incompatible type error.
How can I change this?
Go to Settings -> Inspections. Then you need to search through the long list for the offending inspection, which you can get the name of by hovering on the warning marker in the margin. You can change the severity of the inspection, whether it's an error, warning, etc. or just disable it altogether.
Edit: if you search for "magic" in Settings, you get the following, which should be helpful:
Whenever you see an inspection warning/error you can place the caret on it and press Alt+Enter (a light bulb also appears that tells you that). A menu will appear with suggested quick fixes. You may need to open a submenu by pressing Right, and you'll find "Edit inspection settings" there. Having invoked that, you may proceed as in hvgotcodes's answer :), it's just a faster way of getting to those settings.
As Michael Calvin said you can use the SuppressWarnings annotation. For example:
#SuppressWarnings("OptionalUsedAsFieldOrParameterType")
See https://github.com/JetBrains/intellij-community/blob/master/plugins/InspectionGadgets/src/inspectionDescriptions/OptionalUsedAsFieldOrParameterType.html
Usually searching the internet for the exact description leads me to this.
Not directly relevant to the OP, but may be of use to future Googlers
I got to this question while trying to figure out how to disable IntelliJ IDEA's warnings about Guava functionalities that have been replaced by Java 8 features. I'm not able to use the Java 8 versions of these features in my case because of a library we're using that was built with Guava (despite being a Java 8 project). So to solve that, I added a SuppressWarnings annotation before any class using Guava:
#SuppressWarnings(Guava)
public final class...