$ show seattlerb/flog
Flog is a Ruby code complexity analyzer that calculates an ABC (assignments, branches, conditionals) complexity metric with Ruby-specific enhancements. It processes Ruby source files to identify complex/tortured code that is difficult to test and maintain. The system consists of a core Flog library that performs the analysis, a CLI interface for command-line usage, a Rake task for integration with build systems, and a plugin system for extensibility. The architecture cleanly separates concerns: the Flog class handles AST processing and scoring, FlogCLI manages option parsing and file discovery, and FlogTask provides Rake integration. Recent versions have switched to using the prism parser for improved performance while maintaining backward compatibility with a --legacy flag for RubyParser.
The LLM identified 2 files worth highlighting for reuse:
The core Flog class implements an ABC complexity metric with Ruby-specific enhancements and depth-based compounding penalties. It inherits from MethodBasedSexpProcessor to efficiently process Ruby AST nodes, calculates scores based on assignments, branches, and conditionals, and applies additional penalties for Ruby-specific patterns like to_proc usage and nested scopes. The implementation demonstrates expertise in AST traversal, metric calculation, and maintaining clean separation between processing, scoring, and reporting concerns.
FlogCLI provides a well-designed command-line interface with comprehensive option handling via OptionParser, intelligent file discovery using path_expander, and a plugin system for extensibility. It cleanly separates CLI concerns from core logic, handles edge cases like stdin input and syntax errors gracefully, and provides flexible reporting options (grouped, detailed, thresholded). The component showcases skill in building maintainable CLI tools with proper error handling, plugin architecture, and user-friendly output formatting.