You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defining another variable let expected = 7 would not improve style, but would rather make the code more opaque and difficult to reason about.
It's probably required to add a configuration option to specify which parent classes make a test class a test class. In the example, it's XCTestCase (the default of the option). This can be taken over from already existing rules specific for tests.
Environment
0.51.0
Homebrew
Paste your configuration file:
only_rules:
- no_magic_numbers
The text was updated successfully, but these errors were encountered:
What configuration options were you thinking of @SimplyDanny?
Presumably a test_parent_classes: [“QuickSpec”, “XCTestCase”] like the test related rules have. Would that be empty by default, or would there be a separate flag to say "ignore cases in test classes", and then test_parent_classes to determine which classes are tests?
Yes, the option test_parent_classes is what I was referring to. The default can be the same like in the other rules supporting this option. I think it's reasonable for this rule to ignore tests by default. If anyone likes to see violations in tests, the option can be cleared.
We would not need it if we have another reliable marker characterizing test classes. I have no idea though. Let me know if you see another way to recognize them.
I can't think of another way - I can have a go at adding that in - should be pretty easy, unless you've already started, in which case I can hang back ...
Description
In test code, it's reasonable to use raw numbers in assertions. The
no_magic_numbers
rule thus reports a lot of findings in tests.Defining another variable
let expected = 7
would not improve style, but would rather make the code more opaque and difficult to reason about.It's probably required to add a configuration option to specify which parent classes make a test class a test class. In the example, it's
XCTestCase
(the default of the option). This can be taken over from already existing rules specific for tests.Environment
The text was updated successfully, but these errors were encountered: