"Remove Redundant Qualifier" quick-fix enhancement?

I know I've asked for similar enhancements elsewhere, but this one just
keeps affecting me and it would be really a great addition and save me a ton
of time:

I've taken over someone else's old code, and it's literally FILLED with
redundant qualifiers everywhere (mostly "this." but also others).

It is a serious pain to click on the light-bulb and select "remove redundant
qualifier" for each and every one of them, when there can be dozens in the
file I'm working on.

But likewise, I only want to touch the code in the file I'm actually working
on.  I don't want to make the change everywhere all at once... this is
legacy code and I'd like to keep my changes, when I make them, focused.

What I want is an option on that light-bulb pop up to "Remove all redundant
qualifiers in file".  Is that possible, doable, or feasable?  Even if it
were more limited, like "Remove all redundant qualifiers LIKE THIS in file"
(which in this specific case, would remove all "this." qualifiers, but leave
other redundant qualifiers alone), that would be fine.

And more generally, there are dozens of times when I've looked at the
quick-fix menu pop-up, and wished for a "perform this quick-fix for every
linke of code in this file that has this particular issue".  I would LOVE to
see this enhancement.

Anyone else?


5 comments
Comment actions Permalink

Hello,

For these specific redundancies, the Code Cleanup would probably do. It could
be run just on the current file, or a folder, or the whole solution.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0
Comment actions Permalink

I have to respectfully disagree.  I want to be able to do this right where I
am, not have to put everything away, go somewhere else, and fiddle around
with code cleanup settings to ensure it does exactly what I want, then run
it, and then come back to where I was.  "Code Cleanup" is just way too
heavy-weight, and it requires too much manual setup, when the quick-fix
already knows exactly what I want, when I want, where I want.

This really belongs there, not in a heavy-weight function like code-cleanup.
Having to create a new profile just for what is likely a one-off task seems
rather over-kill, don't you think?

As I've said, I can't count the number times I've wanted this feature...
usually for specific things (not a general "clean up ALL things", but "do
this one specific quick-fix everywhere in this file").  Again, it's not
something that seems appropriate for "Code Cleanup" with all its heavy
set-up requirements... especially, again, given the quick fix has ALL the
information necessary right there.  All I need is one click.

Can you please reconsider?  There are LOTS of quick-fixes that could use
this... not just "remove redundant qualifier".  I used that as an example
because that's the one I'm hitting now where I really am feeling the lack of
this simple ability.

"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf1559888cccbdfa1733952@news.intellij.net...

Hello,

>

For these specific redundancies, the Code Cleanup would probably do. It
could be run just on the current file, or a folder, or the whole solution.

>


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”

>

1
Comment actions Permalink

Hello,

Actually, I do not think running Full Cleanup is really that complicated.
It fits well the task described.

As for the quick-fixes feature, there's nothing to reconsider yet, just because
it has not been decided on ;) I think the current status is "nice to have
if we can think up a decent UI, keep from ruining random code in some distant
part of the file, and have time to implement it". It's not getting into R#
5.1, and I have no info on any following versions. The Code Cleanup suggestion
is just a possible workaround in the current situation where the feature
is not present yet.

I think it could be considered a nice idea for a PowerToy R# plugin, though.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0
Comment actions Permalink

I think the code cleanup is way too complicated for this.  And I'm just
spent some time trying to figure out how to do it, and couldn't.

So, rather than a single click, I have to break the flow of what I'm doing,
go to the ReSharper menu, select tools, then select "Cleanup Code", then
click "Edit Profiles', then click "Add" and type in a new name... and ...
then I can't figure out what to do to get it to remove a redundant "this",
but not touch anything else.  And even if I could, how many "profiles" would
I have to have to cover each possible case?  And then have to distribute out
all those saved profiles out to other developers so they could benefit too?

Again, just one click vs. all that?  Never mind that if it's possible to use
Cleanup Code for this, I can't figure out how.

So please enter this as a suggestion for a feature enhancement I guess.  It
seems so obvious and simple and NECESSARY to me.  And I know I've asked for
it for a long time, and can't understand why "Cleanup Code" is always the
answer for why it gets rejected.

In my mind it's really simple:

When I click on a quick fix, such as "remove redundant Qualifier", simply
have one more item in the drop down (or possibly two more):  "remove all
redundant qualifiers like this in file".  The optional second would be
"remove all redundant qualifiers in file" (which would remove not only
"this." but any others).  Since ReSharper already knows all the locations
where this needs to happen (they're all marked/flagged in the error bar,
along with the exact error/warning) it should be simple enough to just
iterate over them and apply the selected action to them, as if I had
manually gone down clicking every light bulb and making the same fix
selection manually on each one.

So the UI should be already there... just add one (or two) new items to the
existing light-bulb pop-up menu.  Even if the only option were "remove all
redundant qualifiers in file", that would be a huge help.  But I really want
the "fix all issues like this specific case" option, to fix the same issue
everywhere it occurs, without necessarily doing "too much".  The "like this"
option may not make sense in other cases, but there are certainly other
warnings/quick-fixes where a "do this for all instances of this issue in
this file" makes perfect sense.

And placing it right there, where you're working, doesn't in any way break
the flow of coding.  It's fast, efficient, and reduces a ton of manual labor
(right now, I'm clicking on flagged code, then going over to hover so the
light-bulb pops up, then clicking on it, then selecting the correct fix....
and then repeating that between a dozen and four dozen times in each file).
It's painful.  And "Code Cleanup" seems like a sledge-hammer tool when what
I really want is an X-Acto Knife.... something fast, precise, and specific.
Exactly the kind of thing ReSharper excels at.


"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf1559ce8cccbf79d3b8bc0@news.intellij.net...

Hello,

>

Actually, I do not think running Full Cleanup is really that complicated.
It fits well the task described.

>

As for the quick-fixes feature, there's nothing to reconsider yet, just
because it has not been decided on ;) I think the current status is "nice
to have if we can think up a decent UI, keep from ruining random code in
some distant part of the file, and have time to implement it". It's not
getting into R# 5.1, and I have no info on any following versions. The
Code Cleanup suggestion is just a possible workaround in the current
situation where the feature is not present yet.

>

I think it could be considered a nice idea for a PowerToy R# plugin,
though.

>


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”

>

1
Comment actions Permalink

I'll probably sound indecisive here, but I agree with both of you. It would
be really nice to be able to select a quick fix and have it apply that quick
fix everywhere in the current code file or in the current class. I inherited
a lot of code over the years as well (most of it just utterly sloppy as can
be) and the way I currently handle this is with Code Cleanup using a profile
I named "Safe Cleanup". This is my default profile, so I can quickly apply
it just by pressing Ctrl+K, F.  The only options I have enabled with this
profile are:

Arrange 'this' qualifier
Make field read-only if possible
Optimize 'using' directive
Shorten qualified references
Reformat code
Use 'var' in declaration: do not change

I've found these to be about the safest settings to use when working with a
foreign code base that won't break or alter the code and that fix the
majority of the formatting issues with the code.  Having said this, there
are some rare situations I've run into in which ReSharper breaks the code
with either the Arrange 'this' qualifier or the Shorten qualified
references; specifically, a local variable or a base class member named the
same as a member variable will conflict causing a compiler error. When this
happens, I jump to the error, undo the changes with Ctrl+Z, and inspect the
code to find out why it conflicted.

What this does not do (and I wish it would!) is remove redundant base class
references so it doesn't help one iota if the code has hundreds of
base.whatever references and it does not fix any other issues that could be
handled with a quick fix (e.g. using object initializers). However, this
usually applies enough quick fixes and cleans up the code sufficiently that
most of the remainder need to be handled manually anyway with the obvious
omission of removing all those glaring base references that drive me
bananas.

"Paul Bradshaw" <pbradshaw@advsol.com> wrote in message
news:htmbvk$9a0$1@nntp-server.labs.intellij.net...

I think the code cleanup is way too complicated for this.  And I'm just
spent some time trying to figure out how to do it, and couldn't.

>

So, rather than a single click, I have to break the flow of what I'm
doing, go to the ReSharper menu, select tools, then select "Cleanup Code",
then click "Edit Profiles', then click "Add" and type in a new name... and
... then I can't figure out what to do to get it to remove a redundant
"this", but not touch anything else.  And even if I could, how many
"profiles" would I have to have to cover each possible case?  And then
have to distribute out all those saved profiles out to other developers so
they could benefit too?

>

Again, just one click vs. all that?  Never mind that if it's possible to
use Cleanup Code for this, I can't figure out how.

>

So please enter this as a suggestion for a feature enhancement I guess.
It seems so obvious and simple and NECESSARY to me.  And I know I've asked
for it for a long time, and can't understand why "Cleanup Code" is always
the answer for why it gets rejected.

>

In my mind it's really simple:

>

When I click on a quick fix, such as "remove redundant Qualifier", simply
have one more item in the drop down (or possibly two more):  "remove all
redundant qualifiers like this in file".  The optional second would be
"remove all redundant qualifiers in file" (which would remove not only
"this." but any others).  Since ReSharper already knows all the locations
where this needs to happen (they're all marked/flagged in the error bar,
along with the exact error/warning) it should be simple enough to just
iterate over them and apply the selected action to them, as if I had
manually gone down clicking every light bulb and making the same fix
selection manually on each one.

>

So the UI should be already there... just add one (or two) new items to
the existing light-bulb pop-up menu.  Even if the only option were "remove
all redundant qualifiers in file", that would be a huge help.  But I
really want the "fix all issues like this specific case" option, to fix
the same issue everywhere it occurs, without necessarily doing "too much".
The "like this" option may not make sense in other cases, but there are
certainly other warnings/quick-fixes where a "do this for all instances of
this issue in this file" makes perfect sense.

>

And placing it right there, where you're working, doesn't in any way break
the flow of coding.  It's fast, efficient, and reduces a ton of manual
labor (right now, I'm clicking on flagged code, then going over to hover
so the light-bulb pops up, then clicking on it, then selecting the correct
fix.... and then repeating that between a dozen and four dozen times in
each file). It's painful.  And "Code Cleanup" seems like a sledge-hammer
tool when what I really want is an X-Acto Knife.... something fast,
precise, and specific. Exactly the kind of thing ReSharper excels at.

>
>

"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf1559ce8cccbf79d3b8bc0@news.intellij.net...

>> Hello,
>>
>> Actually, I do not think running Full Cleanup is really that complicated.
>> It fits well the task described.
>>
>> As for the quick-fixes feature, there's nothing to reconsider yet, just
>> because it has not been decided on ;) I think the current status is
>> "nice to have if we can think up a decent UI, keep from ruining random
>> code in some distant part of the file, and have time to implement it".
>> It's not getting into R# 5.1, and I have no info on any following
>> versions. The Code Cleanup suggestion is just a possible workaround in
>> the current situation where the feature is not present yet.
>>
>> I think it could be considered a nice idea for a PowerToy R# plugin,
>> though.
>>
>> —
>> Serge Baltic
>> JetBrains, Inc — http://www.jetbrains.com
>> “Develop with pleasure!”
>>
>>

0

Please sign in to leave a comment.