Merge pull request #67 from JoseDeFreitas/linter

Add linter
This commit is contained in:
José De Freitas 2021-02-06 14:57:01 -05:00 committed by GitHub
commit db5b3e4fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 91 additions and 0 deletions

28
linter/lint.py Normal file
View File

@ -0,0 +1,28 @@
from rules import (content_about, featured_playlists, youtubers_names)
file_readme = './../readme.md'
with open(file_readme, 'r') as read_readme:
content_readme = read_readme.readlines()
def main():
"""
Main function. Used specifically to call print results
by calling functions into rules/.
"""
if len(youtubers_names.youtubers_name_errors_nums) == 0:
print("Every YouTubers names are good.", "\n")
else:
print("'YouTubers name' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in youtubers_names.youtubers_name_errors_nums]), "\n")
if len(content_about.content_about_errors_nums) == 0:
print("Every 'Content about' sections are good.", "\n")
else:
print("'Content about' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in content_about.content_about_errors_nums]), "\n")
if len(featured_playlists.featured_playlists_errors_nums) == 0:
print("Every 'Featured playlists' sections are good.", "\n")
else:
print("'Featured playlists' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in featured_playlists.featured_playlists_errors_nums]), "\n")
if __name__ == '__main__':
main()

17
linter/readme.md Normal file
View File

@ -0,0 +1,17 @@
# Awesome YouTubers linter
The awesome-youtubers linter is a workflow that checks the layout of the pull requests opened. This helps the contributors show if
something in the layout is not formatted correctly so it can be fixed. This linter was created in order to keep the format of the
list without breaking the layouts (images, new lines, etc.)
## Rules
The rules that the linter follows are:
- Trailing `\` at the end of the name and link of the YouTuber.
- Trailing `\` at the end of the "Content about" section.
- Trailing `\` at the end of the "Featured playlists" section.
- Spaces between badges.
- Spaces between "Content about" words (including `,`).
- Spaces between "Featured playlists" words (including `,`).
- Links formatted correctly in the markdown syntax (`[text](link)`)

View File

@ -0,0 +1,15 @@
file_readme = './../readme.md'
with open(file_readme, 'r') as read_readme:
content_readme = read_readme.readlines()
def content_about():
content_about_errors_nums = []
content_about_line = 'Content about:'
for j, i in enumerate(content_readme):
if content_about_line in i:
if i[-2] != '\\':
content_about_errors_nums.append(j)
return content_about_errors_nums
content_about_errors_nums = content_about()

View File

@ -0,0 +1,16 @@
file_readme = './../readme.md'
with open(file_readme, 'r') as read_readme:
content_readme = read_readme.readlines()
def featured_playlists():
featured_playlists_errors_nums = []
featured_playlists_line = 'Featured playlists:'
featured_playlists_dlen = 124
for j, i in enumerate(content_readme):
if featured_playlists_line in i:
if len(i) < featured_playlists_dlen and i[-2] != '\\':
featured_playlists_errors_nums.append(j)
return featured_playlists_errors_nums
featured_playlists_errors_nums = featured_playlists()

View File

@ -0,0 +1,15 @@
file_readme = './../readme.md'
with open(file_readme, 'r') as read_readme:
content_readme = read_readme.readlines()
def youtubers_names():
youtubers_name_errors_nums = []
youtuber_count_char = '[**'
for j, i in enumerate(content_readme):
if youtuber_count_char in i:
if i[-2] != '\\':
youtubers_name_errors_nums.append(j)
return youtubers_name_errors_nums
youtubers_name_errors_nums = youtubers_names()