-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rule] Too many arguments without default #1145
Comments
That's good idea. For how we want to do it, I would:
I'm debating between 1 and 2. If we want to check number of default arguments separately, we might also want to parametrize it (ie. allow up to 10 default arguments, no more). Given that, maybe:
Both new rules would be non-default. |
I like the three-rule approach. It offers maximum flexibility in an understandable way. We can also name the new rules I'm not so sure about the defaults though. I think it might be worth making
This is a breaking change, but I think it'd be worth it during a major release. |
Agree on required/optional names. 3 required arguments can be bit too low, if we stick to 5 it would be breaking change but with minimal impact (nothing will fail as people with existing default configuration will use 5. If they configure max_args in |
I took a good look at our codebase to see what a reasonable default could be. I agree, 3 is a bit too low, but I also think that 5 is too high. In our codebase, it looks like 4 is the sweet spot. With max 4 required arguments, I may have to add a couple of disablers, but most keywords with 5 or more should be solved in a different way. In our way of working, the only bar you have to clear to justify a disabler is to convince the reviewer. This allows us to be a bit stricter with our lint rules than others might want. With that in mind, I'd change |
Having keywords in test with 5 arguments does sound excessive - but I'm sticking to it since it's current default. If the official code style mention it, I will adjust the numbers accordingly. Thanks for checking out the numbers |
I am personally not a fan of the rule
too-many-arguments
. Instead, I want to proposetoo-many-arguments-without-default
.A lot of arguments can make a keyword cumbersome to use. It can also be an indication of too much keyword complexity. However, I don't think having a lot of arguments with defaults is always an issue. For example:
This is (a modified version of) a keyword we use all the time for user account creation. Note it has more than the default allowed 5 arguments, but all have a default value. The unmodified version has 10 arguments, all with a sensible default value.
In most tests, we use the keyword without arguments. In tests where we need a specific account state, we use the keyword with a few arguments overwritten. I think that with a pattern like this, you can create great keywords with many arguments. These keywords offer great flexibility.
At the same time, I think that the following is a bad pattern and should not be used:
There are too many arguments here that you always have to explicitly fill. This makes the keyword hard to use and hard to understand.
There are a few ways we can achieve this:
too-many-arguments-without-default
as a non-default rule.too-many-arguments
. This parameter could be calledignore_optional_arguments
.too-many-arguments
.If you agree with me, please let me know and I'll open a PR.
The text was updated successfully, but these errors were encountered: