This product is not supported for your selected Datadog site. ().
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Metadata

ID: swift-code-style/tuples-too-large

Language: Unknown

Severity: Notice

Category: Best Practices

Description

Tuples should not be too large. This is because tuples are designed to be simple, quick ways to group related values. They are not meant to serve as data structures or record types, which are better suited to handle larger amounts of data.

To avoid the violation of this rule, you should consider using a struct or a class when you find yourself needing a tuple with more than two or three items. For example, instead of func myfunction() -> (Int, Int, Int, String) {}, you could define a struct like this: struct MyFunctionResult { let a: Int; let b: Int; let c: Int; let d: String }, and then have myfunction() return a MyFunctionResult. This makes your code more readable and easier to maintain.

Non-Compliant Code Examples

func myfunction() -> (Int, Int, Int, String) {}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

シームレスな統合。 Datadog Code Security をお試しください