You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Omit needless words] Split before last preposition in most cases.
Splitting *before* the last preposition tends to keep the
prepositional phrase together. Only leave the preposition on the base
name in rare cases where we would end up with weird argument labels
(e.g., prefer "moveTo(x:y:)" to "move(toX:y:)").
Also, refine our heuristics for when we can remove the preposition
entirely.
Copy file name to clipboardExpand all lines: test/Sema/omit_needless_words.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
classC1{
4
4
init(tasteString:String){} // expected-warning{{'init(tasteString:)' could be named 'init(taste:)'}}{{8-8=taste }}
5
5
func processWithString(string:String, toInt:Int){} // expected-warning{{'processWithString(_:toInt:)' could be named 'process(withString:to:)'}}{{8-25=process}}{{42-42=to }}
6
-
func processWithInt(value:Int){} // expected-warning{{'processWithInt' could be named 'processWith'}}{{8-22=processWith}}
6
+
func processWithInt(value:Int){} // expected-warning{{'processWithInt' could be named 'process(withInt:)'}}{{8-22=process}}
7
7
}
8
8
9
9
extensionString{
@@ -14,7 +14,7 @@ extension String {
14
14
func callSites(s:String){
15
15
letc1=C1(tasteString:"blah") // expected-warning{{'init(tasteString:)' could be named 'init(taste:)'}}{{15-26=taste}}
16
16
c1.processWithString("a", toInt:1) // expected-warning{{'processWithString(_:toInt:)' could be named 'process(withString:to:)'}}{{6-23=process}}{{29-34=to}}
17
-
c1.processWithInt(5) // expected-warning{{'processWithInt' could be named 'processWith'}}{{6-20=processWith}}
17
+
c1.processWithInt(5) // expected-warning{{'processWithInt' could be named 'process(withInt:)'}}{{6-20=process}}
18
18
_ =String.randomString // expected-warning{{'randomString' could be named 'random'}}{{14-26=random}}
19
19
_ = s.wonkycasedString // expected-warning{{'wonkycasedString' could be named 'wonkycased'}}{{9-25=wonkycased}}
0 commit comments