Resharper (Find and) fix all issues at once

25,042

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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

Share:
25,042
Cel
Author by

Cel

Contact: http://www.linkedin.com/pub/kristjan-laane/40/9b0/698

Updated on July 12, 2022

Comments

  • Cel
    Cel almost 2 years

    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.

  • tsells
    tsells over 12 years
    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.
  • Tim Lloyd
    Tim Lloyd over 12 years
    @tsells I've been doing this for years, it's FINE.
  • tsells
    tsells over 12 years
    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.
  • Tim Lloyd
    Tim Lloyd over 12 years
    @tsells The question is about automating code cleanup, if you have issues with this, then please comment on the QUESTION, not on my ANSWER.
  • Cornelius
    Cornelius over 12 years
    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.
  • Admin
    Admin almost 12 years
    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.
  • Jura Gorohovsky
    Jura Gorohovsky almost 12 years
    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.
  • Admin
    Admin almost 12 years
    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.
  • Mark
    Mark over 11 years
    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.
  • joncodo
    joncodo over 11 years
    Is this still not fixed with resharper 7?
  • Jura Gorohovsky
    Jura Gorohovsky over 11 years
    @JonathanO Nope, still not implemented.
  • Jeff
    Jeff over 10 years
    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.
  • thomas nn
    thomas nn about 10 years
    @JonathanO Nope, still not fixed in Resharper 8 :(
  • Dan Is Fiddling By Firelight
    Dan Is Fiddling By Firelight about 10 years
    R#er 8's new Fix in Scope feature looks like it can do mass fixes for at least some types of issues: blog.jetbrains.com/dotnet/2013/10/14/…
  • Jura Gorohovsky
    Jura Gorohovsky about 10 years
    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.
  • stricq
    stricq about 8 years
    It's still not available in ReSharper 10!
  • RJB
    RJB almost 8 years
    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.
  • Jura Gorohovsky
    Jura Gorohovsky almost 8 years
    @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.
  • Coxy
    Coxy almost 8 years
    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!
  • Jura Gorohovsky
    Jura Gorohovsky almost 8 years
    @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: blog.jetbrains.com/dotnet/2012/09/28/…)