Skip to content

Commit

Permalink
fix lint check
Browse files Browse the repository at this point in the history
  • Loading branch information
skullydazed committed Aug 29, 2021
1 parent 851fd80 commit a03a66c
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions lib/python/qmk/cli/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,33 @@
from qmk.path import is_keyboard, keyboard


def keymap_check(kb, km):
"""Perform the keymap level checks.
"""
ok = True
keymap_path = locate_keymap(kb, km)

if not keymap_path:
ok = False
cli.log.error("%s: Can't find %s keymap.", kb, km)

else:
keymap_readme = keymap_path.parent / 'readme.md'

if not keymap_readme.exists():
cli.log.warning('%s: %s: Missing %s', kb, km, keymap_readme)

if cli.config.lint.strict:
ok = False

return ok


def rules_mk_assignment_only(keyboard_path):
"""Check the keyboard-level rules.mk to ensure it only has assignments.
"""
current_path = Path()
found_invalid = False
ok = True

for path_part in keyboard_path.parts:
current_path = current_path / path_part
Expand All @@ -41,9 +63,9 @@ def rules_mk_assignment_only(keyboard_path):

if line and '=' not in line:
cli.log.error('Non-assignment code: +%s %s: %s', i, rules_mk, line)
found_invalid = True
ok = False

return not found_invalid
return ok


@cli.argument('--strict', action='store_true', help='Treat warnings as errors.')
Expand Down Expand Up @@ -109,19 +131,10 @@ def lint(cli):

# Keymap specific checks
if cli.config.lint.keymap:
keymap_path = locate_keymap(kb, cli.config.lint.keymap)

if not keymap_path:
if not keymap_check(kb, cli.config.lint.keymap):
ok = False
cli.log.error("%s: Can't find %s keymap.", kb, cli.config.lint.keymap)
else:
keymap_readme = keymap_path.parent / 'readme.md'
if not keymap_readme.exists():
cli.log.warning('%s: %s: Missing %s', kb, cli.config.lint.keymap, keymap_readme)

if cli.config.lint.strict:
ok = False

# Report status
if not ok:
failed.append(kb)

Expand All @@ -132,4 +145,3 @@ def lint(cli):

cli.log.info('Lint check passed!')
return True

0 comments on commit a03a66c

Please sign in to comment.