The invention discloses an effective code measurement method based on an AST
abstract syntax tree. The effective code measurement method comprises the following steps that S1,
source code files before and after change in a code warehouse are read; s2, tree transformation is carried out on the obtained
source code file through ASTs, and tree ASTs before and after change are generated respectively; s3, traversing the tree-shaped AST before the change and the tree-shaped AST after the change, and generating a Tree diff change node through comparison; and S4, performing weighted calculation according to the generated Tree diff change node type to obtain an effective code quantity. Through AST-level comparison, semantic changes, such as code reconstruction (such as method movement) and function modification, which are difficult to detect by a traditional diff tool can be accurately identified,
noise, such as spaces and dead codes, of a
source code level can be eliminated, a compilation optimization technology can be applied, and evaluation is more accurate.