Static code analysis is performed to analyze code quality, design, vulnerabilities, and bugs without executing the code. Types of static analysis include checking code style, security, errors, duplicates, secrets, comments, unused code, and complexity. Cyclomatic complexity measures code complexity more accurately than lines of code. It is calculated using McCabe's function based on the number of edges, nodes, and connected components in the control flow graph of the code. Higher complexity leads to reduced readability, testability, and maintainability. Checking complexity per method can provide insight into violations of principles like single responsibility. Keeping code simple, dry, and solid improves quality.
Related topics: