- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
",t};e.buildCustomizationMenuUi=t;function n(e){let t='
",t}function s(e){let n=e.filter.currentValue||e.filter.defaultValue,t='${e.filter.label}
`,e.filter.options.forEach(s=>{let o=s.id===n;t+=``}),t+="${e.filter.label}
`,t+=`ID: swift-code-style/max-class-lines
Language: Unknown
Severity: Warning
Category: Best Practices
This rule states that Swift classes should not exceed 1000 lines of code (by default). The purpose of this guideline is to ensure code remains readable and maintainable. Large classes can become difficult to understand, debug, and maintain, increasing the likelihood of bugs and inefficiencies.
Following this rule promotes clean code practices and fosters efficient software development. It encourages developers to adopt modularity by breaking down complex problems into smaller, more manageable pieces.
To prevent classes from becoming too large, it is good practice to split functionality into multiple smaller classes, each with a single, well-defined responsibility. If a class is growing too complex, evaluate whether some of its functionality can be moved to a separate class. You can use inheritance or composition to help distribute responsibilities. For example, if MyClass
is too large, you could create a new class, MySubClass
, and let MyClass
inherit from it:
class MySubClass {
func foo() {}
}
class MyClass: MySubClass {
override init() {
super.init()
}
}
The goal is to write code that is easy to read, understand, and maintain. By keeping classes concise and focused, you can improve code quality and make your software easier to work with.
max-lines
: Maximum number of lines. Default: 100.// This class is NOT compliant because it is >100 lines long.
class Person {
var name: String
var age: Int
var occupation: String?
init(name: String, age: Int, occupation: String? = nil) {
self.name = name
self.age = age
self.occupation = occupation
}
func displayOccupation() {
print(self.age);
}
}
// This class is compliant because it is <=100 lines long.
class Person {
var name: String
var age: Int
var occupation: String?
init(name: String, age: Int, occupation: String? = nil) {
self.name = name
self.age = age
self.occupation = occupation
}
func displayOccupation() {
print(self.age);
}
}