Add nolint

This commit is contained in:
Samuel Sloniker 2022-08-17 11:21:22 -07:00
parent 32096b46a3
commit d5f0915071
Signed by: kj7rrv
GPG Key ID: 1BB4029E66285A62
2 changed files with 67 additions and 1 deletions

View File

@ -1,3 +1,7 @@
# nocode-linter # nocode-linter
Linter for No Code: https://github.com/kelseyhightower/nocode Linter for No Code: https://github.com/kelseyhightower/nocode
## Usage
python3 nolint.py <file>

62
nolint.py Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description="Linter for No Code.")
parser.add_argument("file", help="name of No Code file to lint")
args = parser.parse_args()
try:
with open(args.file) as f:
content = f.read()
if content:
if content.strip():
if args.file.endswith(".no"):
print("Not very good.")
print(" * File has non-whitespace content")
print("At least there's something good, though:")
print(" * File extension is `.no`")
print("Suggestions:")
print(" * Delete the file")
else:
print("Not good. At all.")
print(" * File has non-whitespace content")
print(" * File extension is not `.no`")
print("Suggestions:")
print(" * Delete the file")
print(" * Use `.no` file extension")
else:
if args.file.endswith(".no"):
print("Not terrible...")
print(" * All content is whitespace")
print(" * File extension is `.no`")
print("There's room for improvement, however:")
print(" * Delete the file")
else:
print("Okay...")
print(" * All content is whitespace")
print("There's room for improvement, however:")
print(" * Delete the file")
print(" * Use `.no` file extension")
else:
if args.file.endswith(".no"):
print("Good job!")
print(" * File is empty")
print(" * File extension is `.no`")
print("There's room for improvement, however:")
print(" * Delete the file")
else:
print("Pretty good!")
print(" * File is empty")
print("There's room for improvement, however:")
print(" * Delete the file")
print(" * Use `.no` file extension")
except FileNotFoundError:
if args.file.endswith(".no"):
print("Excellent!")
print(" * File extension is `.no`")
print(" * File does not exist")
else:
print("Great!")
print(" * File does not exist")
print("There's room for improvement, however:")
print(" * Use `.no` file extension")