Exemplo n.º 1
0
def _find_unused_code(filenames):
    """
    :param filenames: List of filenames to check.
    :return: Generator of Result objects.
    """
    vulture = Vulture()
    vulture.scavenge(filenames)
    for item in vulture.get_unused_code():
        yield Result.from_values(origin='VultureBear',
                                 message=item.message,
                                 file=item.filename,
                                 line=item.first_lineno,
                                 end_line=item.last_lineno,
                                 confidence=item.confidence)
Exemplo n.º 2
0
def _find_unused_code(filenames):
    """
    :param filenames: List of filenames to check.
    :return: Generator of Result objects.
    """
    def file_lineno(item):
        return (item.filename.lower(), item.lineno)

    vulture = Vulture()
    vulture.scavenge(filenames)
    for item in sorted(vulture.unused_funcs + vulture.unused_imports +
                       vulture.unused_props + vulture.unused_vars +
                       vulture.unused_attrs,
                       key=file_lineno):
        message = 'Unused {0}: {1}'.format(item.typ, item)
        yield Result.from_values(origin='VultureBear',
                                 message=message,
                                 file=item.filename,
                                 line=item.lineno)
Exemplo n.º 3
0
def _find_unused_code(filenames):
    """
    :param filenames: List of filenames to check.
    :return: Generator of Result objects.
    """

    def file_lineno(item):
        return (item.filename.lower(), item.lineno)

    vulture = Vulture()
    vulture.scavenge(filenames)
    for item in sorted(
            vulture.unused_funcs + vulture.unused_imports +
            vulture.unused_props + vulture.unused_vars +
            vulture.unused_attrs, key=file_lineno):
        message = 'Unused {0}: {1}'.format(item.typ, item)
        yield Result.from_values(origin='VultureBear',
                                 message=message,
                                 file=item.filename,
                                 line=item.lineno,
                                 confidence=CONFIDENCE_MAP[item.typ])
Exemplo n.º 4
0
def v():
    return Vulture(verbose=True)
Exemplo n.º 5
0
 def __init__(self, found_files):
     Vulture.__init__(self, exclude=None, verbose=False)
     self._files = found_files
Exemplo n.º 6
0
 def __init__(self, found_files):
     Vulture.__init__(self, verbose=False)
     self._files = found_files
     self._internal_messages = []
     self.file = None
     self.filename = None
Exemplo n.º 7
0
 def __init__(self, found_files):
     Vulture.__init__(self, exclude=None, verbose=False)
     self._files = found_files
     self._internal_messages = []
Exemplo n.º 8
0
 def __init__(self, found_files):
     Vulture.__init__(self, exclude=None, verbose=False)
     self._files = found_files
     self._internal_messages = []
Exemplo n.º 9
0
from vulture import Vulture

vulture = Vulture()

files = ['file1.py', 'file2.py']
vulture.scavenge(files)

for item in vulture.get_unused_code():
    # filter items
    print(item)
Exemplo n.º 10
0
"""Look for unreachable code."""

import argparse
import sys

from vulture import Vulture

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("files", nargs="*")
    args = parser.parse_args()

    v = Vulture()
    v.scavenge(args.files)
    ret = 0
    for item in v.get_unused_code(min_confidence=100):
        if item.typ == "unreachable_code":
            print(item.get_report())
            ret = 1

    sys.exit(ret)