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

JSON reporting or summary line #119

Closed
WTK opened this issue Sep 19, 2022 · 10 comments · Fixed by #120 or #125
Closed

JSON reporting or summary line #119

WTK opened this issue Sep 19, 2022 · 10 comments · Fixed by #120 or #125
Labels
enhancement New feature or request

Comments

@WTK
Copy link

WTK commented Sep 19, 2022

Is your feature request related to a problem? Please describe.

It's related to using deptry in CI (particularly Jenkins)

Describe the solution you would like

It would make it easier to integrate deptry into CI pipelines if you'd offert json output and/or some summary line that can be easily regexped to find out number of issues found.

Additional context

Jenkins allows us to define scripts that are used to parse output of various tools and collect errors/warnings. For example we use it to parse output from black formatter check, that after bunch of text spits out line like "2 files would be modified.". So we parse that and report that black found 2 issues.

@WTK WTK added the enhancement New feature or request label Sep 19, 2022
@fpgmaas
Copy link
Owner

fpgmaas commented Sep 19, 2022

Thanks for the suggestion, sure, this sounds like something we can add. It will be fairly output to add a line to the logging, similar to black, that says

There were X dependency issues found

I will work on this in the upcoming days. Would this suffice for your purposes?

Alternatively/additionally, we could add a json file, this will be slightly more work. For example, the output json file could look something like this:

{
  "missing": [
    "foo"
  ],
    "obsolete": [
    "bar"
  ]
}

@WTK
Copy link
Author

WTK commented Sep 19, 2022

Yes, looks pretty much perfect.

@fpgmaas
Copy link
Owner

fpgmaas commented Sep 19, 2022

Hi @WTK , sorry, I just updated my comment. Should maybe have added a new one instead. Could you let me know if just the additional logging output would suffice, or if the json file is needed?

@WTK
Copy link
Author

WTK commented Sep 19, 2022

No worries :) As for the summary line, I'd suggest adding a tiny bit more details. Like "There were X dependency issues found: Y obsolete, Z missing, W transitive".

@fpgmaas
Copy link
Owner

fpgmaas commented Sep 19, 2022

I'm thinking of adding this code in the upcoming release:

    @staticmethod
    def _log_total_number_of_issues_found(number):
        if number == 0:
            logging.info("Success! No dependency issues found.")
        elif number == 1:
            logging.info("There was 1 dependency issue found.")
        else:
            logging.info(f"There were {number} dependency issues found.")

However, I do have a strong preference to not add the details you mentioned to the output in that line, since it feels a bit redundant. The issues are outlined right below it.

Scanning 19 files...
There was 1 dependency issue found.

-----------------------------------------------------

The project contains obsolete dependencies:

        foo

Consider removing them from your project's dependencies. If a package is used for development purposes, you should add it to your development dependencies instead.

-----------------------------------------------------

So if the above logging line is not sufficient and you'd like to have the number of issues per category, I'd prefer to work on adding a CLI argument that can be used to specify a path for a json file with the details.

Let me know your thoughts :)

@WTK
Copy link
Author

WTK commented Sep 19, 2022

They're outlined in the response indeed, but it's not a one-liner you can just take a look to understand what are we dealing with. That said, I'm not pushing for it :)

@fpgmaas fpgmaas linked a pull request Sep 19, 2022 that will close this issue
4 tasks
@fpgmaas
Copy link
Owner

fpgmaas commented Sep 19, 2022

I do understand that the logging output is not very useful to get numbers of different types of issues from, that would become too much of a hassle and prone to errors. However, if you are okay with it I'll choose not to add details about the number of different issues to the summary line. I think those are more suited to be fetched from a json file. So if you need those, just give me a heads up and I'll work on that.

side-note; since this is an open-source project I don't think that my preference should be a deciding factor in these kind of decisions. So if there are more people in favour of expanding the summary line than adding json output, then that should be the way to go.

@fpgmaas fpgmaas reopened this Sep 19, 2022
@rrauenza
Copy link
Contributor

rrauenza commented Sep 21, 2022

Thanks for considering this! I just came here today to see if this was an upcoming feature.

We want to use this in python pre-commit tool and the json will be helpful to make a wrapper around it.

@fpgmaas
Copy link
Owner

fpgmaas commented Sep 22, 2022

Thanks for letting me know this is a feature you also need, I'll work on adding json output.

@fpgmaas fpgmaas linked a pull request Sep 22, 2022 that will close this issue
4 tasks
@fpgmaas
Copy link
Owner

fpgmaas commented Sep 22, 2022

@rrauenza I just created a PR that allows the user to run deptry as

deptry . -o deptry.json

where an example of the resulting deptry.json looks as follows:

{
    "obsolete": [
        "foo"
    ],
    "missing": [],
    "transitive": [],
    "misplaced_dev": []
}

Would this suffice for your purposes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants