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

FP S1854 DeadStoreCheck: `defer` statement

    XMLWordPrintable

    Details

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

      Description

      func processFile(filename: String) throws {
          if exists(filename) {
              let file = open(filename)
              var option = "foo"
              defer {
                  close(file, option)
              }
              option = "bar" // FP here
              while let line = try file.readline() {
                  // Work with the file.
              }
              // close(file, option) is called here, at the end of the scope.
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pierre-yves.nicolas Pierre-Yves Nicolas
              Reporter:
              elena.vilchik Elena Vilchik
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: