@@ -88,6 +88,8 @@ public function process(File $phpcsFile, $stackPtr)
8888 $ content = $ tokens [$ i ]['content ' ];
8989 }
9090
91+ $ recordMetrics = true ;
92+
9193 // If this is an inline HTML token, split the content into
9294 // indentation whitespace and the actual HTML/text.
9395 $ nonWhitespace = '' ;
@@ -105,6 +107,9 @@ public function process(File $phpcsFile, $stackPtr)
105107 // There is no content after this whitespace except for a newline.
106108 $ content = rtrim ($ content , "\r\n" );
107109 $ nonWhitespace = $ phpcsFile ->eolChar ;
110+
111+ // Don't record metrics for empty lines.
112+ $ recordMetrics = false ;
108113 }
109114
110115 $ hasSpaces = strpos ($ content , ' ' );
@@ -117,7 +122,10 @@ public function process(File $phpcsFile, $stackPtr)
117122
118123 if ($ hasSpaces === false && $ hasTabs !== false ) {
119124 // All ok, nothing to do.
120- $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'tabs ' );
125+ if ($ recordMetrics === true ) {
126+ $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'tabs ' );
127+ }
128+
121129 continue ;
122130 }
123131
@@ -136,7 +144,9 @@ public function process(File $phpcsFile, $stackPtr)
136144 $ tabAfterSpaces = strpos ($ content , "\t" , $ hasSpaces );
137145
138146 if ($ hasTabs === false ) {
139- $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'spaces ' );
147+ if ($ recordMetrics === true ) {
148+ $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'spaces ' );
149+ }
140150
141151 if ($ numTabs === 0 ) {
142152 // Ignore: precision indentation.
@@ -145,14 +155,20 @@ public function process(File $phpcsFile, $stackPtr)
145155 } else {
146156 if ($ numTabs === 0 ) {
147157 // Precision indentation.
148- $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'tabs ' );
158+ if ($ recordMetrics === true ) {
159+ if ($ tabAfterSpaces !== false ) {
160+ $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'mixed ' );
161+ } else {
162+ $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'tabs ' );
163+ }
164+ }
149165
150166 if ($ tabAfterSpaces === false ) {
151167 // Ignore: precision indentation is already at the
152168 // end of the whitespace.
153169 continue ;
154170 }
155- } else {
171+ } else if ( $ recordMetrics === true ) {
156172 $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'mixed ' );
157173 }
158174 }//end if
0 commit comments