Uploaded image for project: 'SonarSwift'
  1. SonarSwift
  2. SONARSWIFT-365

FP S1481: variable declared inside compiler directives

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3
    • Component/s: False-Positives, Rules
    • Labels:
      None

      Description

        var image: Image {
      
          let bundle = Bundle(for: BundleToken.self)
      
          #if os(iOS) || os(tvOS)
      
          let image = Image(named: name, in: bundle, compatibleWith: nil)   // FP
      
          #elseif os(OSX)
      
          let image = bundle.image(forResource: NSImage.Name(name))   // FP
      
          #elseif os(watchOS)
      
          let image = Image(named: name)   // FP
      
          #endif
      
          guard let result = image else { fatalError("Unable to load image named \(name).") }
      
          return result
      
        }
      

      Issue reported https://groups.google.com/forum/#!topic/sonarqube/_Y1J_anO85o

        Attachments

          Activity

            People

            Assignee:
            alban.auzeill Alban Auzeill
            Reporter:
            elena.vilchik Elena Vilchik
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: