Add ignore_codingkeys parameter to nesting#5650
Conversation
Generated by 🚫 Danger |
SimplyDanny
left a comment
There was a problem hiding this comment.
Thank you for the contribution! Looks good in principle.
What about the following example?
struct Outer {
enum CodingKeys: String, CodingKey {
case id
struct S {}
}
}I think, the rule should trigger on S.
You need to run IntegrationTests locally and fix all linting issues it reports and update the configuration set reference file.
Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/NestingConfiguration.swift
Outdated
Show resolved
Hide resolved
|
FYI I'm out of town until next weekend. I'll jump back into this once I'm back |
0be58c7 to
2f71da4
Compare
2f71da4 to
0e488b2
Compare
It wasn't a year long vacation but here we are a year later 😓
I've updated this so that this will now trigger the rule.
I think I've got this done? I moved the I don't fully understand what is failing now? |
SimplyDanny
left a comment
There was a problem hiding this comment.
Glad you are back! 🥳 I have a few more comments ...
| verifyRule(description, ruleConfiguration: ["ignore_typealiases_and_associatedtypes": true]) | ||
| } | ||
|
|
||
| func testNestingWithoutCodingKeys() { |
There was a problem hiding this comment.
You can move these examples directly into NestingRuleExamples. Any options deviating from the default will be added to the online documentation, so it's clear why an example triggers or why it doesn't.
There was a problem hiding this comment.
I might need just a little bit more clarification what you mean by this? I was thinking because these are not using the default configuration they shouldn't be in the default examples.
But you're saying they should?
There was a problem hiding this comment.
In the documentation that includes these examples later, we now also show the configuration in case it deviates from the default one. So having them as normal examples is even nicer as people also see how options influence the rule's behavior.
There was a problem hiding this comment.
Ahhh okay I didn't realize that Example has a configuration option. That's why I was confused!
Okay I updated these and I removed the tests. Which I'm not 100% sure about... but I thought the testing covered all the default examples. Is that wrong?
There was a problem hiding this comment.
The feature that configurations are added to the examples in the documentation is quite new and we won't convert existing tests. But we should prefer this way of documenting examples from now on.
|
For the build, please rebase onto the current |
a5e0ba1 to
16d7dd7
Compare
This only returns true when the name of the enum is CodingKeys and it conforms to CodingKey
This prevents nested CodingKeys (which may be necessary for functioning Codable conformance) from triggering nesting violations
Essentially this changes the logic so that coding keys do still COUNT towards the depth. But they don't cause violations themselves
16d7dd7 to
44ffcd3
Compare
SimplyDanny
left a comment
There was a problem hiding this comment.
Looks good now. Thanks for the updates, @braker1nine!
Resolves #5641
This very explicitly targets
enum's namedCodingKeyswhich conform toCodingKey. To provide an exception forCodableusers who have to provide custom keys.OK ✅
Not OK ❌