I'm trying to suppress highlights in ReSharper using ReSharper Platform (not ReSharper product).
Some context:
Exceptional is a ReSharper plugin, that highlights undocumented exceptions among other useful things. In some cases, these highlights are safe to be "suppressed".
Currently, suppressing comments aren't working: https://github.com/CSharpAnalyzers/ExceptionalReSharper/issues/37
I can suppress it by looking for the suppression comments (e.g.: // ReSharper disable once ExceptionNotDocumented) and simply not adding the highlight to the DefaultHighlightingConsumer, however, I'm not convinced that the platform doesn't have a simpler way to do this.
Is there a simple way to make ReSharper consider these suppressing comments?
Thanks in advance.
With help from #citizenmatt I've finally come to the solution.
A change in the API (starting from 2016.1) has introduced a new HighlightConsumer implementation named FilteringHighlightConsumer. Using this implementation will consider all suppressing comments.
Here is the link to Matt's answer: https://resharper-support.jetbrains.com/hc/en-us/community/posts/206559159-10-1-EAP-and-RegisterConfigurableSeverity?flash_digest=1939ba6f66e30d494edb8f0d6a902eab4b198342
Related
Been getting into Android Studio (and Android development in general) lately, mostly a personal challenge to make a modern version of an app my mum loves but hasn't been updated in ages. But my life story isn't the point, and that's not just because it's not that interesting.
The actual question:
Is there a way to make Android Studio do automatic folding for block comments (i.e. /* to */) in Kotlin files? In Settings > Editor > Code Folding there's options for documentation (in general) and multiline comments for C or Java, but no settings specific to Kotlin, and just one for Android in general (which has nothing to do with comments).
The reasoning: Because I'm still pretty new at this, there's a lot of things I've tried but haven't worked, and comment out instead of deleting because I still might be able to learn something from them later. There's also some big blocks of logging code for debugging that are great when I'm trying to debug but in the way (given I usually write them in the middle of classes or methods) when I'm not, so I comment them out. It's just annoying having to fold several sections of comments whenever I open a file.
The "well duh" solution?: I could set them as documentation comments, which would hopefully get automatically folded, but if I start writing documentation (like I really should get around to) they'll get mixed in and that would be annoying.
What I've tried so far: Going through all the settings with a fine tooth comb (and I'll freely admit I could have gone over something obvious) and searched for plugins for code folding, about the only one I could find is https://plugins.jetbrains.com/plugin/12007-foldingplus which doesn't seem to do anything about this particular problem.
Can anyone help me out here, other than maybe "be less of a newbie in general"?
With Android Studio Arctic Fox I found that if you highlight a region that has the comments in question, you can right-click on it and one of the options will be Folding. From the expanded options select Fold Selection / Remove Region and the selected comments will fold.
For Resharper can't support Chinese well that all of my comment will be suggest changed.
But I don't think I need to do it.
Questions 1: how to disable the typo in the comment by Resharper?
Questions 2: where can I find the Chinese dictionary? I find wooorm/dictionaries but I can't find the Chinese dictionary.
Resharper 2018.2.1 bring the ReSpeller that just like with code analysis, ReSpeller scans for spelling mistakes and typos in identifiers, comments, string literals and more, and provides quick-fixes to resolve the problem.
To disable the typo in the comment by Resharper, you should click the Resharper and enter option.
You should select the Code Inspection->inspection severity and then you should type typo to search see this image.
You can toggle the Typo in comment to open or close it.
And the other way is to disable ReSpeller.
You should select ReSpeller and then you should uncheck it.
See Spell Checking with ReSpeller
Integrated spell checking with ReSpeller in ReSharper and Rider
hunspell/hunspell: The most popular spellchecking library.
Disable the typo by ReSharper
ReSharper → Options
Code Inspection → Inspection Severity
Search: Typo
Disable whatever you want
If you want to disable those once per class/interface, you can use the SuppressMessage Attribute (where CommentTypo is the inspection you asked for) like so:
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "IdentifierTypo")]
[SuppressMessage("ReSharper", "CommentTypo")]
public interface IHaveNoControlOverTheirApi
{
//...
}
You can also suppress code inspections in other scopes if you like.
Have a look at ReSharper's documentation on code inspections to see what kinds of inspections can be disabled.
For your question 1:
Maybe what you need is to turn off non-English spell checking only, not turn off all the comments spell checking. Unfortunately, ReSharper doesn't provide such an option to turn off only non-English spell checking.
I've reported this issue to its official document and you can see the discussions here: https://www.jetbrains.com/help/resharper/Spell_Checking.html
ReSharper has an issue to trace this problem: ReSpeller: Ignore Chinese and Japanese: RSPL-6949. So you can just wait for this improvement in the next bugfix.
For your question 2:
I can't find any Chinese dictionaries for spell checking.
The setting is under Resharper -> Options -> Environment -> ReSpeller reference the article below.
https://resharper-support.jetbrains.com/hc/en-us/community/posts/360000537679-Turn-off-Spellcheck-in-ReSharper-VS-2017
I am using ReSharper 7.
I have set up my Formatting style, and I want Resharper to generate warnings (amber light in vs) when this style is not adhered to. For example if we do not follow K&R method bracing style I want to see the amber light.
Is this possible? How would I do this?
You can generate warnings for invalid style by installing StyleCop for Resharper.
Whether StyleCop's default settings are suitable for you is another question.
How to setup ReSharper to call "Sort usings" in class?
I will answer for my question.
Using shortcut from Resharper it's not best solution. Nice tool is CodeMaid it makes few nice cleanup's when saving file like with no shortcut key press:
sorting usings alphabetically and remove unused
deleting empty lines
This tool is complement for Resharper.
Resharper (9) will sort usings if you run Code Cleanup, via menus or keyboard shortcut CTRL+E, CTRL+C
Try using the Stylecop Resharper Plugin
Stylecop Rule SA1210: Using directives must be sorted alphabetically by the namespaces will allow you to use a quick fix to sort them by pressing ALT+ENTER.
Using Stylecop is good at helping you write clean code, but you may want to turn off some of the rules.
You don't need ReSharper to do this. By Default the shortcut CTRL+E, R will remove (unused) and sort the using statements.
If you only want sorting or the shortcut isn't set on your instance of Visual Studio, go to:
Tools-> Options.
Environment -> Keyboard
Search for "Editor.ContextMenus.CodeWindow.OrganizeUsings".
There are a few options there to play with.
This question already covers this:
Remove unused Usings across entire assembly
The feature is in ReSharper 4.5. If you right click on the solution,
there's a Cleanup Code... item, which allows you to apply a cleanup
profile to the solution. You can create a new cleanup profile from the
Code Cleanup node within ReSharper options, if you want a profile to
just adjust the using directives.
I'm new to ReSharper.
For those who uses Resharper, is there a way I can add custom code analysis rules?
For example I might have a rule say All private variables should start with letter "m". How can I add this to Resharper so if I violate this, it can shows as a warning or an error?
I know the question is old, but for all folks coming from google like me:
Resharper -> Options -> Code inspections -> Custom Patterns
There you can create your own rules for highlighting patterns or offering substitutions. This is for ReSharper 8. I'm not sure from which version this option is there.
Just to expand on what #AakashM notes above: this can be specified in ReSharper Options | Languages | (either Common or C# or whatever) | Naming Style.
If you click on Advanced Settings, and then double-click on one of the "entity descriptions", there is a far larger selection of possible entities (including events, namespaces etc) , together with access rights (private, protected, etc) and so on, for which you can define prefix, suffix and casing rules.
You can write your own plugins for ReSharper. Take a look at here:
http://stylecopforresharper.codeplex.com/
This is similar to what you're asking for. It might even do what you want. Not sure since I'm not a big StyleCop user.
Also take a look at the first in my series of blog posts coming on ReSharper plugins:
http://hadihariri.com/2010/01/12/writing-plug-ins-for-resharper-part-1-of-undefined/