Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress "Messages" header or configure verbosity #56

Closed
guykisel opened this issue Oct 23, 2014 · 7 comments
Closed

Suppress "Messages" header or configure verbosity #56

guykisel opened this issue Oct 23, 2014 · 7 comments

Comments

@guykisel
Copy link
Contributor

This is somewhat related to pre-commit/pre-commit#178

I'm working on setting up a Prospector hook for http://pre-commit.com/ (a handy git pre-commit hook manager). The way I'm configuring it, pre-commit runs prospector via xargs. See https://github.com/pre-commit/pre-commit/blob/master/pre_commit/languages/system.py

I'm currently setting the entry point to prospector as -n 1 prospector so that pre-commit ends up running xargs -0 -n 1 prospector, which then calls prospector once per input file. This ends up creating a lot of redundant summaries and message headers in the output, when I would rather just get the messages themselves. I can supply the -M argument to suppress the summaries, but I still get the Messages header once per file, even when there are no messages for that file.

My request is to add some sort of flag for either suppressing the Messages header specifically, or for more generally controlling output verbosity.

If this seems reasonable, I'd be willing to work on it and submit a pull request. Alternatively, if there's a better way to do this or something obvious I'm missing, I would appreciate any help.

(my efforts so far are at https://github.com/guykisel/prospector-mirror [which could probably use a better project name])

@carlio
Copy link
Member

carlio commented Oct 23, 2014

@guykisel What format does pre-commit require? There are several output options available already (see http://prospector.readthedocs.org/en/latest/usage.html#output-format). Are any of them useful?

If not, feel free to create a new output formatter which can fix exactly what you need. Examples are here: https://github.com/landscapeio/prospector/tree/master/prospector/formatters

I'm happy to answer any questions :)

@guykisel
Copy link
Contributor Author

There's no particular required format, it normally just displays whatever is written to stdout with no modifications. Your default human-readable format is actually pretty much perfect, I just want to skip the headers because they end up being a little redundant.

Example output (with -M arg):

13:22 $ pre-commit run prospector --all-files
prospector..................................................................................................................................................................................Failed
hookid: prospector

Messages
========

Messages
========

__init__ (services/platform/base/__init__.py):
    L17:4 Base.url: pylint - W0221
    Arguments number differs from overridden method

__init__ (services/platform/base/__init__.py):
    L17:17 Base.url: pylint - W0613
    Unused argument 'secure'

Messages
========

Messages
========

Messages
========

Messages
========

preferences (services/platform/data/preferences.py):
    L21:24 Preferences.get_preferences: pylint - W0613
    Unused argument 'ship_id'

@guykisel
Copy link
Contributor Author

Looks like I could make my own version of the text.py formatter that just doesn't include the header. Is it possible to tell prospector to use a 3rd party formatter?

@carlio
Copy link
Member

carlio commented Oct 23, 2014

Right now there's no ability to use a third-party formatter, but I don't mind merging in one called "precommit" or whatever you want. Also happy to merge in a change to allow third-party formatters!

Maybe a feature which allows 'output template' strings would be nice, so you could say:

prospector --output-template "%(code)s %(message)s %(linenumber)s"

@guykisel
Copy link
Contributor Author

Cool, that would be nice. I was also thinking, an alternative would be to modify prospector to allow an arbitrary number of positional path arguments, as opposed to being limited to one. I suspect this would require more significant modifications, though.

@carlio
Copy link
Member

carlio commented Oct 23, 2014

@guykisel Yes, I think that is the better solution but it requires fiddling with setoptconf a bit so it is perhaps non-trivial. That is something I'd like to do though.

@guykisel
Copy link
Contributor Author

I think once prospector can accept multiple input paths, the pre-commit hook would work great without needing a custom formatter.

Until then, the pylint formatter provides output that doesn't have a header, so I'll just suggest that users of the hook specify that formatter.

Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants