A Java library for calculating class-level and method-level code metrics via static analysis, without requiring compiled code.
CK is a Java library and command-line tool that calculates a wide range of code metrics through static analysis of source code. It helps developers and researchers measure software quality attributes like coupling, cohesion, complexity, and size without needing to compile the code.
Java developers, software engineering researchers, and teams focused on code quality analysis, refactoring, and technical debt management.
CK provides a comprehensive, extensible, and accurate metric suite using pure static analysis, avoiding the overhead and dependencies of bytecode analysis, and is easily integrable into build pipelines or research workflows.
Code metrics for Java code by means of static analysis
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Calculates over 30 metrics including CBO, DIT, LCOM, and unique word counts, providing extensive insights into code quality without needing compilation, as detailed in the README.
Analyzes Java source code directly using Eclipse JDT, eliminating the dependency on compiled bytecode and simplifying setup, as it operates solely on .java files.
Uses Visitor and Factory patterns, allowing developers to easily add custom metrics by implementing ClassLevelMetric or MethodLevelMetric interfaces, making it adaptable for research or custom tools.
Can be run as a standalone command-line tool or integrated as a Maven dependency, catering to both ad-hoc analysis and automated CI/CD pipelines, with examples provided in the README.
The README notes that users may need to tune 'max files per partition' to avoid out-of-memory errors, indicating scalability issues with large projects and complex AST parsing.
As admitted in the README, some metrics like LCOM are not reliable, and others like RFC can fail in cases of method overloading, limiting accuracy for certain code patterns.
CK is limited to Java projects, so it cannot be used for multi-language codebases or other programming languages, restricting its applicability in polyglot environments.
Using JAR files for better type resolution requires manual configuration, and the tool may not handle all dependency scenarios seamlessly, as noted in the 'use jars' parameter description.