53

e.g. alt enter -> context menu -> Find all 'Redundant name qualifier' issues -> but now in the new window that lists all those issues in my project, is there a way to fix them all ? (rather than go through them individualy)

ta.

Cel
  • 6,467
  • 8
  • 75
  • 110
  • 2
    In case anyone still stumbles across this: You can do this now, since Resharper 8.0. Apparently it's called the "Fix in Scope" feature. – Flo Sep 03 '13 at 12:44
  • 1
    Just tried to use this feature but it's severely limited. See: http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Fix_in_Scope.html – Karle Oct 08 '13 at 21:39
  • Fix in Scope seems pretty strong now. I'm using ReSharper 9. – Brian MacKay Dec 29 '14 at 18:50
  • Use Indexer still isn't in scope for fix in scope :-( – Squirrel Apr 21 '15 at 14:04
  • I've started using some of Resharper's bulk fix functions, but, I'm still really disappointed that so few fixes can be applied in bulk. There are so many problems that it can detect that it can't fix across a project/solution. The other feature is a feature that lets you know which features can be bulk applied. I have only found the bulk fix features by hunting around on forums like this. Another annoying thing is that it opens up every single file as a document in Visual Studio which is a pointless waste of resources and slows down the performance. – Christian Findlay May 02 '17 at 01:12

5 Answers5

34

For now, you have to go through the issues individually. There's an existing request to batch-apply fixes to all similar issues selected in the "Inspection Results" tool window.

Code Cleanup does batch-remove certain issues in any given scope but it's quite limited in the number of fixes it can apply, compared to the number of code issues that ReSharper is able to detect.

Jura Gorohovsky
  • 9,886
  • 40
  • 46
  • 26
    it is incredible that this option is not available. Having similar issues in a list, the menu of fix options would be the same, so this is pretty easy to implement. –  May 08 '12 at 16:31
  • This is relatively easy to implement in basic cases only (many of which Code Cleanup already covers). When there's a single warning that can be fixed when multiple different quick-fixes, that's when things get interesting. – Jura Gorohovsky May 09 '12 at 22:21
  • yes, I would add that the simplest case is the most usual, so maybe a "limited edition" of that functionality would be a great addition to Resharper. Moreover, this is specially frustrating when you try to review code quality of a non-owned application with 100K+ Lines. –  May 10 '12 at 06:50
  • 1
    Is this still not fixed with resharper 7? – joncodo Sep 13 '12 at 18:51
  • @JonathanO Nope, still not implemented. – Jura Gorohovsky Sep 22 '12 at 14:00
  • 1
    @JonathanO Nope, still not fixed in Resharper 8 :( – thomas nn Feb 20 '14 at 12:17
  • 1
    R#er 8's new Fix in Scope feature looks like it can do mass fixes for at least some types of issues: http://blog.jetbrains.com/dotnet/2013/10/14/fix-in-scope-a-new-code-cleanup-experience-in-resharper-8/ – Dan Is Fiddling By Firelight Apr 10 '14 at 14:33
  • 2
    Dan, that's correct, thanks for noting this. We're also developing Fix in Scope further for 9.0. For example, we've already implemented mass naming fixes. – Jura Gorohovsky Apr 10 '14 at 17:53
  • 1
    It's still not available in ReSharper 10! – stricq Jan 31 '16 at 03:45
  • 2
    Really? 5 years and 4 versions later, we still have to Alt+Enter every single squiggly? Even when it's all listed right there? Can't just select multiple -> alt + enter? Beyond lame. – RJB May 06 '16 at 18:00
  • 1
    @RJB You still can't fix issues from the Inspection Results window but there's a lot of inspections that you can batch-fix from the Alt+Enter menu. See John Crowell's answer for an example. – Jura Gorohovsky May 07 '16 at 11:08
  • 2
    It seems incredible to me that they implemented the whole "Find similar issues" functionality only to have an Inspection Results window that is completely useless. Really, export? Why would I ever want to do that! – Coxy May 24 '16 at 07:46
  • @Coxy Believe it or not, there are people who use export to share ReSharper inspection results with non-ReSharper users (we blogged about this in the past: http://blog.jetbrains.com/dotnet/2012/09/28/resharper-71-early-access-is-open/) – Jura Gorohovsky May 24 '16 at 17:26
26

Click into a redundant qualifier, alt+enter, then choose from the context menu that lets you fix the issue however thoroughly you'd like.

Resharper options to remove redundant qualifier

I'm running ReSharper 8.2.

enter image description here

Jon Crowell
  • 21,695
  • 14
  • 89
  • 110
17

Yes, you can use ReSharper's "Cleanup Code" to remove redundant qualifiers (amongst other things). This is available from the context-menu when you right-click files, projects and folders in the Solution Explorer window. Code Cleanup will run over all the selected files, reformatting and fixing common issues - it is also customizable.

Tim Lloyd
  • 37,954
  • 10
  • 100
  • 130
  • 8
    If you are going to use code correct features such as this I highly recommend that you do a diff on each file changed and confirm the changes. I would NEVER run something like this on production code without a line by line inspection (changes) after running it. – tsells Sep 02 '11 at 15:03
  • 4
    @tsells I've been doing this for years, it's FINE. – Tim Lloyd Sep 02 '11 at 15:06
  • 4
    I would disagree. Every piece of software has the potential for bugs. What happens when the next release of resharper contains some unknown race condition that your code happened to raise. Now your code will still compile - but depending on what changes to your code were made - you may now have a bug in your code that your clients will suffer for. You should never check in code without knowing EXACTLY what changes were made. – tsells Sep 02 '11 at 15:17
  • @tsells The question is about automating code cleanup, if you have issues with this, then please comment on the QUESTION, not on my ANSWER. – Tim Lloyd Sep 02 '11 at 15:18
  • 5
    Except that your answer throws a subtactical cleanup nuke on the code that addresses way more issues than the original "Fix this kind of errors". I agree with tsells that you should not blindly check in all the changes ReSharper believes are The Right Thing without making sure it actually is the right thing. – Cornelius Oct 12 '11 at 09:24
  • Just adding that "Cleanup Code" can be executed by Ctrl+E, C. Also, in the "Cleanup Code" options for Resharper, you can create a profile of the cleanup methods you want Resharper to perform. That way you're not blindly running all of the preconfigured options, you can figure out what they're doing first. – Mark Aug 23 '12 at 12:55
  • 4
    I agree with the caution expressed, however I also agree with @TimLloyd that, unless you're using reflection (including serialization; ESPECIALLY BinaryFormatter), you will be fine. I would even go so far as to argue that if your code can't "withstand" a ReSharper cleanup, you're doing something else wrong. – Jeff Oct 16 '13 at 03:21
7

This is available (in part) in the latest build. If you go to a specific issue in the code editor, click the lightbulb the fix option now has a submenu for some issues that can be applied to the entire solution. Would be cooler if it was available from the Code Issues window, but still a great improvement.

New Fix in Scope Options https://www.jetbrains.com/help/resharper/2016.1/Code_Analysis__Fix_in_Scope.html

James White
  • 2,062
  • 2
  • 24
  • 36
-2

No use for Resharper Just Go To Visual Studio

Analyze Menu Code Cleanup Menu Run Code ....tion

And Complate