Resumen:
Reducing the Cognitive Complexity of a piece of code to a given threshold is not trivial. Recently, we modeled Software Cognitive Complexity reduction as an optimization problem and we proposed an approach to assist developers on this task. This approach enumerates sequences of Extract Method refactoring operations until a stopping criteria is met. As result, it returns the minimal sequence of Extract Method refactoring operations found that is able to reduce the Cognitive Complexity of a method to the given threshold. However, enumeration algorithms fail to scale with the code size. The number of refactoring plans can grow exponentially with the number of lines of code. In this paper, instead of enumerating sequences of Extract Method refactoring operations, we model the Cognitive Complexity reduction as an Integer Linear Programming optimization problem. This makes it feasible to use solvers, like CPLEX, to efficiently find optimal solutions in large programs.