Refactoring is not a process in my opinion. Because the process has a beginning and an end, the state (works / does not work / works malfunctioning) and workload, but there is no final goal.
I would define refactoring as a set of tasks from backlog, formed on the basis of bugs, feuures requsts and developers reports, which (tasks) include activities for
- reduce technical debt (remove todo, try / pass, monkey-patch),
- improvement of the code base (code style, documentation, comments, details of error messages, etc.),
- processing of the application architecture (adaptation of the general structure so that the crutches sticked to the side began to fit organically into the application, accelerate the work, optimize for resources, etc.)
- facilitating the development and onboarding,
- acceleration of the introduction of new features,
- Correcting bugs and unlocking business features and bugfixes,
- migrating to new versions of dependencies
In this case, refactoring does not set itself the goal of rewriting the application or a significant change in its behavior.
Metrics that can be considered are
- the complexity of the refactoring itself and checking its quality,
-% of changed code base and% of affected user scenarios,
- the number of introduced bugs and degradations,
- the number (unintentionally) of the fixed bugs,
- the number of business features and bugfixes unlocked by refactoring and
- The number of business features and bugfixes blocked by refactoring.
Checklist when you can / need to proceed
- at the beginning of the next release cycle before the introduction of any features (not after the features!)
- the presence of planned features that either are not realizable, or the laboriousness of their implementation on a bad code basis is comparable to the laboriousness of refactoring and implementation on an improved code base
- bugs that can not be fixed on the current architecture
- there are problems of onboarding of new engineers
- multiple complaints about those debts from developers / testers / managers / ..