How to use the prospector.message.Message function in prospector

To help you get started, we’ve selected a few prospector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyCQA / prospector / prospector / tools / mypy / __init__.py View on Github external
result = self.checker.run(paths)
        report, _ = result[0], result[1:]
        messages = []

        for message in report.splitlines():
            iter_message = iter(message.split(':'))
            (path, line, char, err_type, err_msg) = islice(iter_message, 5)
            location = Location(
                path=path,
                module=None,
                function=None,
                line=line,
                character=int(char),
                absolute_path=True
            )
            message = Message(
                source='mypy',
                code=err_type.lstrip(" "),
                location=location,
                message=err_msg.lstrip(" ")
            )
            messages.append(message)

        return messages
github PyCQA / prospector / prospector / tools / pyroma / __init__.py View on Github external
if filename != 'setup.py':
                continue

            data = projectdata.get_data(dirname)

            all_tests = [m() for m in PYROMA_TEST_CLASSES]
            for test in all_tests:
                code = PYROMA_CODES[test.__class__]

                if code in self.ignore_codes:
                    continue

                passed = test.test(data)
                if passed is False:  # passed can be True, False or None...
                    loc = Location(module, 'setup', None, -1, -1)
                    msg = Message('pyroma', code, loc, test.message())
                    messages.append(msg)

        return messages
github PyCQA / prospector / prospector / tools / pylint / collector.py View on Github external
# At this point pylint will give us the code but we want the
        # more user-friendly symbol
        try:
            if PYLINT_VERSION < (2, 0):
                msg_data = self._message_store.check_message_id(msg_id)
            else:
                msg_data = self._message_store.get_message_definitions(msg_id)[0]
        except UnknownMessageError:
            # this shouldn't happen, as all pylint errors should be
            # in the message store, but just in case we'll fall back
            # to using the code.
            msg_symbol = msg_id
        else:
            msg_symbol = msg_data.symbol

        message = Message('pylint', msg_symbol, loc, msg)
        self._messages.append(message)
github PyCQA / prospector / prospector / tools / frosted / __init__.py View on Github external
line=None,
            character=None,
            code=None,
            message=None):

        if code in self.ignore:
            return

        location = Location(
            path=filename,
            module=None,
            function=None,
            line=line,
            character=character,
        )
        message = Message(
            source='frosted',
            code=code,
            location=location,
            message=message,
        )
        self._messages.append(message)
github PyCQA / prospector / prospector / tools / pyflakes / __init__.py View on Github external
character=None,
            code=None,
            message=None):

        code = code or 'F999'
        if code in self.ignore:
            return

        location = Location(
            path=filename,
            module=None,
            function=None,
            line=line,
            character=character,
        )
        message = Message(
            source='pyflakes',
            code=code,
            location=location,
            message=message,
        )
        self._messages.append(message)
github PyCQA / prospector / prospector / message.py View on Github external
def make_tool_error_message(filepath, source, code, message,
                            line=0, character=0, module=None, function=None):
    location = Location(
        path=filepath,
        module=module,
        function=function,
        line=line,
        character=character
    )
    return Message(
        source=source,
        code=code,
        location=location,
        message=message
    )
github PyCQA / prospector / prospector / tools / pylint / __init__.py View on Github external
def _error_message(self, filepath, message):
        location = Location(filepath, None, None, 0, 0)
        return Message('prospector', 'config-problem', location, message)
github PyCQA / prospector / prospector / tools / pylint / __init__.py View on Github external
for message in messages:
            if message.code == 'unused-wildcard-import':
                by_loc[message.location].append(message)
            else:
                out.append(message)

        for location, message_list in by_loc.items():
            names = []
            for msg in message_list:
                names.append(
                    _UNUSED_WILDCARD_IMPORT_RE.match(msg.message).group(1))

            msgtxt = 'Unused imports from wildcard import: %s' % ', '.join(
                names)
            combined_message = Message('pylint', 'unused-wildcard-import',
                                       location, msgtxt)
            out.append(combined_message)

        return out