@@ -88,6 +88,8 @@ public function process(File $phpcsFile, $stackPtr)
88
88
$ content = $ tokens [$ i ]['content ' ];
89
89
}
90
90
91
+ $ recordMetrics = true ;
92
+
91
93
// If this is an inline HTML token, split the content into
92
94
// indentation whitespace and the actual HTML/text.
93
95
$ nonWhitespace = '' ;
@@ -105,6 +107,9 @@ public function process(File $phpcsFile, $stackPtr)
105
107
// There is no content after this whitespace except for a newline.
106
108
$ content = rtrim ($ content , "\r\n" );
107
109
$ nonWhitespace = $ phpcsFile ->eolChar ;
110
+
111
+ // Don't record metrics for empty lines.
112
+ $ recordMetrics = false ;
108
113
}
109
114
110
115
$ hasSpaces = strpos ($ content , ' ' );
@@ -117,7 +122,10 @@ public function process(File $phpcsFile, $stackPtr)
117
122
118
123
if ($ hasSpaces === false && $ hasTabs !== false ) {
119
124
// 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
+
121
129
continue ;
122
130
}
123
131
@@ -136,7 +144,9 @@ public function process(File $phpcsFile, $stackPtr)
136
144
$ tabAfterSpaces = strpos ($ content , "\t" , $ hasSpaces );
137
145
138
146
if ($ hasTabs === false ) {
139
- $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'spaces ' );
147
+ if ($ recordMetrics === true ) {
148
+ $ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'spaces ' );
149
+ }
140
150
141
151
if ($ numTabs === 0 ) {
142
152
// Ignore: precision indentation.
@@ -145,14 +155,20 @@ public function process(File $phpcsFile, $stackPtr)
145
155
} else {
146
156
if ($ numTabs === 0 ) {
147
157
// 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
+ }
149
165
150
166
if ($ tabAfterSpaces === false ) {
151
167
// Ignore: precision indentation is already at the
152
168
// end of the whitespace.
153
169
continue ;
154
170
}
155
- } else {
171
+ } else if ( $ recordMetrics === true ) {
156
172
$ phpcsFile ->recordMetric ($ i , 'Line indent ' , 'mixed ' );
157
173
}
158
174
}//end if
0 commit comments