Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cpp_linter_hooks/clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
from cpp_linter_hooks.util import resolve_install_with_diagnostics

parser = ArgumentParser()
parser.add_argument("--version", default=None)
parser.add_argument(
"--version",
default=None,
help=(
"Version of clang-format to install and run; defaults to the latest "
"stable wheel on PyPI"
),
)
parser.add_argument(
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
Expand Down
33 changes: 28 additions & 5 deletions cpp_linter_hooks/clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,36 @@ def _positive_int(value: str) -> int:


parser = ArgumentParser()
parser.add_argument("--version", default=None)
parser.add_argument("--compile-commands", default=None, dest="compile_commands")
parser.add_argument(
"--no-compile-commands", action="store_true", dest="no_compile_commands"
"--version",
default=None,
help=(
"Version of clang-tidy to install and run; defaults to the latest stable "
"wheel on PyPI"
),
)
parser.add_argument(
"--compile-commands",
default=None,
dest="compile_commands",
help="Directory containing compile_commands.json to pass to clang-tidy via -p",
)
parser.add_argument(
"--no-compile-commands",
action="store_true",
dest="no_compile_commands",
help="Disable automatic compile_commands.json detection",
)
parser.add_argument(
"-j",
"--jobs",
type=_positive_int,
default=1,
help="Number of clang-tidy processes to run in parallel (default: 1)",
)
parser.add_argument(
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
parser.add_argument("-j", "--jobs", type=_positive_int, default=1)
parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("--fix", action="store_true", help="Apply fixes in place (-fix)")


Expand Down
12 changes: 11 additions & 1 deletion tests/test_clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

import pytest

from cpp_linter_hooks.clang_format import main, run_clang_format
from cpp_linter_hooks.clang_format import main, parser, run_clang_format


def test_all_arguments_have_help():
missing_help = [
action.option_strings for action in parser._actions if not action.help
]
assert missing_help == []

help_text = " ".join(parser.format_help().split())
assert all(" ".join(action.help.split()) in help_text for action in parser._actions)


@pytest.mark.benchmark
Expand Down
12 changes: 11 additions & 1 deletion tests/test_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@

import pytest

from cpp_linter_hooks.clang_tidy import _exec_clang_tidy, run_clang_tidy
from cpp_linter_hooks.clang_tidy import _exec_clang_tidy, parser, run_clang_tidy


def test_all_arguments_have_help():
missing_help = [
action.option_strings for action in parser._actions if not action.help
]
assert missing_help == []

help_text = " ".join(parser.format_help().split())
assert all(" ".join(action.help.split()) in help_text for action in parser._actions)


@pytest.fixture(scope="function")
Expand Down
Loading