Code Complexity Scoring via Entity Context Analysis
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code complexity metrics fail to effectively consider contextual changes and variations within a code base, leading to difficulties in understanding, modifying, and reusing code, as they evaluate the code as a unified mass without accounting for the evolution and context of new lines of code introduced over time.
Innovation Solution
A system and method to determine code complexity scores by identifying code entities and context changes within a code unit, using a formula that incorporates the count of entities, context changes, and code lines, and applying relevancy filters to exclude irrelevant entities, enabling context-aware complexity assessments and generating rework recommendations.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Device complexity
If code complexity metrics evaluate the code base as a unified mass, then the measurement process is simplified, but the ability to effectively consider contextual changes and variations is lost
Solution Approach 1:
The patent segments the code base into individual code entities (functions, classes, modules) and evaluates each entity's complexity separately. This allows the system to consider contextual changes and variations in each segment while maintaining manageable measurement processes through automated analysis of individual units.
2Ease of operation
If traditional code complexity metrics are used, then the assessment process is straightforward, but the difficulty in understanding, modifying, and reusing code increases
Solution Approach 1:
The system provides feedback by generating complexity scores and reports for individual code entities, highlighting areas with high complexity that may difficult to understand or modify. This feedback mechanism guides developers to focus on specific code segments that need refactoring or improvement.
3Device complexity
If code evolution and context of new lines are not considered, then the measurement process remains simple, but the accuracy of complexity assessment deteriorates
Solution Approach 1:
The system performs preliminary analysis by examining the evolution history and context of code entities before calculating complexity scores. It identifies changes, additions, and modifications in code over time, incorporating this contextual information into the complexity assessment to improve accuracy.
Data Source
AI summary
In one example of the disclosure, code lines for a software program are received, the code lines including a unit of code lines. Code entities within the unit are identified. Each code entity includes a line or consecutive lines of code implementing a distinct program requirement or defect fix for the program. Context changes are identified within the unit, each context change including an occurrence of a first code line set implementing an entity, adjacent to a second code line set implementing another entity, within a same code scope. A code complexity score is determined based upon counts of entities identified and context changes identified within the unit, and upon counts of code lines and entities within the program.


