forked from Verified-zkEVM/CompPoly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-style.sh
More file actions
executable file
·61 lines (42 loc) · 1.76 KB
/
Copy pathlint-style.sh
File metadata and controls
executable file
·61 lines (42 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -eo pipefail
# # Style linter
# ## Usage
# Run this script from the root of CompPoly using:
# ./scripts/lint-style.sh
# ## Purpose
# The style linter checks for new style issues,
# and maintains a list of exceptions for legacy reasons.
# Ideally, the length of the list of exceptions tends to 0.
# Examples of issues that are checked for are:
# * existence of copyright header
# * existence of module docstrings (in the right place)
# * line length <= 100 (unless URL)
# ## Implementation details
# There are two parts.
# 1. A Python script `scripts/lint-style.py` that lints the contents of a Lean file.
# This script is called below on all Lean files in the repository.
# Exceptions are maintained in `scripts/style-exceptions.txt`.
# 2. The remainder of this shell script
# contains some lints on the global repository.
#
################################################################################
# 1. Call the Lean file linter, implemented in Python
touch scripts/style-exceptions.txt
git ls-files 'CompPoly/**/*.lean' '*.lean' | xargs ./scripts/lint-style.py "$@"
# 2.1 Check for executable bit on Lean files
executable_files="$(find . -name '*.lean' -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \))"
if [[ -n "$executable_files" ]]
then
echo "ERROR: The following Lean files have the executable bit set."
echo "$executable_files"
exit 1
fi
# 2.2 Check that there are no filenames with the same lower-case reduction
# `uniq -D`: print all duplicate lines
ignore_case_clashes="$(git ls-files | sort --ignore-case | uniq -D --ignore-case)"
if [ -n "${ignore_case_clashes}" ]; then
printf $'The following files have the same lower-case form:\n\n%s\n
Please, make sure to avoid such clashes!\n' "${ignore_case_clashes}"
exit 1
fi