Attached is a patch to standardize the json output for the Audit Status 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
FluxSauce’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
102.72 KB

Hi Lisa,

Thanks for the patch! However, it's not working out of the box.

jon@Decker ~/projects/drupal-7.37 $ drush as --json
PHP Fatal error:  Call to undefined function striptags() in /Users/jon/projects/site_audit/Check/Status/System.php on line 88

Fatal error: Call to undefined function striptags() in /Users/jon/projects/site_audit/Check/Status/System.php on line 88
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                             [error]
Error: Call to undefined function striptags() in /Users/jon/projects/site_audit/Check/Status/System.php, line 88

Additionally, the changes do not pass Drupal Coding standards:

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/Status/System.php
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
 86 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
 87 | ERROR | Expected "foreach (...) {\n"; found "foreach(...) {\n"
--------------------------------------------------------------------------------
UPGRADE TO PHP_CODESNIFFER 2.0 TO FIX ERRORS AUTOMATICALLY
--------------------------------------------------------------------------------

Taking a step back, let's look at what's happening semantically. I fixed the syntax errors for the purposes of demonstration.

This is a much better structure, and it contains the same data as before. Other groups, such as Pantheon, currently use the JSON format, so I'm going to have to initiate some change management and notifications so upgrades don't break everything.

Please resolve the syntax and formatting errors, and I'll get this in!

Thanks,
Jon

FluxSauce’s picture

Also, you can simplify:

      $ret_val = array();
      foreach ($items as $item) {
        $ret_val[] = array(
          'Title' => $item['title'],
          'Severity' => $item['severity'],
          'Value' => $item['value'],
        );
      }
gaurav.goyal’s picture

Assigned: lhridley » gaurav.goyal
Status: Needs work » Needs review
FileSize
1.63 KB

Changes made as per the comments. Patch is attached.

  • FluxSauce committed 0a981b2 on 7.x-1.x authored by gaurav.goyal
    Issue #2496899 by lhridley, gaurav.goyal: Standardize Results Rendering...
  • FluxSauce committed 7524f09 on 7.x-1.x
    Issue #2496899: Standardizing and simplifying.
    
FluxSauce’s picture

Assigned: gaurav.goyal » FluxSauce
Status: Needs review » Fixed

Thanks for the cleanup, Gaurav! I've made a small tweak as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.