- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: ruby-best-practices/infinite-loop
Language: Ruby
Severity: Info
Category: Best Practices
The Ruby static analysis rule “Use Kernel#loop instead of while/until” focuses on promoting the use of Kernel#loop
for infinite loops rather than while true
or until false
. This is because Kernel#loop
is more idiomatic to Ruby, and it communicates the intent of an infinite loop more clearly. This rule helps to maintain readability, which is crucial in large codebases where understanding the flow and function of the code is important.
The while true
or until false
expressions can be misleading as they suggest a condition that might change, even though they are used to create infinite loops. Using Kernel#loop
eliminates this ambiguity, making the code easier to understand.
To adhere to this rule, replace any while true
or until false
loops with Kernel#loop
. The body of the loop remains the same. This small change can significantly improve the clarity of the code, making it more understandable for other developers who might work on the same codebase.
while true
do_something
end
until false
do_something
end
loop do
do_something
end
|
|
For more information, please read the Code Analysis documentation
Identify code vulnerabilities directly in yourVS Code editor
Identify code vulnerabilities directly inJetBrains products