arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2402.05559cs.SEcs.CC
收藏

通过整数线性规划自动化软件认知复杂度降低

Automatizing Software Cognitive Complexity Reduction through Integer Linear Programming

Rubén Saborido, Javier Ferrer, Francisco Chicano

AI总结:

本文针对代码认知复杂度降低问题,提出将重构操作序列建模为整数线性规划,利用高效求解器替代穷举枚举,以实现在大规模程序中的最优解。

摘要:

将一段代码的认知复杂度降低到给定阈值并非易事。近期,我们将软件认知复杂度降低建模为一个优化问题,并提出了一种辅助开发者完成此任务的方法。该方法枚举代码提取重构操作的序列,直到满足停止标准。最终,它返回能够将代码认知复杂度降低到给定阈值的最短代码提取重构操作序列。然而,穷举枚举算法在代码规模增大时无法扩展。重构计划的数量可能随代码行数呈指数级增长。在本文中,我们不枚举代码提取重构操作的序列,而是将认知复杂度降低建模为整数线性规划问题。这为使用高效求解器在大规模程序中寻找最优解打开了大门。

英文摘要:

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 code extraction refactoring operations until a stopping criterion is met. As a result, it returns the minimal sequence of code extraction refactoring operations that is able to reduce the cognitive complexity of a code to the given threshold. However, exhaustive 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 code extraction refactoring operations, we model the cognitive complexity reduction as an Integer Linear Programming problem. This opens the door to the use of efficient solvers to find optimal solutions in large programs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑