- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: ruby-best-practices/no-then
Language: Ruby
Severity: Notice
Category: Best Practices
The then
keyword is not necessary in multi-line if/unless/when/in
statements in Ruby. When used in multi-line statements, it can make the code harder to read and understand. This is because then
is typically associated with single-line conditional statements in Ruby, and its use in multi-line statements can be confusing.
Maintaining readability and clarity in your code is crucial for effective collaboration and debugging. It becomes even more important in larger codebases, where complex logic can become difficult to follow if not written clearly.
To avoid this issue, omit the then
keyword in your multi-line if/unless/when/in
statements. For single-line if/unless/when/in
statements, using then
is acceptable and can help improve readability. This practice keeps your code clean and easy to understand, following the principles of good coding practices.
if condition then
do_something
end
case expression
when condition then
do_something
end
case expression
in pattern then
do_something
end
if condition
do_something()
end
case expression
when condition
do_something()
end
case expression
in pattern
do_something()
end
if condition then 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