Skip to content

refactor: decompose Methods.java into focused utility classes - #90

Open
maxulysse wants to merge 12 commits into
nf-core:mainfrom
maxulysse:refactor/decompose-methods
Open

refactor: decompose Methods.java into focused utility classes#90
maxulysse wants to merge 12 commits into
nf-core:mainfrom
maxulysse:refactor/decompose-methods

Conversation

@maxulysse

@maxulysse maxulysse commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Methods.java was 1,790 lines mixing 7+ concerns. This PR breaks it into 5 utility classes, extracts a typed options model from OutputSanitizer, and fixes three code-quality blockers from review.

New classes

Class Lines Responsibility
HashUtils 82 Single MD5 implementation (was duplicated 3x)
YamlUtils 194 YAML reading and key manipulation
ArchiveDownloader 460 curl/zip/tar extraction and S3 downloads
FileTraversalUtils 443 Directory walking, file collection, path resolution
NextflowOutputFilter 402 Nextflow output line filtering and sanitization

Changes to existing files

  • Methods.java: 1,790 → 488 lines. Delegation facade with section dividers. All public signatures preserved.
  • OutputSanitizer.java: Extracted SanitizeOptions inner class. Moves 9 getOrDefault calls and validation out of the 100-line sanitizeOutput method.
  • NfCoreUtils.java: Removed duplicate MD5, uses HashUtils.md5Hex(). installModule now throws IOException on failure instead of swallowing it.
  • CsvUtils.java: Removed duplicate MD5, uses HashUtils.md5Hex(). Owns DEFAULT_DOUBLE_DIGITS as single source of truth.
  • ArchiveDownloader.java: curlAndUntar and curlAndUnzip now throw IOException on failure instead of logging and returning silently.

Also fixed

  • Deleted duplicate filterNextflowOutput(Object, Map) adapter (identical to the LinkedHashMap variant)
  • Fixed raw types (ListList<?> / List<String>) in public API signatures
  • Consolidated DEFAULT_CSV_DOUBLE_DIGITS (was duplicated in Methods and OutputSanitizer)

Deferred

  • Consolidate two MD5 implementations within HashUtils
  • Decompose NextflowOutputFilter.filterNextflowOutput 127-line method
  • Extract shared buildMatchers(List<String>) helper (duplicated 3x)

Verification

  • 24/24 unit tests pass
  • Checkstyle, PMD, SpotBugs: clean

Generated via opencode and mistral-ai
Verified by @maxulysse

maxulysse and others added 4 commits September 11, 2026 15:44
Methods.java was 1,790 lines mixing 7+ concerns. Extract 5 new classes:
- HashUtils: consolidate 3 duplicate MD5 implementations
- YamlUtils: YAML reading and manipulation
- ArchiveDownloader: curl/zip/tar extraction and S3 downloads
- FileTraversalUtils: directory walking and file collection
- NextflowOutputFilter: output line filtering and sanitization

Methods.java is now a 488-line thin delegation facade.
Delete duplicate filterNextflowOutput Groovy adapter.
Update NfCoreUtils and CsvUtils to use HashUtils.
The sanitizeOutput method was ~100 lines with 9 getOrDefault calls
and inline validation. Extract a SanitizeOptions inner class to
centralize option parsing and validation.
- Fix raw types: List -> List<?> / List<String> in FileTraversalUtils
  and Methods public API
- Fix silent exception swallowing: ArchiveDownloader.curlAndUntar,
  curlAndUnzip, and NfCoreUtils.installModule now throw IOException
  on failure instead of logging and returning silently
- Consolidate DEFAULT_CSV_DOUBLE_DIGITS: single source of truth in
  CsvUtils.DEFAULT_DOUBLE_DIGITS, referenced by Methods and
  OutputSanitizer
- Implement missing additionalPatterns filtering in NextflowOutputFilter
  (was lost during refactoring, now properly applies regex patterns to output)
- Consolidate MD5 implementations in HashUtils:
  - Extract shared byteToHex(byte) helper method
  - Use consistent hex conversion in both md5Hex() and listToMD5()
  - Change listToMD5 parameter from ArrayList<Object> to List<?> for type safety
  - Align exception handling (NoSuchAlgorithmException instead of UnsupportedEncodingException)
- Update Methods.java delegation to match new HashUtils signature

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@maxulysse
maxulysse force-pushed the refactor/decompose-methods branch from 5b73088 to 2634f2a Compare September 11, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant