Skip to content

Commit 99aa469

Browse files
authored
resolve #34 (#35)
* replace pylint with ruff and fix docs/tests * allow LGTM comment when no files checked or failed * do not exit early if no files are checked allows LGTM comment in such a case fix unit test and comments.json debug output file * ensure CACHE_PATH exists before doing anything * tally format advice if file-annotations is false applied in make_annotations() * annotate tidy advice if file-annotations is on found a bug where file-annotations=false & tidy advice was still posted * modify log output to reflect count not annotations * fix filename matching for tidy annotations also adjust unit test to use a src that triggers tidy annotations
1 parent 977eb16 commit 99aa469

File tree

12 files changed

+225
-757
lines changed

12 files changed

+225
-757
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ repos:
1717
hooks:
1818
- id: black
1919
args: ["--diff"]
20-
- repo: https://github.com/pycqa/pylint
21-
rev: v3.0.1
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
# Ruff version.
22+
rev: v0.0.287
2223
hooks:
23-
- id: pylint
24-
name: pylint (action code)
24+
- id: ruff
2525
types: [python]
26-
exclude: "^(docs/|tests/|setup.py$)"
27-
additional_dependencies: [pyyaml, requests]
2826
- repo: local
2927
# this is a "local" hook to run mypy (see https://pre-commit.com/#repository-local-hooks)
3028
# because the mypy project doesn't seem to be compatible with pre-commit hooks

cpp_linter/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from requests import Response
99

1010
if TYPE_CHECKING: # Used to avoid circular imports
11-
from cpp_linter.clang_format_xml import XMLFixit
12-
from cpp_linter.clang_tidy_yml import YMLFixit
13-
from cpp_linter.clang_tidy import TidyNotification
11+
from cpp_linter.clang_format_xml import XMLFixit # noqa: F401
12+
from cpp_linter.clang_tidy_yml import YMLFixit # noqa: F401
13+
from cpp_linter.clang_tidy import TidyNotification # noqa: F401
1414

1515
FOUND_RICH_LIB = False
1616
try:
@@ -132,7 +132,7 @@ def range_of_changed_lines(
132132
]
133133
if get_ranges:
134134
return ranges
135-
return [l for r in ranges for l in range(r[0], r[1])]
135+
return [line for r in ranges for line in range(r[0], r[1])]
136136
# we return an empty list (instead of None) here so we can still iterate it
137137
return [] # type: ignore[return-value]
138138

cpp_linter/cli.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,30 @@
157157
See `Authenticating with the GITHUB_TOKEN
158158
<https://docs.github.com/en/actions/reference/authentication-in-a-workflow>`_
159159
160+
Defaults to ``%(default)s``.""",
161+
)
162+
cli_arg_parser.add_argument(
163+
"-g",
164+
"--no-lgtm",
165+
default="true",
166+
type=lambda input: input.lower() == "true",
167+
help="""Set this option to true or false to enable or disable the use of a
168+
thread comment that basically says 'Looks Good To Me' (when all checks pass).
169+
170+
.. seealso::
171+
The :std:option:`--thread-comments` option also notes further implications.
172+
160173
Defaults to ``%(default)s``.""",
161174
)
162175
cli_arg_parser.add_argument(
163176
"-t",
164177
"--thread-comments",
165178
default="false",
166-
type=lambda input: input.lower() == "true",
167-
help="""Set this option to true or false to enable or disable the use of
168-
thread comments as feedback.
179+
choices=['true', 'false', 'update'],
180+
help="""Set this option to 'true' or 'false' to enable or disable the use of
181+
thread comments as feedback. Set this to 'update' to update an existing comment
182+
if one exists; the value 'true' will always delete an old comment and post a new one
183+
if necessary.
169184
170185
.. note::
171186
To use thread comments, the ``GITHUB_TOKEN`` (provided by

0 commit comments

Comments
 (0)