Attached is a patch to standardize the json output for the Audit Extensions option. This patch converts the text/markup rendered currently with the --json option for both the summary and the detail (--detail) reports.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lhridley’s picture

lhridley’s picture

Status: Active » Needs review
lhridley’s picture

FluxSauce’s picture

Status: Needs review » Needs work

Thanks for the patch!

jon@Decker ~/projects/drupal-7.37 $ phpcs --standard=sites/all/modules/coder/coder_sniffer/Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt' ~/projects/site_audit/Check/

FILE: /Users/jon/projects/site_audit/Check/Extensions/Count.php
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
 79 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
 81 | ERROR | else must start on a new line
--------------------------------------------------------------------------------
UPGRADE TO PHP_CODESNIFFER 2.0 TO FIX ERRORS AUTOMATICALLY
--------------------------------------------------------------------------------

Also, I've done some restructuring and cleanup, the patch isn't applying cleanly anymore. Sorry about that, but some of that was to address things you changed, like removing the color text ("a clean site is a happy site").

      elseif (drush_get_option('json')) {
        $registryinfo = array();
        $extensioninfo = array();
        foreach ($this->registry['extensions_unrec'] as $row) {
          $extensioninfo[] = array(
            'Name' => $row[0],
            'Reason' => $row[1],
          );
        }
        $registryinfo[] = array(
          'Unrecommended Extensions' => $extensioninfo,
        );
        $ret_val = $registryinfo;
      }

You can be much more concise.

      elseif (drush_get_option('json')) {
        $ret_val = array();
        foreach ($this->registry['extensions_unrec'] as $row) {
          $ret_val[] = array(
            'Name' => $row[0],
            'Reason' => $row[1],
          );
        }
      }

Same goes for duplicate, development, and count (which is even simpler, $ret_val = $options;)

lhridley’s picture

I'm going to resubmit with much more extensive refactoring shortly, which will move the output preparation out of the "checks" class and into the "reports" class, which will make it easier to extend and modify the output with a plugin.

FluxSauce’s picture

Incremental, not monolithic improvements are preferred at this stage. It's a lot easier to review and test. Let's get this smaller work done cleanly first!