Quality https://keopx.net/ es Coder Sniffer for Drupal Coding Standards https://keopx.net/blog/coder-sniffer-drupal-coding-standards <span>Coder Sniffer for Drupal Coding Standards</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Install Coder with composer:</p> <pre> <code class="language-bash">composer global require drupal/coder</code></pre><p><strong>Custom setup using for Drupal Coding Standards.</strong></p> <p>Add symbolic path to support <em>Drupal</em> and <em>DrupalPractice</em> Standard:</p> <pre> <code class="language-bash">$ ln -s ~/.composer/vendor/drupal/coder/coder_sniffer/Drupal ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Drupal $ ln -s ~/.composer/vendor/drupal/coder/coder_sniffer/DrupalPractice ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/DrupalPractice</code></pre><p>If you're using <em>bash</em>, edit <em>$HOME/.bashrc</em> (or <em>$HOME/.bash_profile</em>).</p> <pre> <code class="language-bash">alias drupalcs="~/.composer/vendor/bin/phpcs --colors --standard=~/.composer/vendor/drupal/coder/coder_sniffer/Drupal --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt,md"</code></pre><p>Or if you added symbolic links:</p> <pre> <code class="language-bash">alias drupalcs="~/.composer/vendor/bin/phpcs --colors --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt,md"</code></pre><pre> <code class="language-bash">source .bashrc</code></pre><p>Execution example:</p> <pre> <code class="language-bash">$ drupalcs modules/custom/custom_crm FILE: ...ww/docroot/modules/custom/custom_crm/src/CrmConfigUri.php ---------------------------------------------------------------------- FOUND 3 ERRORS AFFECTING 3 LINES ---------------------------------------------------------------------- 3 | ERROR | [x] There must be one blank line after the namespace | | declaration 6 | ERROR | [x] Missing class doc comment 28 | ERROR | [x] Expected 1 newline at end of file; 0 found ---------------------------------------------------------------------- PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- Time: 157ms; Memory: 7.75Mb </code></pre><p>References:</p> <ul><li><a href="https://www.drupal.org/project/coder">Coder</a></li> <li><a href="https://www.drupal.org/node/1419988">Installing Coder Sniffer</a></li> <li><a href="https://www.drupal.org/node/1587138">Command Line Usage</a></li> </ul></div> <span><span>keopx</span></span> <span><time datetime="2016-07-16T11:38:42+02:00" title="Sábado, Julio 16, 2016 - 11:38">Sáb, 16/07/2016 - 11:38</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/drupal" hreflang="es">Drupal</a></div> <div class="field__item"><a href="/categoria/drupal-8x" hreflang="es">Drupal 8.x</a></div> <div class="field__item"><a href="/categoria/drupal-7x" hreflang="es">Drupal 7.x</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/drupal-7x" hreflang="es">Drupal 7.x</a></div> <div class="field__item"><a href="/tag/drupal-8x" hreflang="es">Drupal 8.x</a></div> <div class="field__item"><a href="/tag/quality" hreflang="es">Quality</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=266&amp;2=field_comments&amp;3=comment" token="gqLjaRVS46gQeekKVb4H5xj9BaiDawhrBhoEKGIhT7s"></drupal-render-placeholder> </div> </div> </section> Sat, 16 Jul 2016 09:38:42 +0000 keopx 266 at https://keopx.net https://keopx.net/blog/coder-sniffer-drupal-coding-standards#comments