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

fix: adds a short sha representation to modules list command pointing to the repo specific commit #2870

Merged
merged 9 commits into from
Mar 18, 2024
Prev Previous commit
Next Next commit
Hyperlink module name and file path in lint results
ewels committed Mar 18, 2024
commit afaf2ff826eb039a7751d7e29b90a52b6c07f4b9
18 changes: 16 additions & 2 deletions nf_core/components/lint/__init__.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import rich.box
import rich.console
import rich.panel
import rich.repr
from rich.markdown import Markdown
from rich.table import Table

@@ -31,6 +32,7 @@ class LintExceptionError(Exception):
pass


@rich.repr.auto
class LintResult:
"""An object to hold the results of a lint test"""

@@ -42,6 +44,7 @@ def __init__(self, component, lint_test, message, file_path):
self.component_name = component.component_name


@rich.repr.auto
class ComponentLint(ComponentCommand):
"""
An object for linting modules and subworkflows either in a clone of the 'nf-core/modules'
@@ -231,9 +234,20 @@ def format_result(test_results, table):
if last_modname and lint_result.component_name != last_modname:
even_row = not even_row
last_modname = lint_result.component_name

# If this is an nf-core module, link to the nf-core webpage
if lint_result.component.repo_url == "https://github.com/nf-core/modules.git":
module_name = f"[link=https://nf-co.re/modules/{lint_result.component_name.replace("/","_")}]{lint_result.component_name}[/link]"
else:
module_name = lint_result.component_name

# Make the filename clickable to open in VSCode
file_path = os.path.relpath(lint_result.file_path, self.dir)
file_path_link = f"[link=vscode://file/{os.path.abspath(file_path)}]{file_path}[/link]"

table.add_row(
Markdown(f"{lint_result.component_name}"),
os.path.relpath(lint_result.file_path, self.dir),
module_name,
file_path_link,
Markdown(f"{lint_result.message}"),
style="dim" if even_row else None,
)