Introduce precommit hooks #15673
Replies: 6 comments
-
Pre-commit hooks are nice for add-ons; at least one that I have created for linting. If it lasts only 2-3 seconds to commit a file, it remains acceptable. But for NVDA the problem is that the checks last more time due to the number of files:
I am not in favor of pre-commits that modify the full code files such as automatic linting or space removing, since as discussed in #15331 (review), it impacts the |
Beta Was this translation helpful? Give feedback.
-
Closing for the reasons Cyrille has raised |
Beta Was this translation helpful? Give feedback.
-
I'm reopening this since the future of linting/formatting of NVDA is still open for discussion, see #15299. We can always close this again if there is a stronger consensus for it. |
Beta Was this translation helpful? Give feedback.
-
@LeonarddeR, even if NV Access can now be in favor of a linting of the whole codebase, the reasons why this issue was closed still stand:
Have you some specific checks in mind for a pre-commit hook? If not, maybe the comments of this issue would rather deserve a GitHub discussion? |
Beta Was this translation helpful? Give feedback.
-
Shouldn't be a problem when only linting changed files.
Linting a diff is no longer necessary when the baseline is correctly formatted and linted. Even when we'd lint a diff, the diff would be the diff of that commit alone, not against a base branch.
i actually agree that unit tests are probably way too much time consuming, but linting should certainly be possible and cause less issues. If there is a desire to convert line endings to a standardized format, we can add a line ending check, though ideally that'd be performed by the linter. Note that pre-commit hooks would still be optional, we can't force them upon users anyway. |
Beta Was this translation helpful? Give feedback.
-
This has been converted to a discussion as we need a more specific implementation discussed - i.e. we need specific hooks defined, and the impact of these clear. If we are moving towards an auto-linting solution - auto linting changed files in the commit have a risky O(N)+ computation time. While N is generally small, there are exceptions i.e. when changing a popular function name, you'd be linting large numbers of files in the codebase. Linting unit tests is not ideal, as you may want to create intermediate commits where unit tests are broken. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
Sometimes, people including myself forget to run unit tests or linting before a commit. There are also other tasks that can be automated at commit time.before
Describe the solution you'd like
Introduce precommit hooks. Note that the add-on template already has support for these. They can be used to run unit tests and linting before committing. They can also be used to automatically remove trailing white space, for example.
Beta Was this translation helpful? Give feedback.
All reactions