Commit Graph

29 Commits

Author SHA1 Message Date
Max Radermacher
9105b0655d Fix precommit.py output for keyword matches
We were passing `bytes` to `print(...)`, which outputs an escaped
representation. We should pass a string, as we do elsewhere.
2022-07-27 05:31:51 -05:00
Evan Hahn
7149dd6c99 Autoformat precommit script
This auto-formats the precommit script with [Black][0]. I made no manual
changes as part of this commit.

[0]: https://github.com/psf/black
2022-05-10 12:40:13 -05:00
Evan Hahn
d7c33eb211 Speed up pre-commit script
On my machine, the `./precommit.py --all` took 344.15 seconds (more than
5 minutes). This change speeds it up so that it takes less than 10
seconds.

It primarily achieves this by running `swiftlint` twice instead of twice
per file. There are some other smaller changes, too:

- Use a `set` for common operations
- Avoid a needless call to `text.split`
- Use built-in `pathlib.Path().parts` instead of a home-rolled solution

Tested this by running `./precommit.py` with all flags.
2022-03-23 09:43:21 -05:00
Evan Hahn
a7d5f778e2 Fix pre-commit block format script
Python 3 removed the [`cmp` function][0] which this script relied on.
Calling it was unnecessary, so I removed it (and cleaned up some of the
surrounding code).

Tested this with the `--all`, `--path`, and `--ref` flags.

[0]: https://docs.python.org/2.7/library/functions.html#cmp
2022-03-22 13:33:32 -05:00
Evan Hahn
c254811765 Remove unnecessary coding: utf-8 heading from Python scripts
Python 3 uses UTF-8 for source files by default. This removes the
unnecessary `coding: utf-8` declaration comment from all files.
2022-03-21 14:43:45 -05:00
Evan Hahn
1101db6a29 Upgrade scripts to Python 3
Python 2 was [removed from macOS in 12.3][0]. This change:

- Automatically converts many files with [2to3][1]
- Manually updates all [shebangs][2] to use `python3` instead of
  versionless `python` or `python2.7`
- Manually applies a few fixes, many of which were noted by 2to3
- Manually undoes a few fixes that were automatically done by 2to3

[0]: https://www.macrumors.com/2022/01/28/apple-removing-python-2-in-macos-12-3/
[1]: https://docs.python.org/3/library/2to3.html
[2]: https://en.wikipedia.org/wiki/Shebang_(Unix)
2022-03-21 12:58:33 -05:00
Michelle Linington
220a49134e Fix lint script 2022-01-31 11:00:13 -08:00
Matthew Chen
726fa6577f Fix bug around handling forward declarations of obj-c protocols in precommit script. 2021-11-23 14:16:35 -03:00
Michelle Linington
7a3f063276 Fix clang format 2021-11-03 13:46:03 -07:00
Matthew Chen
9211ac8fa3 Move MobileCoin SDK to SignalUI. 2021-11-02 14:26:03 -03:00
Matthew Chen
a0efdc2e95 Respond to CR. 2021-10-21 09:21:33 -03:00
Matthew Chen
eca3fdf26f Respond to CR. 2021-10-21 09:21:33 -03:00
Michelle Linington
6028212361 Re-add swiftlint --fix invocation 2021-10-12 11:46:44 -07:00
Michelle Linington
fa190b88cd Skip files where sourcekitd crashes 2021-10-12 11:46:44 -07:00
Michelle Linington
d2de17afb9 Fix lint script 2021-10-12 11:46:44 -07:00
Nora Trapp
da59806acf Update precommit.py for swiftlint 0.43.1 2021-03-17 13:15:51 -07:00
Nora Trapp
aa1f0ab39c Fix precommit script for when PRs remove files 2020-04-03 11:17:01 -07:00
Ehren Kret
82f3f3ed01 Change shebang line for pre and post commit scripts
These scripts are written for Python 2.7 and fail if python executable
points to Python 3.
2020-04-01 18:09:57 -07:00
Nora Trapp
f05f2ff85f Add lint action 2020-03-14 15:40:02 -07:00
Nora Trapp
778885db9f Fix precommit, git-clang-format doesn't like spaces between extension type 2019-11-15 14:17:46 -08:00
Michael Kirk
583077d94b skip formatting proto files 2019-11-06 21:24:53 -07:00
Nora Trapp
03f3f4aa9a Don't disable universal support in precommitt 2019-10-23 13:46:31 -07:00
Nora Trapp
06f66b7cb5 Disable universal device support in precommit check. 2019-10-03 11:54:00 -07:00
Disconnect3d
0fc0377d0c Fix check_diff_for_keywords in scripts
Fixes the `objc_keywords` list in `check_diff_for_keywords`.

This list stores strings and Python automagically concatenates strings if there is no comma between them.

As a result the first two items of the list: `OWSAbstractMethod\(` and `OWSAssert\(` were wrongly conacatenated into `"OWSAbstractMethod\(OWSAssert\("`.

This has been found with LGTM 0ddaedbfad/files/Scripts/precommit.py (x84c147336239d4b6):1
2019-09-15 09:40:02 -07:00
Michael Kirk
5236fba691 keyword checks 2018-09-17 09:50:22 -06:00
Michael Kirk
551102210e include C assert variants in keywords check 2018-09-17 09:36:44 -06:00
Michael Kirk
d534651ac4 check keywords in diff 2018-09-07 11:02:56 -06:00
Matthew Chen
49b0ea993d Dedupe forward class declarations. 2018-07-12 15:35:42 -04:00
Michael Kirk
17ed0f6100 dedupe git hooks
// FREEBIE
2018-03-02 17:57:58 -05:00