Code Quality Analysis via Complexity and Dependency Metrics
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Software developers face challenges in identifying and addressing low-quality source code that can hinder development processes, lead to unpredictable results, and be harmful to systems due to its complexity, high dependency, and low cohesion, which existing evaluation methods fail to adequately assess.
Innovation Solution
A system analyzes source code by determining complexity, dependency, and cohesion metrics to classify code groups as high-complexity, high-dependence, or low-cohesion, and flags them as low-quality, providing a user interface to alert developers and facilitate improvement.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If developers use legacy code and develop quickly to meet market demands, then productivity is improved, but code quality deteriorates resulting in unpredictable and harmful results
Solution Approach 1:
The system performs preliminary analysis of code quality metrics (complexity, dependency, cohesion) before code is deployed or causes problems. By evaluating code groups in advance using automated metrics collection and classification, the system enables developers to identify and fix low-quality code patterns before they lead to unpredictable behavior or system harm, thus maintaining both productivity and reliability.
2Adaptability or versatility
If developers create complex code to meet customer demands, then adaptability is improved, but code maintainability deteriorates
Solution Approach 1:
The system changes the parameters used to evaluate code by introducing specific metrics for complexity, dependency, and cohesion. By measuring these parameters automatically and comparing them against threshold values, the system can identify code groups that have become too complex to maintain. This enables objective assessment and refactoring decisions based on quantitative data rather than subjective judgment, helping maintain code quality even as adaptability requirements increase.
3Measurement precision
If existing evaluation methods are used to assess code quality, then some code attributes are measured, but low-quality code groups cannot be accurately identified
Solution Approach 1:
The system segments code into discrete code groups (such as classes, methods, or modules) and evaluates each segment independently using specific metrics. By dividing the overall codebase into manageable units and assessing their complexity, dependency, and cohesion separately, the system can accurately identify low-quality code groups without being overwhelmed by the complexity of the entire codebase. This segmented approach enables precise identification while keeping the evaluation process manageable.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
Methods, systems, and apparatus, including computer programs encoded on computer storage media, for identifying low-quality groups of source code. In one aspect, a method includes receiving code groups that each include source code. For each code group, a level of complexity of methods within the source code included in the code group is determined. A code group is classified as a high-complexity code group whenever the level of complexity satisfies a threshold. For each code group, a number of attributes of other code groups on which members of the code group depend is determined. A code group is classified as a high-dependence code group whenever the number of attributes of other code groups on which members of the code group depends satisfies a threshold. A code group is classified as a low-quality code group whenever the code group is a high-complexity code group and a high-dependence code group.