HomePhabricator

lint: add new python script to check file names and permissions

Description

lint: add new python script to check file names and permissions

Summary:
Replaces existing filenames and shebang linters, as well as adding some new and increased testing.
Summary of tests:

  • Checks every file in the repository against an allowed regexp to make sure only lowercase or uppercase alphanumerics (a-zA-Z0-9), underscores (_), hyphens (-), at (@) and dots (.) are used in repository filenames.
  • Checks only source files (*.cpp, *.h, *.py, *.sh, *.rs) against a stricter allowed regexp to make sure only lowercase alphanumerics (a-z0-9), underscores (_), hyphens (-) and dots (.) are used in source code filenames. Additionally there is an exception regexp for directories or files which are excepted from matching this regexp (replaces existing filename linter)
  • Checks all files in the repository match an allowed executable or non-executable file permission octal. Additionally checks that for executable files, the file contains a shebang line.
  • Checks that for executable .py and .sh files, the shebang line used matches an allowable list of shebangs (replacethe two existing shebang linters)
  • Checks every file that contains a shebang line to ensure it has an executable permission.

This is a backport of core#21740, core#24762, core#21873 and core#25015

Benchmark, before this diff:

$ time arc lint --everything
...
real	3m37,360s
user	17m17,366s
sys	3m29,937s

After this diff:

$ time arc lint --everything
...
real	3m38,471s
user	17m27,795s
sys	3m32,067s

Linter on its own:

$ time test/lint/lint-files.py

real	0m0,132s
user	0m0,164s
sys	0m0,099s

Test Plan:
arc lint
arc lint --everything

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D15458

Details

Provenance
windsok <windsok@protonmail.com>Authored on Apr 21 2021, 01:41
PiRKCommitted on Feb 16 2024, 16:43
PiRKPushed on Feb 16 2024, 16:43
Reviewer
Restricted Project
Differential Revision
D15458: lint: add new python script to check file names and permissions
Parents
rABC6649b0d3da90: [guix] Build for windows
Branches
Unknown
Tags
Unknown