-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
- Loading branch information
Felix Weilbach
committed
Jun 17, 2021
1 parent
3e77ae0
commit 3e3c124
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Small script that counts the warnings which the compiler emits | ||
# and takes care that not more warnings are added. | ||
|
||
import sys | ||
import re | ||
import requests | ||
|
||
|
||
if len(sys.argv) != 2: | ||
print(f"Usage: {sys.argv[0]} REPOSITORY_PATH") | ||
sys.exit(1) | ||
|
||
repository_path = sys.argv[1] | ||
warning_regex = re.compile(r'warning:', re.M) | ||
max_allowed_warnings_count_response = requests.get( | ||
"https://nextclouddesktopwarningscount.felixweilbach.de") | ||
|
||
if max_allowed_warnings_count_response.status_code != 200: | ||
print('Can not get maximum number of allowed warnings') | ||
sys.exit(1) | ||
|
||
max_allowed_warnings_count = int(max_allowed_warnings_count_response.content) | ||
|
||
print("Max number of allowed warnings:", max_allowed_warnings_count) | ||
|
||
warnings_count = 0 | ||
|
||
for line in sys.stdin: | ||
if warning_regex.findall(line): | ||
warnings_count += 1 | ||
|
||
print(line, end="") | ||
|
||
if warnings_count > max_allowed_warnings_count: | ||
print("Error: Too many warnings! You probably introduced a new warning!") | ||
sys.exit(1) | ||
|
||
print("Total number of warnings:", warnings_count) |