-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
Currently, our Elvis configuration disables several rules globally across all modules (e.g., max_module_length, max_function_length, etc.). This approach reduces code quality enforcement and misses opportunities to catch issues in modules that could easily comply with these rules.
Proposed Solution
Refactor the Elvis configuration to:
- Enable all rules by default with strict, reasonable limits
- Use per-module rule customization only where necessary via -elvis() attributes
- Split large modules to resolve structural issues like max_module_length and god_modules
- Document exceptions with clear reasoning for each per-module override
Benefits
- Higher code quality across the codebase
- Targeted exceptions only where genuinely needed
- Better maintainability by catching issues early
- Clearer intent when rules are disabled for specific modules
Implementation Plan
- Audit current disabled rules in elvis.config
- Identify modules that can be split (e.g., separate parsing logic, validation, optimization phases)
- Re-enable rules globally with appropriate thresholds
- Refactor large modules into smaller, focused modules where possible
- Add per-module overrides using -elvis() attributes only where splitting isn't feasible
- Document rationale for each exception in module comments
Module Splitting Strategy
For rules like max_module_length and god_modules:
- Extract related functionality into separate modules (e.g.,
arizona_parse_transform_validation.erl,arizona_parse_transform_optimization.erl) - Use behavior patterns to organize module responsibilities
- Maintain clear interfaces between split modules
Example
Instead of:
% elvis.config
{rules, [
{elvis_style, max_module_length, disable}
]}Use:
% elvis.config - strict by default
{rules, [
{elvis_style, max_module_length, #{max_length => 500}}
]}In specific modules that need exceptions:
% arizona_parse_transform.erl
-elvis([{elvis_style, max_module_length, #{max_length => 1000}}]).
% Large parse transform module due to comprehensive AST processingPriority
Medium - Improves code quality without blocking current development
Metadata
Metadata
Assignees
Labels
No labels