Summary
Several files are currently excluded from RuboCop metrics checks due to their complexity. These could be refactored to meet the standards while maintaining functionality.
Files to Refactor
lib/classifier/extensions/vector.rb
SV_decomp method (46 lines, high complexity)
- Contains nested loops for SVD algorithm
- Consider extracting helper methods
lib/classifier/lsi/content_node.rb
raw_vector_with method (28 lines, high complexity)
- Multiple conditionals for GSL vs pure Ruby
- Consider strategy pattern or separate implementations
lib/classifier/lsi.rb
build_index method (high ABC size)
- Complex matrix operations
- Consider breaking into smaller methods
Goals
RuboCop Compliance
- Reduce method length to ≤25 lines
- Reduce ABC size to ≤30
- Reduce cyclomatic complexity to ≤10
Test Coverage
- Add unit tests for extracted helper methods
- Improve branch coverage for GSL vs native paths
- Target 95%+ line coverage for refactored files
RBS Type Signatures
- Add/update type signatures in
sig/ for refactored methods
- Ensure new helper methods have proper type annotations
- Validate with
rbs -I sig validate
Other Requirements
- Maintain 100% backward compatibility
- Keep performance characteristics
- Document complex algorithms inline
Approach
- Extract helper methods for repeated logic
- Use early returns to reduce nesting
- Consider strategy pattern for GSL vs native paths
- Add inline documentation for complex algorithms
- Write tests for new helper methods before refactoring
- Update RBS signatures as methods are extracted
Related
Follow-up from #56 (RuboCop integration)
Summary
Several files are currently excluded from RuboCop metrics checks due to their complexity. These could be refactored to meet the standards while maintaining functionality.
Files to Refactor
lib/classifier/extensions/vector.rb
SV_decompmethod (46 lines, high complexity)lib/classifier/lsi/content_node.rb
raw_vector_withmethod (28 lines, high complexity)lib/classifier/lsi.rb
build_indexmethod (high ABC size)Goals
RuboCop Compliance
Test Coverage
RBS Type Signatures
sig/for refactored methodsrbs -I sig validateOther Requirements
Approach
Related
Follow-up from #56 (RuboCop integration)