Skip to content

Commit 38b6211

Browse files
authored
Merge pull request #1842 from WordPress/feature/commaafterarrayitem-add-metrics
CommaAfterArrayItem: add metrics for comma after last item
2 parents 370ae76 + 35fd3b6 commit 38b6211

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public function process_token( $stackPtr ) {
103103
*/
104104
if ( true === $single_line && $item_index === $array_item_count ) {
105105

106+
$this->phpcsFile->recordMetric(
107+
$stackPtr,
108+
'Single line array - comma after last item',
109+
( true === $is_comma ? 'yes' : 'no' )
110+
);
111+
106112
if ( true === $is_comma ) {
107113
$fix = $this->phpcsFile->addFixableError(
108114
'Comma not allowed after last value in single-line array declaration',
@@ -153,6 +159,14 @@ public function process_token( $stackPtr ) {
153159
}
154160
}
155161

162+
if ( false === $single_line && $item_index === $array_item_count ) {
163+
$this->phpcsFile->recordMetric(
164+
$stackPtr,
165+
'Multi-line array - comma after last item',
166+
( true === $is_comma ? 'yes' : 'no' )
167+
);
168+
}
169+
156170
if ( false === $is_comma ) {
157171
// Can't check spacing around the comma if there is no comma.
158172
continue;

0 commit comments

Comments
 (0)