[Bug] Any text before dot in keyword name is acknowledged as library name
What happened?
Bug details
When Using gherkin with a dot . And a ppp file '1.log' is loaded
rule 0302 -c 0302:convention:first_word_capitalized
Keyword is fine but Robocop complains with error:
Keyword name "And a ppp file '1.log' is loaded''' should use title case
Robocop expect "Log" to be written as first word capitalized but log should be ok as well in this case
Greetings Ruud
Operating System
No response
Robocop version
2.0.1
Thanks @p74 for reporting this issue.
This is due to the fact that we normalize the keyword name before running a rule on it and in this case (And a ppp file '1.log' is loaded) everything before the dot is removed and we only parse log is loaded which leads to the reported output. I will take a look how we can handle such cases in the code.
I know gherkin is bit difficult to handle for tools like this as it's difficult to discover if it's gherkin or keyword but in this case I have some ideas for example ignore what is between ' and " (variables are defined between quotes) Ignore the last char. Or make an option to ignore this dot.. other possibility is only ignore the first chars followed by a dot until the first space
The problem here is how we discover keyword's library prefix. It's too simple approach and I need to think about something more precise. Gherkin is already supported and it's not the issue here :) I think I will have some time to look at it today, but I can't promise.
Yes - the problem is with how we discover keyword prefix. Robot Framework uses quite complex logic here. If you have "Some.Text" keyword, it will check if "Some.Text" keyword exist somewhere, and if not it will check if "Some" library exists, and if so it will check it for "Test" keyword (simplifying a bit). In Robocop we don't have access to libraries resources so we need to guess if something is library name or not. Library names are not checked. In your case with the keyword:
And a ppp file '1.log' is loaded
we are discarding everything before . and we're only checking:
log' is loaded
I think we should improve how we recognize library name - for example we can agree that libraries don't have ' in its names - just alpha numeric (however it could be also robot ${Variable}). We need to investigate what is allowed for library name and use is as pattern.