Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tools: update check-imports using function
Currently, the do_exist function that performs the checks for unused
types declared with using declarations, only matches the name of the
using declarations. The means that some unused using declarations are
not detected. For example having both a 'using Maybe;' and a 'using
MaybeLocal' and only using MaybeLocal would not be reported.

This commit attempts to take into account the above mentioned case and
also others where the name of the using declaration type is used in name
of a variables or function call. For example, 'using Just;', will now be
reported as unused even if there are calls to the FromJust function.
  • Loading branch information
danbev committed May 26, 2020
commit e82f39375a2a5445ec7f8a2aa25102132661cd40
5 changes: 3 additions & 2 deletions tools/check-imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import re
import sys


def do_exist(file_name, lines, imported):
if not any(not re.match('using \w+::{0};'.format(imported), line) and
re.search(imported, line) for line in lines):
re.search("(:?^|\s|<|\(|\:|{{){0}[\s<>(,:*)&]".format(imported),
line)
for line in lines):
print('File "{0}" does not use "{1}"'.format(file_name, imported))
return False
return True
Expand Down