US 11,860,764 B2
Method, apparatus, and system for evaluating code design quality
Fei Peng, Beijing (CN); and Ke Han, Beijing (CN)
Assigned to SIEMENS AKTIENGESELLSHAFT, Munich (DE)
Appl. No. 17/441,781
Filed by Siemens Aktiengesellschaft, Munich (DE)
PCT Filed Mar. 26, 2019, PCT No. PCT/CN2019/079738
§ 371(c)(1), (2) Date Sep. 22, 2021,
PCT Pub. No. WO2020/191627, PCT Pub. Date Oct. 1, 2020.
Prior Publication US 2022/0179773 A1, Jun. 9, 2022
Int. Cl. G06F 11/36 (2006.01)
CPC G06F 11/3616 (2013.01) 13 Claims
OG exemplary drawing
 
1. A method for evaluating code design quality, comprising:
receiving a modification record of the code;
determining probabilities of error-prone patterns in a code based on a compound logic conditional expression including at least one of a result of static scanning of the code and the modification record, including at least one of,
determining a probability of an existence of a shotgun surgery based on a compound logic conditional expression including metrics of afferent coupling, efferent coupling and changing method,
determining a probability of an existence of a divergent change based on a compound logic conditional expression including metrics of revision number, instability and afferent coupling,
determining a probability of an existence of a big design up front based on a compound logic conditional expression including metrics of line of code, line of changed code, class number, changed class number and a statistical average of the metrics,
determining a probability of an existence of a scattered/redundant functionality based on a compound logic conditional expression including metrics of structure similarity and logic similarity,
determining a probability of an existence of a long method based on a compound logic conditional expression including a metric of cyclomatic complexity,
determining a probability of an existence of a complex class based on a compound logic conditional expression including metrics of line of code, attribute number, method number and maximum method cyclomatic complexity,
determining a probability of an existence of a long parameter list based on a compound logic conditional expression including a metric of parameter number, or
determining a probability of an existence of a message chain based on a compound logic conditional expression including a metric of indirect calling number;
inputting the probabilities of each of the error-prone patterns into an artificial neural network;
based on the artificial neural network, connecting the probabilities of each of the error-prone patterns to design principles;
based on the artificial neural network and the connections, determining a prediction result of whether the code violates the design principles and a quantified degree to which the code violates the design principles; and
evaluating the design quality of the code based on the prediction result.