robotframework-robocop icon indicating copy to clipboard operation
robotframework-robocop copied to clipboard

[Rule] Calling keyword outlook should follow keyword definition outlook

Open rikerfi opened this issue 2 years ago • 2 comments

What happened?

Rule to keep keyword calling outlook in line with the keyword definition:

*** Settings ***
Library           String


*** Test Cases ***
Calling Keywords
    ${CAPS}  Set Variable  NOLOWERCASEHERE
    # From String library 'Convert To Lower Case' keyword
    ${low}   Convert To Lower Case  ${CAPS}    
    # Following should warn/info
    ${low}   ConvertTo Lower Case   ${CAPS}    
    ${low}   ConvertToLower Case    ${CAPS}    
    ${low}   ConvertToLowerCase     ${CAPS}    
    ${low}   Convert ToLower Case   ${CAPS}    
    ${low}   Convert To LowerCase   ${CAPS}    

Operating System

Linux

Robocop version

1.10.0

rikerfi avatar Mar 09 '22 08:03 rikerfi

To verify - do you mean that we should check if the same naming convention is used across the same scope? For example if the same keyword is used at the beginning of the keyword it should use the same name:

My Keyword    ${arg}
My_Keyword    ${arg}  # warns that we don't follow the same naming
My Keyword    ${arg}  # fine
My keyword    ${arg}  # warns that we don't follow the same naming

OR rather it's about checking if the keyword call uses the same name convention as library definition? This would be check that requires context reading and for most of the libraries wouldn't be possible to implement in the Robocop (without initializing your project we don't know your libraries etc). But it could be possible for built in libraries as bare minimum.

bhirsz avatar Jul 26 '22 11:07 bhirsz

It is more like the latter:

OR rather it's about checking if the keyword call uses the same name convention as library definition? This would be check that requires context reading and for most of the libraries wouldn't be possible to implement in the Robocop (without initializing your project we don't know your libraries etc). But it could be possible for built in libraries as bare minimum.

Indeed, this blurs the line of static analysis. This RF behavior is a bit annoying from the maintenance point of view. Searching various possible keyword 'outlooks' across the code is a bit painful.

    Hit Homepage
    Hit Home page

The rule would be useful, but implementation would be troublesome and with many pitfalls...

rikerfi avatar Aug 14 '22 19:08 rikerfi