File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 11import Foundation
22
3- class MyViewController : UIViewController { // space before colon
4- var userName : String = " " // no space after colon; redundant type
5- let x = 5 // short variable name
3+ class MyViewController : UIViewController { // space before colon
4+ var userName : String ? = " " // no space after colon; redundant type
5+ let x = 5 // short variable name
66
7- func doSomething( arg: Int ) { // unused parameter
8- let result = userName as! String // force cast
7+ func doSomething( arg: Int ) { // unused parameter
8+ let result = userName as! String // force cast
99
10- if ( result. count > 0 ) { // control statement parentheses; use !isEmpty
10+ if ( result. count > 0 && x > 1 ) { // control statement parentheses; use !isEmpty; prefer condition list
1111 print ( " User name is not empty " )
12+ return
13+ } else { // unnecessary else
14+ print ( " User name is empty " )
1215 }
1316
14- // try! someRiskyOperation() // SwiftLint is syntax-aware -> no violation here
15- try ! someRiskyOperation ( ) // force try
17+ // try! someOperation() // SwiftLint is syntax-aware -> no violation here
18+ try ! MyViewController . someOperation ( ) // force try; prefer Self
1619 }
1720
18- func someRiskyOperation ( ) async throws { // unnecessary async; unnecessary throws
19- // Implementation
21+ final class func someOperation ( ) async throws { // final class -> static; unnecessary async; unnecessary throws
22+ if let userName = userName { } // shorthand optional binding; empty block
2023 }
2124}
25+
You can’t perform that action at this time.
0 commit comments