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

Reports json_report not working from command line execution[Bug] #554

Closed
ZephyrusMB opened this issue Jan 28, 2022 · 10 comments · Fixed by #662
Closed

Reports json_report not working from command line execution[Bug] #554

ZephyrusMB opened this issue Jan 28, 2022 · 10 comments · Fixed by #662
Assignees
Labels
bug Something isn't working

Comments

@ZephyrusMB
Copy link

What happened?

Hi,
Reading the doc seems i can get a report with the list of issues found in JSON format with the command robocop -r json_report -o report.json file/to/parse.robot.
But seems this doesn't work and instead I get a file with the classic text line "{source}:{line}:{col} [{severity}] {rule_id} {desc} ({name})"

Is it a bug or am i missing something? thank you very much

Operating System

10.0.19042

Robocop version

1.12.0

@ZephyrusMB ZephyrusMB added the bug Something isn't working label Jan 28, 2022
@bhirsz
Copy link
Member

bhirsz commented Jan 28, 2022

The json_report is actually dedicated to returning issues in json format when using Robocop Python module inside your Python script (not from cli). Here is example from docs:

import robocop
        from robocop.config import Config
        config = Config()
        config.include = {'1003'}
        config.paths = ['tests\\atest\\rules\\section-out-of-order']
        robocop_runner = robocop.Robocop(config=config)
        issues = robocop_runner.run()

The downside of using Robocop class directly in your Python script rather than using cli is that you need to handle cli arguments on your own (it can be workarounded though).

What's your purpose? Depending in your needs maybe there is other option you could use or I could modify our code so it'll be possible ie to output issues in json format even from cli.

@mnojek
Copy link
Member

mnojek commented Apr 10, 2022

Hey @bhirsz. What do you think about this issue? Are we going to add possibility to prepare JSON output from CLI? Sounds like a nice improvement, but overall no one was asking for this feature (apart from @ZephyrusMB).

@bhirsz
Copy link
Member

bhirsz commented Apr 11, 2022

@mnojek
It can be added but we need feature request for it - I'm voting for closing this bug and if someone (such as @ZephyrusMB ) wants to feature he can create feature request.

But the bug mentioned that JsonOutput is mentioned in docs: https://robocop.readthedocs.io/en/stable/reports.html I think we need to update the docs so it's clear that it's internal report and can be only used if we're using Robocop python API.

@mnojek
Copy link
Member

mnojek commented Apr 11, 2022

Are you able to

But the bug mentioned that JsonOutput is mentioned in docs: https://robocop.readthedocs.io/en/stable/reports.html I think we need to update the docs so it's clear that it's internal report and can be only used if we're using Robocop python API.

Are you able to add it? I haven't touched that part of the code.

@bhirsz
Copy link
Member

bhirsz commented Apr 12, 2022

Yes, I will do it.

@bhirsz bhirsz self-assigned this Apr 12, 2022
@Reddriver
Copy link

@bhirsz and @mnojek Hi, I did same thing as author of this issue. Can you add note about this behaviour in documentation? I tried also ,,version", no output about version to CMD, is this also functionality for Python?

@bhirsz
Copy link
Member

bhirsz commented Jun 20, 2022

I will redo the documentation soon for the json report.

@Reddriver As for the version report it should work (from Robocop 2.1.0 onwards). Just tested it:
image

@Reddriver
Copy link

I've just tested ,,version" in 2.1.0, it is OK. Something has changed, in version 2.0.2 it isn't working. Anyway it works now.

@bhirsz
Copy link
Member

bhirsz commented Jun 20, 2022

It was only introduced in 2.1.0 that's why it doesn't work in 2.0.2 (compare https://robocop.readthedocs.io/en/2.0.2/reports.html and https://robocop.readthedocs.io/en/2.1.0/reports.html).

@Reddriver
Copy link

well, I see now, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants