WordPress / WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
MIT License
2.56k stars 485 forks source link

Add a sniff to detect git merge conflict resolution text #1432

Closed tomjn closed 6 years ago

tomjn commented 6 years ago

There's a pending PR by @david-binda for the VIP standards at https://github.com/Automattic/VIP-Coding-Standards/pull/126 that tries to detect conflict resolution text in files, e.g.

<?php
function is_prime( $n ) {
<<<<<<< HEAD
    if ( 2 === $n  ) {
        return true;
    }
=======
    if ( $n % 2 === 0 ) {
        return false;
    }
>>>>>>> branch-a
}

It might be worth merging into WPCS rather than VIPCS given its platform agnostic nature.

If the PR is good as is I can adjust the namespaces etc and create a PR to put the sniff in the WordPress ruleset, perhaps under WhiteSpace?

grappler commented 6 years ago

This might be even useful further upstream.

jrfnl commented 6 years ago

There is already a PR (by me) open for a sniff to do just this in PHPCS upstream: https://github.com/squizlabs/PHP_CodeSniffer/pull/1724

jrfnl commented 6 years ago

FYI: The upstream PR has been merged. Also see #1500.