Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3111

Conditional compilation should not be used

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • 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

            Activity

              People

              Assignee:
              elena.vilchik Elena Vilchik
              Reporter:
              ann.campbell.2 Ann Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: