@@ -27,70 +27,71 @@ private enum Element {
2727 case end
2828}
2929
30- private func print < Target: TextOutputStream > (
30+ private func buildString < Target: TextOutputStream > (
3131 _ text: String ,
3232 indent: Int ,
3333 to output: inout Target
3434) {
35- Swift . print ( " \( String ( repeating: " " , count: indent) ) \( text) " , to: & output)
35+ print ( " \( String ( repeating: " " , count: indent) ) \( text) " , to: & output)
3636}
3737
38+ // swiftlint:disable:next cyclomatic_complexity
3839private func debugDescriptionBuilder< Target: TextOutputStream > (
3940 elements: [ ( Element , Int ) ] ,
4041 to output: inout Target
4142) {
4243 for (element, indent) in elements {
4344 switch element {
4445 case let . type( type) :
45- print ( " < \( type) : " , indent: indent, to: & output)
46+ buildString ( " < \( type) : " , indent: indent, to: & output)
4647
4748 case let . index( index) :
48- print ( " [ \( index) ]: " , indent: indent, to: & output)
49+ buildString ( " [ \( index) ]: " , indent: indent, to: & output)
4950
5051 case let . id( id) :
51- print ( " id: \( id) " , indent: indent, to: & output)
52+ buildString ( " id: \( id) " , indent: indent, to: & output)
5253
5354 case let . header( header) :
5455 if let header {
55- print ( " header: \( header. id) ( \( header. reuseIdentifier) ) " , indent: indent, to: & output)
56+ buildString ( " header: \( header. id) ( \( header. reuseIdentifier) ) " , indent: indent, to: & output)
5657 } else {
57- print ( " header: nil " , indent: indent, to: & output)
58+ buildString ( " header: nil " , indent: indent, to: & output)
5859 }
5960
6061 case let . footer( footer) :
6162 if let footer {
62- print ( " footer: \( footer. id) ( \( footer. reuseIdentifier) ) " , indent: indent, to: & output)
63+ buildString ( " footer: \( footer. id) ( \( footer. reuseIdentifier) ) " , indent: indent, to: & output)
6364 } else {
64- print ( " footer: nil " , indent: indent, to: & output)
65+ buildString ( " footer: nil " , indent: indent, to: & output)
6566 }
6667
6768 case let . cells( cells) :
6869 if !cells. isEmpty {
69- print ( " cells: " , indent: indent, to: & output)
70+ buildString ( " cells: " , indent: indent, to: & output)
7071 } else {
71- print ( " cells: none " , indent: indent, to: & output)
72+ buildString ( " cells: none " , indent: indent, to: & output)
7273 }
7374
7475 for (index, cell) in cells. enumerated ( ) {
75- print ( " [ \( index) ]: \( cell. id) ( \( cell. reuseIdentifier) ) " , indent: indent + 2 , to: & output)
76+ buildString ( " [ \( index) ]: \( cell. id) ( \( cell. reuseIdentifier) ) " , indent: indent + 2 , to: & output)
7677 }
7778
7879 case let . supplementaryViews( supplementaryViews) :
7980 if !supplementaryViews. isEmpty {
80- print ( " supplementary views: " , indent: indent, to: & output)
81+ buildString ( " supplementary views: " , indent: indent, to: & output)
8182 } else {
82- print ( " supplementary views: none " , indent: indent, to: & output)
83+ buildString ( " supplementary views: none " , indent: indent, to: & output)
8384 }
8485
8586 for (index, supplementaryView) in supplementaryViews. enumerated ( ) {
86- print ( " [ \( index) ]: \( supplementaryView. id) ( \( supplementaryView. reuseIdentifier) ) " , indent: indent + 2 , to: & output)
87+ buildString ( " [ \( index) ]: \( supplementaryView. id) ( \( supplementaryView. reuseIdentifier) ) " , indent: indent + 2 , to: & output)
8788 }
8889
8990 case let . sections( sections) :
9091 if !sections. isEmpty {
91- print ( " sections: " , indent: indent, to: & output)
92+ buildString ( " sections: " , indent: indent, to: & output)
9293 } else {
93- print ( " sections: none " , indent: indent, to: & output)
94+ buildString ( " sections: none " , indent: indent, to: & output)
9495 }
9596
9697 for (index, section) in sections. enumerated ( ) {
@@ -102,34 +103,34 @@ private func debugDescriptionBuilder<Target: TextOutputStream>(
102103 ( . footer( section. footer) , indent + 4 ) ,
103104 ( . cells( section. cells) , indent + 4 ) ,
104105 ( . supplementaryViews( section. supplementaryViews) , indent + 4 ) ,
105- ( . isEmpty( section. isEmpty) , indent + 4 ) ,
106+ ( . isEmpty( section. isEmpty) , indent + 4 )
106107 ] ,
107108 to: & output
108109 )
109110 }
110111
111112 case let . registrations( registrations) :
112113 if !registrations. isEmpty {
113- print ( " registrations: " , indent: indent, to: & output)
114+ buildString ( " registrations: " , indent: indent, to: & output)
114115 } else {
115- print ( " registrations: none " , indent: indent, to: & output)
116+ buildString ( " registrations: none " , indent: indent, to: & output)
116117 }
117118
118119 for registration in registrations. sorted ( by: { $0. reuseIdentifier < $1. reuseIdentifier } ) {
119- print ( " - \( registration. reuseIdentifier) ( \( registration. viewType. kind) ) " , indent: indent + 2 , to: & output)
120+ buildString ( " - \( registration. reuseIdentifier) ( \( registration. viewType. kind) ) " , indent: indent + 2 , to: & output)
120121 }
121122
122123 case let . isEmpty( isEmpty) :
123- print ( " isEmpty: \( isEmpty) " , indent: indent, to: & output)
124+ buildString ( " isEmpty: \( isEmpty) " , indent: indent, to: & output)
124125
125126 case . end:
126- print ( " > " , indent: indent, to: & output)
127+ buildString ( " > " , indent: indent, to: & output)
127128 }
128129 }
129130}
130131
131132@MainActor
132- func debugDescription ( for collection: CollectionViewModel ) -> String {
133+ func collectionDebugDescription ( _ collection: CollectionViewModel ) -> String {
133134 var output = " "
134135 debugDescriptionBuilder (
135136 elements: [
@@ -138,15 +139,15 @@ func debugDescription(for collection: CollectionViewModel) -> String {
138139 ( . sections( collection. sections) , 2 ) ,
139140 ( . registrations( collection. allRegistrations ( ) ) , 2 ) ,
140141 ( . isEmpty( collection. isEmpty) , 2 ) ,
141- ( . end, 0 ) ,
142+ ( . end, 0 )
142143 ] ,
143144 to: & output
144145 )
145146 return output
146147}
147148
148149@MainActor
149- func debugDescription ( for section: SectionViewModel ) -> String {
150+ func sectionDebugDescription ( _ section: SectionViewModel ) -> String {
150151 var output = " "
151152 debugDescriptionBuilder (
152153 elements: [
@@ -158,7 +159,7 @@ func debugDescription(for section: SectionViewModel) -> String {
158159 ( . supplementaryViews( section. supplementaryViews) , 2 ) ,
159160 ( . registrations( section. allRegistrations ( ) ) , 2 ) ,
160161 ( . isEmpty( section. isEmpty) , 2 ) ,
161- ( . end, 0 ) ,
162+ ( . end, 0 )
162163 ] ,
163164 to: & output
164165 )
0 commit comments