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

Rule [too-few-calls-in-keyword] too strict?

Open UliSei opened this issue 1 year ago • 1 comments

What happened?

With the following sample file I get the check result: Snippets/Robcop-too-few-calls-in-keyword.robot:11:1 [W] 0502 Keyword 'Keyword With Some Logic' has too few keywords inside (0/1) (too-few-calls-in-keyword) In my opinion this result is too strict because the keyword contains a complex logic structure and some keywords from BuiltIn lib.

*** Settings ***
Documentation      Test rule too-few-calls-in-keyword


*** Test Cases ***
My Test Case
    No Operation


*** Keywords ***
Keyword With Some Logic
    [Arguments]        ${value}
    IF    ${value} == ${A}
        RETURN    ${1}
    ELSE IF    ${value} == ${B}
        RETURN    ${2}
    ELSE IF    ${value} == ${C}
        RETURN    ${3}
    ELSE IF    ${value} == ${D}
        RETURN    ${4}
    ELSE
        Log    Unexpected value ${value}.    console=yes
        No Operation
        RETURN    ${0}
    END

Operating System

No response

Robocop version

2.1.0

UliSei avatar Jul 06 '22 10:07 UliSei

Looks like a bug - or two actually. The first is when we are not counting RETURN as keyword call (it's technically setting, but for purpose of this rule we should count it as keyword call) and the second is not counting whatever is in IF ELSE branches.

bhirsz avatar Jul 06 '22 10:07 bhirsz

I've checked and also content of TRY EXCEPT is not counted and BREAK and CONTINUE statements are not counted as well.

bhirsz avatar Sep 04 '22 11:09 bhirsz