Code Analysis
Castalia's code analysis tools help you identify areas of your code which would benefit most from refactoring, and help you get a handle on the general quality of your code. Each procedure and function is analyzed using sophisticated metrics and a final "toxicity" score is derived:
In the Code Analysis Window, you can see key metrics for every function in your project:
- Length: The number of "lines" in the function, or more accurately, the number of code statements in the function.
- Parameter Count: The number of parameters in the function declaration.
- If Depth: The maximum depth of nested "if" statements in the function.
- Cyclomatic Complexity: The minimum number of independent code paths through the function. This is the minimum number of tests that would have to be executed in order to ensure that every line of code in the function is tested.
- Toxicity: Combines the above metrics to create a single value that quantifies how "toxic" the function is. Values greater than 1.0 are prime candidates for refactoring.
Castalia also includes a quickbar tool that shows the same metrics for the current function right in the code editor.