You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run rubocop --auto-correct on a project for the first time, it normally fixes dozens of offenses but then, if I run rubocop --auto-correct again (immediately, without making any other changes) it finds additional offenses that it didn’t catch the first time.
I think what’s happening is that one cop is making corrections in a way that introduces new offenses for a different cop. Adding auto-correct to more cops may make this problem even worse.
Here is a concrete example:
defcallraiseNotImplementedError,'Method #call should be overridden in child classes'end
If I run rubycop --auto-correct on this code, the following offense will be automatically fixed:
SignalException: Use `fail` instead of `raise` to signal exceptions.
This will result in a method that looks like this:
defcallfailNotImplementedError,'Method #call should be overridden in child classes'end
This method now contains a new offense, which didn’t exist before auto-correcting:
AlignParameters: Align the parameters of a method call if they span more than one line.
If I run, rubycop --auto-correct again, this offense will be fixed:
defcallfailNotImplementedError,'Method #call should be overriden in child classes'end
This is the correct outcome but it shouldn’t require running rubocop --auto-correct twice.
I believe this is happening because fail is one letter shorter than raise and the SignalException cop only changes the keyword itself, not the alignment of parameters that span multiple lines.
Arguably, this is just a defect in the autocorrect method of the SignalException cop but I believe there are other examples of this as well. I will update this issue as I find them.
The text was updated successfully, but these errors were encountered:
When I run
rubocop --auto-correct
on a project for the first time, it normally fixes dozens of offenses but then, if I runrubocop --auto-correct
again (immediately, without making any other changes) it finds additional offenses that it didn’t catch the first time.I think what’s happening is that one cop is making corrections in a way that introduces new offenses for a different cop. Adding auto-correct to more cops may make this problem even worse.
Here is a concrete example:
If I run
rubycop --auto-correct
on this code, the following offense will be automatically fixed:This will result in a method that looks like this:
This method now contains a new offense, which didn’t exist before auto-correcting:
If I run,
rubycop --auto-correct
again, this offense will be fixed:This is the correct outcome but it shouldn’t require running
rubocop --auto-correct
twice.I believe this is happening because
fail
is one letter shorter thanraise
and theSignalException
cop only changes the keyword itself, not the alignment of parameters that span multiple lines.Arguably, this is just a defect in the
autocorrect
method of theSignalException
cop but I believe there are other examples of this as well. I will update this issue as I find them.The text was updated successfully, but these errors were encountered: