robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[QUESTION] Disable Keyword Error notification for duplicate keyword names

Open burrk opened this issue 1 year ago • 5 comments

This is from https://robotframework.slack.com/archives/C0103745J7P/p1718374099910529 and is the same problem as this one was in LSP: https://github.com/robocorp/robotframework-lsp/issues/724

Simply, we use library search order to enable Page Objects to use the same keywords - just like objects should do. Please see the Robocorp issue for examples etc. We would like to switch to RobotCode but our code is covered in red squiggles - How do we turn the robotcode.namespace(KeywordError) off for multiple keywords with the same name?

Right now I would almost be happy to turn off all error messages! (There are so many squiggles we can't see them anyways)

We have tried setting robotcode.analysis.robot.globalLibrarySearchOrder, and it is very good at finding all the duplicates. Can we just turn this check off?

Thank-you!

Desktop (please complete the following information):

  • VS Code Version: 1.90.1

  • RobotCode Version: 0.83.1

  • OS: Windows 10 Enterprise 22H2

  • Python Version: 3.9.13

  • RobotFramework Version: 6.1.1

  • RoboCorp Code Version: 1.22.3 (we are still using it to manage our development environment - for now)

  • Robot Framework Language Server is disabled (until we replace it with RobotCode)

  • Additional tools like robocop, robotidy - not yet

burrk avatar Jun 18 '24 17:06 burrk

I found a "Disable Keyword Error for this line" option in the right button context menu when I click on the error in the Problems pane, or in the error lightbulb's "quick fix" menu.

It doesn't seem to do anything... and the 'error' is on far too many lines to disable it on each one...

burrk avatar Jun 18 '24 17:06 burrk

Hello @burrk,

Unfortunately, it is not currently possible to disable this check. However, I am working on some options to optimize the analysis of Robot files and make it executable on the console as well. By then, it should be possible to disable these checks.

I might also be able to prioritize this and enable the disabling of checks globally or for an entire file sooner.

There is also Enhancement #203, which aims to incorporate the search order into the analysis.

Could you please provide an example of how such test cases look in your setup and how you manage the search order once it is set in a suite? What impact does this have on other test cases or keywords?

d-biehl avatar Jun 21 '24 08:06 d-biehl

Thanks @d-biehl

I could copy everything from the same bug in LSP: https://github.com/robocorp/robotframework-lsp/issues/724 if that helps?

This is the initial message in the conversation:


Enhancement https://github.com/robocorp/robotframework-lsp/issues/432 causes code which depends on Builtin.Set Library Search Order (http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Library%20Search%20Order) for pseudo-OOP polymorphism to be detected as errors (most of our robot code turns red).

In addition setting "robot.lint.keywordResolvesToMultipleKeywords": false to turn this feature off, causes LSP to miss other problems in the same code.

This is from a conversation with @fabioz on the RobotFramework's Slack channel: https://robotframework.slack.com/archives/C01AWSNKC2H/p1659529202045659?thread_ts=1659365333.316959&cid=C01AWSNKC2H

Set Library Search Order is especially important for RF Page Object frameworks:

  • The RobotFramework-PageObectLibrary uses it to move the current page`s code to the front of the keyword search order. Code: https://github.com/boakley/robotframework-pageobjectlibrary/blob/0ecc01a001196bce4f60528628b5f0b243928e43/PageObjectLibrary/keywords.py#L56
  • Salesforce's CumulusCI's Robot Framework Page Object code uses it similarly: https://github.com/SFDO-Tooling/CumulusCI/blob/cd3be712e3e2fa06a8bd0e6b70e94924a2764a51/cumulusci/robotframework/pageobjects/PageObjects.py#L345 (same author)
  • In the past, I used it in a simple RF script based page object framework: (Every page library had a unique Verify Page Loaded function, as well as other functions with identical names, like Submit)
On Page
    [Arguments]    ${page}
    [Documentation]  Changes library search order so page object's name does not have to appended to each keyword
    ...    
    ...    It *also verifies the page has been loaded*.  This all makes the code easier to read. For example:
    ...    
    ...    Instead of:
    ...    | LogonPage.Verify Page Loaded  |             |
    ...    | LogonPage.Set User Name Field | ${username} |
    ...    | LogonPage.Set Password Field  | ${password} |
    ...    | LogonPage.Submit              |             |
    ...    
    ...    Use:
    ...    | On Page | LogonPage           |             |
    ...    |         | Set User Name Field | ${username} |
    ...    |         | Set Password Field  | ${password} |
    ...    |         | Submit              |             |
    ...    _(Empty first column is just for readability)_
    ...
    ...    See also 
    ...    [http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Library%20Search%20Order|Set Library Search Order] 
    ...    and each page's ``Verify Page Loaded`` keywords
    ...    
    Set Library Search Order	${page}
    Verify Page Loaded
  • I'm sure people use Set Library Search Order for other things as well :-)

burrk avatar Jun 21 '24 20:06 burrk

Hi @d-biehl, Does that provide enough information and examples of code from Git?

burrk avatar Jul 05 '24 20:07 burrk

He @burrk,

I have enough information ;-) I've already started to implement a solution, but I still need a bit more time...

d-biehl avatar Jul 06 '24 11:07 d-biehl