diff --git a/CHANGELOG.md b/CHANGELOG.md index ae1bf38..32ed764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Tools development version - minor documentation improvements. (#197, #198, @kelly-sovacool) +- `ccbr-hooks detect-absolute-paths`: Ignore self-closing HTML tags to avoid + false positives from `/>`. (#228, @kelly-sovacool, @copilot) ## Tools 0.7.0 diff --git a/src/ccbr_tools/hooks/detect_absolute_paths.py b/src/ccbr_tools/hooks/detect_absolute_paths.py index dd052e3..5c8ca37 100644 --- a/src/ccbr_tools/hooks/detect_absolute_paths.py +++ b/src/ccbr_tools/hooks/detect_absolute_paths.py @@ -59,6 +59,7 @@ def word_is_absolute_path(word): return word.startswith("/") and not any( [ word == "/", # FP from pathlib. abs-path:ignore + word == "/>", # FP from self-closing HTML tags. abs-path:ignore word.startswith("/dev/null"), word.startswith("/dev/shm"), word.startswith("//"), # FP from groovy comments. abs-path:ignore diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 00a08e6..7feea8a 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -45,6 +45,7 @@ def test_word_is_absolute_path(): assert not hooks.word_is_absolute_path("/dev/null") # common shell redirection assert not hooks.word_is_absolute_path("/dev/shm") # common shell redirection assert not hooks.word_is_absolute_path("/$") # nextflow script + assert not hooks.word_is_absolute_path("/>") # self-closing HTML tag def test_line_contains_absolute_path():