reviewdog / reviewdog

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

Home Page:https://medium.com/@haya14busa/reviewdog-a-code-review-dog-who-keeps-your-codebase-healthy-d957c471938b#.8xctbaw5u

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mypy errors not reported in all relevant files in PR

voisey opened this issue · comments

@ajahl and I are trying to get mypy errors reported to PRs using tsuyoshicho/action-mypy in a GitHub workflow, but not all such errors are being reported. In particular, we have introduced mypy errors in three files for testing purposes, but only the errors in one of the files are being reported.

We are running the workflow on a branch on my fork. When I run mypy on the branch locally, I get the following output:

~/magma$ mypy lte/gateway/python/ 
lte/gateway/python/magma/enodebd/state_machines/enb_acs_manager.py:43: error: Need type annotation for "_state_machine_by_ip" (hint: "_state_machine_by_ip: Dict[<type>, <type>] = ...")  [var-annotated]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_manager.py:114: error: "None" has no attribute "mconfig"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_manager.py:169: error: Return value expected  [return-value]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_manager.py:216: error: Need type annotation for "ip_by_enb_serial" (hint: "ip_by_enb_serial: Dict[<type>, <type>] = ...")  [var-annotated]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_manager.py:217: error: Need type annotation for "enb_serial_by_ip" (hint: "enb_serial_by_ip: Dict[<type>, <type>] = ...")  [var-annotated]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:116: error: "None" has no attribute "exit"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:118: error: "None" has no attribute "enter"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:122: error: "None" has no attribute "exit"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:191: error: "None" has no attribute "enter"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:205: error: "None" has no attribute "read_msg"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:208: error: "None" has no attribute "read_msg"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:214: error: "None" has no attribute "get_msg"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:230: error: "None" has no attribute "state_description"  [attr-defined]
lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:236: error: "None" has no attribute "state_description"  [attr-defined]
lte/gateway/python/magma/pipelined/tests/pipelined_test_util.py:71: error: NamedTuple field name cannot start with an underscore: __test__  [misc]
lte/gateway/python/magma/pipelined/tests/pipelined_test_util.py:71: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"  [misc]
lte/gateway/python/magma/pipelined/tests/pipelined_test_util.py:706: error: Missing return statement  [return]
Found 17 errors in 3 files (checked 658 source files)

but only the errors in enb_acs_manager.py are being reported in the PR, e.g. here.

In trying to debug this, we have set filter_mode: nofilter and added extra output to the action, again on my fork, as you can see here. Looking at this in the CI, we find that the errors not being reported by reviewdog are found by mypy. (Note that we have fail_on_error set to false so the job is green despite showing errors) For example,

  Raw Output:
  /home/runner/work/magma/magma/lte/gateway/python/magma/enodebd/state_machines/enb_acs_impl.py:116:9: error: "None" has no attribute "exit"  [attr-defined]
  Error: [mypy] reported by reviewdog 🐶
  "None" has no attribute "enter"  [attr-defined]

so we wonder whether something is going wrong when the results are filtered by reviewdog in the action here.

We're not sure whether (i) we have some unwanted configuration, (ii) something is wrong with the use of reviewdog in the action itself, or (iii) there is a bug in reviewdog. Any help would be really appreciated, thanks!

I'm pretty sure github actions has a limit of 10 error annotations and 10 warning annotations per check when using commands. Ref: https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations

If you want more:

  • make sure you have reporter as "github-check" or "github-pr-check"
  • make sure your github token is properly passed to reviewdog and that it has permissions to write to the checks api

When reviewdog doesn't have proper permissions, it falls back to using commands