Skip to content

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

Merged
maxulysse merged 23 commits into
nf-core:mainfrom
maxulysse:refactor/decompose-methods
Nov 12, 2026
Merged

maxulysse merged 23 commits into
nf-core:mainfrom
maxulysse:refactor/decompose-methods

Conversation

@maxulysse

@maxulysse maxulysse commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Split the 1,841-line Methods.java into focused utility classes, implement the ignored additionalPatterns option, and make archive download failures fatal.

  • Methods.java (581 lines): the public API, registered through extensionMethods; owns every overload, default and Groovy options map, and delegates with typed parameters to one entry point per operation. All public signatures kept, including filterNextflowOutput(LinkedHashMap, Object) and filterNextflowOutput(Object, Map)
  • HashUtils: the single MD5 implementation (was duplicated 3x); listToMD5() no longer declares NoSuchAlgorithmException
  • YamlUtils: YAML reading and key removal; wildcard paths resolved with Files.newDirectoryStream
  • FileTraversalUtils: getAllFilesFromDir, getAllFilesFromPath, getAllFilesFromChannel, getRelativePath; one PathFilter, walk() and Utils.buildMatchers() (also used by OutputSanitizer) replace the duplicated include/exclude checks; also lists S3 paths
  • NextflowOutputFilter: precompiled rule tables and small helpers replace the 127-line method; additionalPatterns matches are now removed from every line, and an invalid regex prints a warning and is skipped
  • ArchiveDownloader: curlAndExtract() downloads with curl --fail to a temporary file, then extracts, and throws IOException on failure; the URL overload derives the compression from the file name, and one TAR_FLAGS table handles the compression types, case-insensitive; downloadFromS3() uses Utils.runProcess and takes only the URI
  • NfCoreUtils: nfcoreInstall reads each module spec, then makes one installModule call; installModule throws IOException with the exit code, command and stderr; nfcoreInstall still prints it, so a failed install stays non-fatal
  • TableUtils: owns DEFAULT_DOUBLE_DIGITS and DEFAULT_REMOVE_COMMENTS, used by Methods and OutputSanitizer
  • Raw types (List) replaced by List<?> / List<String> in public signatures
  • docs/usage.md: document additionalPatterns; fix the filterNextflowOutput placeholders and sorted lines; downloadFromS3 needs Nextflow, not the AWS CLI, and reads public buckets without noSignRequest (Nextflow falls back to anonymous access)
  • Tests: NextflowOutputFilterTest (additionalPatterns, (Object, Map) overload), ArchiveDownloaderTest (tar, HTTP error, truncated and corrupt downloads, compression aliases, unsupported URL extensions)

Tested with mise tools: 34 JUnit tests, 45 nf-tests on Nextflow 26.04.9, filterNextflowOutput nf-tests on 26.10.5.

Generated via opencode and mistral-ai
Verified by @maxulysse

🤖 Generated with Claude Code

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
maxulysse and others added 10 commits September 11, 2026 15:52
Carry 1.2.1 (tableMD5Keys, normalizeTable, tableRemoveComments) into the
decomposed structure: SanitizeOptions reads the table options, Methods and
OutputSanitizer take defaults from TableUtils.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- restore filterNextflowOutput(Object output, Map options): it was not a
  duplicate of the (LinkedHashMap, Object) overload, argument order differs
- additionalPatterns removes matches instead of replacing them with
  [FILTERED], like the built-in rules; only catch PatternSyntaxException
- keep the install command in the installModule error message
- revert SanitizeOptions: same behaviour, ~150 lines of getters; keep
  the shared DEFAULT_TABLE_DOUBLE_DIGITS
- HashUtils: one hex loop, md5Hex delegates to listToMD5
- CHANGELOG: keep past releases as on main (history rewrite goes to its
  own PR), document behaviour changes under Unreleased
- add NextflowOutputFilterTest

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and S3 code

- Methods owns all overloads and defaults; utility classes expose one entry point each
- FileTraversalUtils.PathFilter and walk() replace the duplicated include/exclude checks; S3 listing moves there from ArchiveDownloader
- NextflowOutputFilter uses precompiled rule tables and small helpers
- ArchiveDownloader downloads with curl --fail to a temp file, then extracts; one TAR_FLAGS table handles compression types
- downloadFromS3 uses Utils.runProcess; HashUtils no longer throws NoSuchAlgorithmException
- TableUtils owns the table defaults used by Methods and OutputSanitizer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maxulysse added a commit that referenced this pull request Nov 11, 2026
* docs: add PR links and authors to past CHANGELOG entries

Backfill PR numbers and contributors for 0.0.1-1.2.1, fix release
attribution, and drop the brackets from release headings (no link
references are defined for them).

Moved out of #90, where it was unrelated to the refactor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: link each CHANGELOG release to its GitHub release

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: credit #61 and #81 to @prototaxites, their GitHub author

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: drop release link definitions from the CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: add the PR link to the tableRemoveComments CHANGELOG entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
maxulysse and others added 8 commits November 11, 2026 13:34
…lution

- Methods parses every Groovy options map; FileTraversalUtils, NextflowOutputFilter and ArchiveDownloader take typed parameters only
- downloadFromS3 no longer passes its unused options map down
- YamlUtils resolves wildcards with Files.newDirectoryStream, which closes the listing and keeps the I/O error's cause
- NextflowOutputFilter compiles the userName pattern once

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oadFromS3 docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…number

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Request

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… nfcoreInstall

- curlAndExtract(url, dest) derives the compression from the file name and delegates; curlAndUntar and curlAndUnzip are inlined
- nfcoreInstall reads the module spec first, then makes a single installModule call
- HashUtils formats the digest with BigInteger instead of a hand-written hex loop

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maxulysse
maxulysse merged commit 9a04027 into nf-core:main Nov 12, 2026
5 checks passed
maxulysse added a commit that referenced this pull request Nov 13, 2026
* feat: extract() archives from local paths, URLs and S3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: add PR number to CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: warn when the deprecated curlAndExtract() is called

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: extract() takes optional dest and compression named arguments

Without dest, extract() uses a temporary directory deleted at exit;
it returns the directory either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: name the extract() directory option extractDir

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: reject unknown extract() options, create extractDir only for a valid type

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: name the extraction directory extractDir in ArchiveExtractor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: extract file:// URLs in place, download other URLs with nextflow fs cp

Drops curl: nextflow fs cp reads http(s), ftp and cloud URLs, and fails
on HTTP errors and truncated transfers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: report downloadFromS3() failures through runOrThrow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: drop curl from the CHANGELOG, extract() downloads with nextflow fs cp

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: bring extract() prose up to date

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: restore the #90 CHANGELOG entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants