<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[6711] sites/trunk/wordcamp.org: WordCamp PHPMD: Add initial configuration.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/6711">6711</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/6711","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>iandunn</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-02-21 21:15:23 +0000 (Wed, 21 Feb 2018)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp PHPMD: Add initial configuration.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgphpcsxmldist">sites/trunk/wordcamp.org/phpcs.xml.dist</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgphpmdxmldist">sites/trunk/wordcamp.org/phpmd.xml.dist</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgphpcsxmldist"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/phpcs.xml.dist</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/phpcs.xml.dist   2018-02-21 20:19:46 UTC (rev 6710)
+++ sites/trunk/wordcamp.org/phpcs.xml.dist     2018-02-21 21:15:23 UTC (rev 6711)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?xml version="1.0" ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <ruleset name="WordCamp.org Coding Standards">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <description>Apply customized version of WordPress Coding Standards to WordCamp.org PHP scripts</description>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <description>Apply customized version of WordPress Coding Standards to WordCamp.org PHP scripts.</description>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <!--
</span><span class="cx" style="display: block; padding: 0 10px">                Setup instructions:
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,6 +30,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                <exclude-pattern>/build/*</exclude-pattern>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                Look through `General` and `Squiz` sniffs for anything you might want to add.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        Is there one that detects `\Foo` instead of `use Foo`?
+                       maximum nesting level?
+                       function length?
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                Maybe add WordCamp\Remote_CSS\output_cached_css to customEscapingFunctions or whichever param is most appropriate
</span><span class="cx" style="display: block; padding: 0 10px">                Maybe do something similar for set_cache_headers and nonce verification
</span></span></pre></div>
<a id="sitestrunkwordcamporgphpmdxmldist"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/phpmd.xml.dist</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/phpmd.xml.dist                           (rev 0)
+++ sites/trunk/wordcamp.org/phpmd.xml.dist     2018-02-21 21:15:23 UTC (rev 6711)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,108 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?xml version="1.0" ?>
+<ruleset name="WordCamp.org Code Quality Standards"
+                xmlns="http://pmd.sf.net/ruleset/1.0.0"
+                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+                xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+       <description>Analyze WordCamp.org PHP scripts for code quality issues.</description>
+
+       <!--
+               The "rules" here should be considered rough guidelines rather than hard rules. PHPMD is naturally not as
+               accurate or clear as PHPCS, so developers need to use their judgement more. It's normal and expected to get
+               warnings about things that are ok in reality. So, if this warns you about something, then take that into
+               consideration, but use your judgement, and feel free to ignore it if you feel like it's unwarranted.
+               The Code Size rules are some of the most important ones to pay attention to, because they're good indicators
+               that a function needs to be modularized. Even they are hard to tune for a good signal/noise ratio, though.
+
+               Setup instructions:
+
+               1) Install PHPMD (e.g., `brew install homebrew/php/phpmd`)
+               2) Make sure this file is at the project root. You can symlink it there if your `meta.(git|svn).wordpress.org`
+                  checkout is elsewhere.
+               3) Run `phpmd {folder/file to scan} text path/to/phpmd.xml.dist`. If you'd like, you can set up a convenience wrapper
+                  so that you just have to type `phpmd {folder/file to scan}. Example: https://github.com/iandunn/dotfiles/commit/5b20c05
+               4) Run it before you generate a patch or create a commit. Setting up a git pre-commit or pre-push hook can
+                  make that automatic.
+
+               Note: It's possible to create a `phpmd.xml` file if you want to override anything here, but please don't abuse
+               that, since code that you contribute affects other developers. If you think any of the rules here should
+               change, start a discussion in #meta-wordcamp.
+
+               See https://phpmd.org/rules/index.html for details on the rules and configuration parameters.
+
+               Note: To customize a rule's properties, you have to exclude it from its ruleset, and then include it with a
+               custom property list. See `rulesets/naming.xml/ShortVariable` below for an example.
+       -->
+
+
+       <rule ref="rulesets/cleancode.xml">
+               <!-- We're currently excluding all the individual rules here, but we want this ruleset in principal, so let's
+                        leave it included and evaluate any new rules that are added to it. -->
+
+               <!-- This is not a reliable indicator of violating SRP in a meaningful way, and our typical usage of it is fine. -->
+               <exclude name="BooleanArgumentFlag" />
+
+               <!-- Returning early is more readable, but can make a function harder to maintain. A single point of
+                    return is sometimes best. See https://tommcfarlin.com/wordpress-refactoring-plugin-functions/#comment-40498
+                    and the following comments. Often it's best to return early and late, but not in the middle of a
+                    function. -->
+               <exclude name="ElseExpression" />
+
+               <!-- This is too strict for us right now. -->
+               <exclude name="StaticAccess" />
+       </rule>
+
+       <rule ref="rulesets/codesize.xml">
+               <!-- Include later with custom values -->
+               <exclude name="ExcessiveMethodLength" />
+               <exclude name="CyclomaticComplexity"  />
+       </rule>
+
+       <rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
+               <properties>
+                       <property name="minimum" value="70" />
+               </properties>
+       </rule>
+
+       <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
+               <properties>
+                       <!-- This value is particularly difficult to tune for a good signal/noise ratio, but let's try it this
+                            low for awhile and only bump it if we really need to, because keeping CC low makes a big difference
+                            when it comes to maintainability, reliability, and testability. -->
+                       <property name="reportLevel" value="8" />
+               </properties>
+       </rule>
+
+       <!-- `rulesets/controversial.xml` is a non-starter, because camelCase is inconsistent with the WP Coding Standards,
+            and requiring a framework to access superglobals overkill. -->
+
+       <rule ref="rulesets/design.xml">
+               <!-- There are proper cases for this, like exit()'ing after a redirect -->
+               <exclude name="ExitExpression" />
+       </rule>
+
+       <rule ref="rulesets/naming.xml">
+               <!-- Include later with custom values -->
+               <exclude name="ShortVariable" />
+
+               <!-- Variable names should be descriptive and self-documenting -->
+               <exclude name="LongVariable" />
+       </rule>
+
+    <rule ref="rulesets/naming.xml/ShortVariable">
+        <properties>
+            <!-- $a and $b are conventionally used in usort() callbacks. $to is perfectly descriptive with `wp_mail()`. -->
+            <property name="exceptions" value="a,b,to" />
+        </properties>
+    </rule>
+
+       <rule ref="rulesets/unusedcode.xml">
+               <!-- It's nice to know what variables are passed from WP hooks, even if we're not using them right now.
+                    Also, PHP doesn't support named parameters, so sometimes it's unavoidable  -->
+               <exclude name="UnusedFormalParameter" />
+
+               <!-- Too many false positives when a controller function creates a variable, and then includes a view file
+                        which uses the variable -->
+               <exclude name="UnusedLocalVariable" />
+       </rule>
+</ruleset>
</ins></span></pre>
</div>
</div>

</body>
</html>