DrupalCon New Orleans 2016
By Joseph D. Purcell
@josephdpurcell

Questions, comments, concerns, objections,
are all welcome!
Anything you know without executing code.
i.e. code smells...
If it stinks, change it.
- Grandma Beck, "Refactoring"
An open source static analysis platform.
Find problems before you merge code.
Source: github.com/18F/micropurchase/pull/524
Source: github.com/18F/micropurchase/pull/466
Source: codeclimate.com/github/18F/micropurchase/pull/466
Search for existing problems.
function wp_ajax_delete_tag() {
$tag_id = (int) $_POST['tag_ID'];
check_ajax_referer( "delete-tag_$tag_id" );
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
...
Source: codeclimate.com/repos/5730fdf0d132d84858004be5/issues?category=security...
protected function doLoadMultiple(array $names, $immutable = TRUE) {
...
if (isset($GLOBALS['config'][$name])) {
$this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]);
...
Source: codeclimate.com/repos/5730f2e8d132d85e94000b46/issues?category=security...
Source: codeclimate.com/repos...core/lib/Drupal/Core/Field/WidgetBase.php
Source: codeclimate.com...multiversion/src/Entity/Index/MultiversionIndexFactory.php
function hook_tokens_alter(array &$replacements, array $context, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
$options = $context['options'];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
}
else {
$langcode = NULL;
}
if ($context['type'] == 'node' && !empty($context['data']['node'])) {
$node = $context['data']['node'];
if (isset($context['tokens']['title'])) {
$title = $node->field_title->view('default');
$replacements[$context['tokens']['title']] = drupal_render($title);
}
}
}
Source: codeclimate.com/repos...core/lib/Drupal/Core/Utility/token.api.php
Source: codeclimate.com/repos...core/lib/Drupal/Core/Entity/EntityType.php#complexity
Inspect quality of code before using it.
Source: github.com/josephdpurcell/code-climate-and-drupal
Questions, comments, concerns, objections,
are all welcome!