Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Message:Refactor the code to not need these conditional compilation directives.
-
Default Severity:Critical
-
Impact:High
-
Likelihood:Low
-
Covered Languages:Swift
-
Remediation Function:Constant/Issue
-
Constant Cost:30min
Description
Conditional compilation is generally recognized as a bad practice that is occasionally necessary when dealing with platform-specific code. As much as possible, code should be refactored to minimize or eliminate conditionally-compiled, platform-specific code because even when necessary and well-intentioned, such code segments can leave your codebase in a hopeless tangle.
Noncompliant Code Example
#if os(OSX) // Noncompliant let a = 2 #else let a = 3 #endif
Attachments
Issue Links
- is implemented by
-
SONARSWIFT-41 Rule: Conditional compilation should not be used
-
- Closed
-