ZedThree / clang-tidy-review

Create a pull request review based on clang-tidy warnings
MIT License
90 stars 45 forks source link

fix: support empty commits/PRs #132

Closed Nerixyz closed 3 months ago

Nerixyz commented 3 months ago

When opening a PR without any changes (with one or more empty commits), clang-tidy-review currently fails with

Traceback (most recent call last):
  File "/usr/local/bin/review", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/clang_tidy_review/review.py", line 154, in main
    review = create_review(
             ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/clang_tidy_review/__init__.py", line 843, in create_review
    diff = pull_request.get_pr_diff()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/clang_tidy_review/__init__.py", line 297, in get_pr_diff
    diffs = data["data"]
            ~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

This PR checks data and returns with no changes.

While doing that, I noticed the return-type being wrong in this method, so I fixed that too.