Problem/Motivation

After running the tool and looking at the reports, the output of the report does not easily copy and paste into a ticket.

Proposed resolution

Update the output of the reports to be more like the phpcs output, so it can easily be copied and shared from the upgrade status report into other tools / ticketing systems.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikemadison created an issue. See original summary.

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

Can you paste a sample report format you would be looking to have?

mikemadison’s picture

Ideally it would do something like https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting (see below) as opposed to the tabular format that it's currently reporting out in. To be clear, this would be on the report page for the individual module, not necessarily on the overall upgrade status page that shows how many issues there are.

Sidenote, is there a plan to provide a drush interface to the module so that the upgrade status can be run from the terminal? Because ideally it would be the same output in both places!

$ phpcs -s /path/to/code/myfile.php

FILE: /path/to/code/classA.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
--------------------------------------------------------------------------------
  2 | ERROR   | [ ] Missing file doc comment
    |         |     (PEAR.Commenting.FileComment.Missing)
  4 | ERROR   | [x] TRUE, FALSE and NULL must be lowercase; expected "false" but
    |         |     found "FALSE" (Generic.PHP.LowerCaseConstant.Found)
  6 | ERROR   | [x] Line indented incorrectly; expected at least 4 spaces, found
    |         |     1 (PEAR.WhiteSpace.ScopeIndent.Incorrect)
  9 | ERROR   | [ ] Missing function doc comment
    |         |     (PEAR.Commenting.FunctionComment.Missing)
 11 | WARNING | [x] Inline control structures are discouraged
    |         |     (Generic.ControlStructures.InlineControlStructure.Discouraged)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

$ phpcs -s --report=summary /path/to/code

PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE                                                            ERRORS  WARNINGS
--------------------------------------------------------------------------------
/path/to/code/classA.inc                                        5       0
/path/to/code/classB.inc                                        1       1
/path/to/code/classC.inc                                        0       2
--------------------------------------------------------------------------------
A TOTAL OF 6 ERROR(S) AND 3 WARNING(S) WERE FOUND IN 3 FILE(S)
--------------------------------------------------------------------------------
Gábor Hojtsy’s picture

The module is a UI on top of https://github.com/mglaman/drupal-check, which has this exact output by default you are requesting. If you are interested primarily in a CLI interface and that output, then you probably don't need the module :)

Gábor Hojtsy’s picture

Status: Postponed (maintainer needs more info) » Active

That said if this is superior to the HTML output and we can assume that everyone using the module wants this ASCII limited output for single and full site exports, then we should change our HTML output to be this instead. We can at least do away with our duplicated CSS in the single and full output templates (and even the templates themselves really).

Gábor Hojtsy’s picture

Title: Improve Report Output » Change export output to ASCII

Changed title based on suggested change.

webchick’s picture

The main reason we went with HTML exports is that there are links in the generated text, and that makes them easy to click directly from the web interface. I don't have any problem with an HTML/ASCII selector, but I think making them only ASCII makes the output less usable, as you now need to select + copy + paste to get the same info.

mikemadison’s picture

the links definitely helped in researching the problems, i did like that. i'm not sure if there's a way to do both?

herczogzoltan’s picture

If there's a need to add another export format, we can modify the current occurrence of the export to mention the format as well (something like "Export HTML" ?). We can also extend the operations for each project row with an extra link which will do the export in the desirable easy to copy format (something like "Export ASCII" ?) and place an extra button on the project report modal popup with the same title. Also modifications needed in constructing the current report, maybe adding a way to select the formatting mode. For example "formatted" and "plain", but we can think it through to make it a bit more extendable, in case somebody will need another format besides HTML or ASCII.
What do you think about the above? The button titles and changes on the report constructor are just suggestions.

Gábor Hojtsy’s picture

If the links are all we care about for HTML then we can output in a HTML page in <pre> or <code> and still inline the links as HTML. Then you can copy paste it (loosing the links) or use it as HTML (click links). I am not fond of adding a lot more UI weight for various more output formats if we can get the best of both worlds.

I understand the copy-pasting for custom projects (to your own internal issue tracker), but for contrib modules, an issue could very well already exist, you may not be running the latest version, stuff may be fixed in dev, etc. So searching the queue first and figuring out how to engage with the maintainer is better. We do have plans to guide users of this module in that interaction. See #3053948: Guide users on how to best engage with a contrib project maintainer.

Gábor Hojtsy’s picture

Title: Change export output to ASCII » Add an ASCII export option or change export to fixed width ASCII with links intact
tsega’s picture

@gábor here is what I have so far on the ASCII export option. I feel there are two things left to make this a complete feature;

  1. Export a .txt file instead of HTML file: I'm still using a twig template file to generate the export. I think we said a simple .txt file would be the right file format here.
  2. Issue with links: They are there, but they are not particularly useful as it is difficult to copy paste URL that span multiple lines. See example screenshot.

Upgrade Status ASCII Export URL copy issue

rpsu’s picture

FileSize
14.07 KB

The patch seems to have been done reversibly (wrong direction, thus no diff here). Attached patch fixes that, and adds dynamic export file extension.

Removed phpstan/phpstan version downgrade (mistake assumed), and html tags from the ascii export file twig template - seems to be cleaner this way.

  • Gábor Hojtsy committed cc33d75 on 8.x-1.x
    Issue #3053090 by tsega: Add new dependency to make exporting in ASCII...
Gábor Hojtsy’s picture

Status: Active » Needs review

I don't have enough composer fu (or time ATM) to figure out how to make a locally updated composer.json function when composer attempts to update the project either way. So I committed just the dependency update as a start to make it easier to test the rest.

Gábor Hojtsy’s picture

@rpsu: you forgot to attach the twig file.

Gábor Hojtsy’s picture

FileSize
17.4 KB

- Restored the twig ASCII template.
- Refactored the form integration a bit.
- Added security filtering to the single export format argument.
- Simplified the ASCII output format, more whitespace less lines.

Still definitely needs work in terms of the table structure and how the ASCII itself gets generated, because it has some duplicate code still.

Status: Needs review » Needs work

The last submitted patch, 17: 3053090-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
17.42 KB

Removed link generation from ASCII tables, I think its distracting.
Fixed test text looking for export button labels, so those should pass again.
Moved to per file tables instead of one table per project, this makes results a LOT more readable, like this:

--------------------------------------------------------------------------------
Upgrade Status 8.x-1.0-beta2+3-dev
Scanned on Thu, 08/08/2019 - 11:17.

2 errors found. 3 warnings found. Items categorized "Fix now" are uses of
deprecated APIs from community unsupported core versions.

See #3056118: Keep Upgrade Status itself Drupal 9 compatible other than testing
code

modules/contrib/upgrade_status/src/DeprecationAnalyser.php:
┌────────┬──────┬────────────────────────────────────────────────────────────┐
│ STATUS │ LINE │                          MESSAGE                           │
├────────┼──────┼────────────────────────────────────────────────────────────┤
│ Fix    │ 366  │ Call to deprecated function file_prepare_directory().      │
│ later  │      │ Deprecated in Drupal 8.7.0, will be removed before Drupal  │
│        │      │ 9.0.0. Use                                                 │
│        │      │ \Drupal\Core\File\FileSystemInterface::prepareDirectory(). │
│        │      │                                                            │
│ Fix    │ 374  │ Call to deprecated function file_prepare_directory().      │
│ later  │      │ Deprecated in Drupal 8.7.0, will be removed before Drupal  │
│        │      │ 9.0.0. Use                                                 │
│        │      │ \Drupal\Core\File\FileSystemInterface::prepareDirectory(). │
│        │      │                                                            │
└────────┴──────┴────────────────────────────────────────────────────────────┘

modules/contrib/upgrade_status/tests/modules/upgrade_status_test_contrib_error/s
rc/Controller/UpgradeStatusTestContribErrorController.php:
┌─────────┬──────┬────────────────────────────────────────────────────────────┐
│ STATUS  │ LINE │                          MESSAGE                           │
├─────────┼──────┼────────────────────────────────────────────────────────────┤
│ Fix now │ 15   │ Call to deprecated function format_string(). Deprecated in │
│         │      │ Drupal 8.0.0, will be removed before Drupal 9.0.0. Use     │
│         │      │ \Drupal\Component\Render\FormattableMarkup.                │
│         │      │                                                            │
└─────────┴──────┴────────────────────────────────────────────────────────────┘

modules/contrib/upgrade_status/tests/modules/upgrade_status_test_error/fatal.php:
┌──────────┬──────┬─────────────────────────────────────────────┐
│  STATUS  │ LINE │                   MESSAGE                   │
├──────────┼──────┼─────────────────────────────────────────────┤
│ Check    │ 3    │ Syntax error, unexpected T_STRING on line 3 │
│ manually │      │                                             │
└──────────┴──────┴─────────────────────────────────────────────┘

modules/contrib/upgrade_status/tests/modules/upgrade_status_test_error/src/Contr
oller/UpgradeStatusTestErrorController.php:
┌─────────┬──────┬─────────────────────────────────────────────────────────────┐
│ STATUS  │ LINE │                           MESSAGE                           │
├─────────┼──────┼─────────────────────────────────────────────────────────────┤
│ Fix now │ 10   │ Call to deprecated function menu_cache_clear_all().         │
│         │      │ Deprecated in Drupal 8.6.0, will be removed before Drupal   │
│         │      │ 9.0.0. Use \Drupal::cache('menu')->invalidateAll() instead. │
│         │      │                                                             │
└─────────┴──────┴─────────────────────────────────────────────────────────────┘

I tried making tables fixed width but the library did not allow to do so. Although given how much we are doing ourselves now, not sure how much is left for the library to do really. Anyway, keeping that for now.

Status: Needs review » Needs work

The last submitted patch, 19: 3053090-19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
20.13 KB

Fix the custom/contrib project labels.

Gábor Hojtsy’s picture

FileSize
21.34 KB

Add its own test coverage.

Gábor Hojtsy’s picture

Title: Add an ASCII export option or change export to fixed width ASCII with links intact » Add an ASCII export option

  • Gábor Hojtsy committed 6b1f253 on 8.x-1.x
    Issue #3053090 by tsega, Gábor Hojtsy, rpsu: Add an ASCII export option
    
Gábor Hojtsy’s picture

Status: Needs review » Fixed

All right, put this in, thanks both for your help :)

Status: Fixed » Closed (fixed)

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