question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.robocop not picked up when using API

See original GitHub issue

When using the API as:

    import robocop
    from robocop.config import Config
    from robocop.utils import issues_to_lsp_diagnostic

    config = Config(root=project_root)
    robocop_runner = robocop.Robocop(config=config)
    robocop_runner.reload_config()

    issues = robocop_runner.run_check(ast_model, filename, source)
    diag_issues = issues_to_lsp_diagnostic(issues)
    return diag_issues

The .robocop file is not being loaded based on the project_root.

I debugged a bit and it seems like load_default_config_file is never called. I tried to manually call: config.parse_opts([]), right after creating the Config and it seems to pick things up on the debugger, but I still couldn’t get it to ignore what I expected.

I tested with a file with:

*** Test Cases ***
Test
    Fail

and a .robocop file with:

--exclude missing-doc-testcase
--include missing-doc-suite

But the missing doc in the testcase is still reported.

So, I’m waiting on some pointers on what I’m doing wrong here…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bhirszcommented, Mar 25, 2021

Configuration (when calling parse_opts and .robocop existing) is loaded correctly. The problem is that we’re ‘filtering out’ some if the issues - based on config - when reporting the issues. Since we’re not reporting the issues in self.run method it will leave everything (instead of reporting them we return list of issues, that is converted to lsp diagnostic later on). I will rearrange our architecture.

Also if the root is not the Path it will throw an error (I saw you made workaround for that). I will fix that as well.

1reaction
bhirszcommented, Mar 25, 2021

For argument parsing issues I had to create workaround - because argparse that we’re using in Robocp always returns SystemExit. After my changes, if you’re using Robocop API and you have invalid configuration it should return “InvalidArgumentError” exception (found in robocop.exceptions).

Read more comments on GitHub >

github_iconTop Results From Across the Web

User guide - Robocop 2.6.0
This is short overview of how to use Robocop together with links to more extensive documentation. You can run lint scan on Robot...
Read more >
MarketSquare/robotframework-robocop - GitHub
Tool for static code analysis of Robot Framework language - GitHub - MarketSquare/robotframework-robocop: Tool for static code analysis of Robot Framework ...
Read more >
RoboCon 2021 - 3.03 NEW PARSING API FOR ROBOT ...
What is the connection between fast development of recent RF versions and new parsing API ? It makes extending Robot Framework code a...
Read more >
API Errors - Oracle Help Center
Learn about the common errors returned by all the services for Oracle Cloud Infrastructure.
Read more >
How to Debug Web API Problems in 4 Steps - Kill All Defects
This article is a step-by-step diagnostic guide for working through common issues with web services. The article assumes that you have a web ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found