SwiftLint
                                
                                 SwiftLint copied to clipboard
                                
                                    SwiftLint copied to clipboard
                            
                            
                            
                        stdout output contains duplicate content when autocorrecting vertical whitespace
New Issue Checklist
- [x] Updated SwiftLint to the latest version
- [x] I searched for existing GitHub issues
Describe the bug
I'm hoping to make use of https://github.com/realm/SwiftLint/pull/4132 (stdin/stdout). Autocorrecting vertical whitespace (vertical_whitespace, vertical_whitespace_closing_braces, and vertical_whitespace_opening_braces) seems to duplicate the file content in the output.
Test.swift:
class Test {
    let x : String = "test"
}
Output:
$ cat Test.swift | swiftlint --fix --use-stdin --enable-all-rules
class Test {
    let x: String = "test"
}
class Test {
    let x : String = "test"
}
class Test {
    let x : String = "test"
}
Done correcting 1 file!
The issue does not occur if the vertical_whitespace, vertical_whitespace_closing_braces, and vertical_whitespace_opening_braces rules are excluded.
.swiftlint-fix.yml:
disabled_rules:
  - vertical_whitespace
  - vertical_whitespace_closing_braces
  - vertical_whitespace_opening_braces
Output:
$ cat Test.swift | swiftlint --fix --use-stdin --config .swiftlint-fix.yml         
class Test {
    let x: String = "test"
}
Done correcting 1 file!
Environment
- SwiftLint version (run swiftlint versionto be sure)? 0.49.1
- Installation method used (Homebrew, CocoaPods, building from source, etc)? SwiftLint.pkg
- Are you using nested configurations? No
- Which Xcode version are you using (check xcodebuild -version)? 13.3.1 (13E500a)
This behavior can be observed with all rules writing directly to the file when correcting. It's not only about the vertical_whitespace* rules. They perform the fix and immediately write the result back to the file. If the file is stdout we notice the different writes as separate outputs.