Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint check for System.exit calls #2211

Merged
merged 5 commits into from
Mar 28, 2023
Merged

Conversation

awgymer
Copy link
Contributor

@awgymer awgymer commented Mar 27, 2023

#1840 for more details

This implements a very simplistic check of all .nf and .groovy files in the pipeline repo for System.exit calls.

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@awgymer awgymer linked an issue Mar 27, 2023 that may be closed by this pull request
2 tasks
@awgymer
Copy link
Contributor Author

awgymer commented Mar 27, 2023

CI is proving this works 😂

╭─ [✗] 6 Pipeline Tests Failed ────────────────────────────────────────────────╮
│                                                                              │
│ system_exit: System.exit in WorkflowTestpipeline.groovy: System.exit(1)      │
│ system_exit: System.exit in WorkflowTestpipeline.groovy: System.exit(1)      │
│ system_exit: System.exit in NfcoreSchema.groovy: System.exit(1)              │
│ system_exit: System.exit in WorkflowMain.groovy: System.exit(0)              │
│ system_exit: System.exit in WorkflowMain.groovy: System.exit(0)              │
│ system_exit: System.exit in WorkflowMain.groovy: System.exit(1)              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

@awgymer
Copy link
Contributor Author

awgymer commented Mar 27, 2023

I think we should allow System.exit(0) - replacing it with an error doesn't really make sense and after discussion with @drpatelh it is only used for the help and version options, to exit cleanly without running.

cc @ewels as you created the parent issue

@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Merging #2211 (9626ae5) into dev (f3b5d1e) will increase coverage by 0.02%.
The diff coverage is 86.36%.

@@            Coverage Diff             @@
##              dev    #2211      +/-   ##
==========================================
+ Coverage   71.95%   71.98%   +0.02%     
==========================================
  Files          77       78       +1     
  Lines        8363     8384      +21     
==========================================
+ Hits         6018     6035      +17     
- Misses       2345     2349       +4     
Impacted Files Coverage Δ
nf_core/lint/system_exit.py 85.71% <85.71%> (ø)
nf_core/lint/__init__.py 74.28% <100.00%> (+0.10%) ⬆️

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@awgymer awgymer marked this pull request as draft March 27, 2023 14:56
@awgymer
Copy link
Contributor Author

awgymer commented Mar 27, 2023

Does this need an independent test? It is tested as part of the lint test pipeline?

@awgymer awgymer marked this pull request as ready for review March 27, 2023 16:02
@awgymer awgymer requested a review from mashehu March 27, 2023 16:15
@awgymer awgymer merged commit ceb3d40 into nf-core:dev Mar 28, 2023
@awgymer awgymer deleted the lint-system-exit branch March 28, 2023 14:00
@awgymer awgymer mentioned this pull request Mar 28, 2023
2 tasks
@ewels
Copy link
Member

ewels commented Mar 28, 2023

I think we should allow System.exit(0) - replacing it with an error doesn't really make sense and after discussion with @drpatelh it is only used for the help and version options, to exit cleanly without running.

I'm still a bit nervous about this. @pditommaso / @bentsherman - are System.exit(0) calls when we want to exit cleanly without an error exit code? Or is there a good alternative to error() that we can use when there is no error?

@bentsherman
Copy link

I think the exit() method is the standard way to exit with a given exit code: https://github.com/nextflow-io/nextflow/blob/7ce05c15f253059f5981f29ba85d4e16ab0b7620/modules/nextflow/src/main/groovy/nextflow/Nextflow.groovy#L183-L220

But as you can see it just logs an optional message and then calls System.exit()

Are you looking for something that calls the usual shutdown logic in the event of a workflow terminate or finish? I don't think there is a method for that.

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.

Don't use System.exit(1)
4 participants