Skip to content

Automatically turn result caching off when Performance report is used #306

Open
@jrfnl

Description

@jrfnl

Is your feature request related to a problem?

PR #60 introduced a new Performance report to measure sniff performance during a scan.

This new report will never give reliable/accurate results if the scan is run with caching turned on as the caching feature will lead to unchanged files being skipped in the scan in favour of re-using the cached results.

Describe the solution you'd like

The cache feature should automatically be turned off when the Performance report is requested (or is one of the requested reports).

Additional context (optional)

I've had a quick look at turning caching off automatically when the Performance report is requested, but this is not as straight-forward as it sounds as it is not clear-cut where the change should be made/how it should be implemented.

There are a number of things to take into account:

  • Config::$overriddenDefaults should still be accurate.
  • CLI arguments can be passed in any order from the command-line, which means that a check would be needed both when setting the cache option, as well as when setting the reports option in Config::processLongArgument(). Or a separate check would need to be done at the end of the method Config::setCommandLineValues() to rectify.
  • CLI arguments can be passed from a custom ruleset, but in that case, the Config::setConfigData() method is used.
  • The Config class uses magic methods which include some logic, which could possible be used for this change, however, those methods can be bypassed via the Config::setSettings() method, which could lead to the Config::$overriddenDefaults no longer being accurate (potential issue anyway, independently of the change proposed here)
  • Outside of the Config class, it could be an option to make the change in the Runner class instead. This would likely make it more reliable, but would be a hard-overrule.
  • The change would likely be untestable as the cache feature is prevented from being turn on when the PHP_CODESNIFFER_IN_TESTS constant is defined.
  • I intend to create a pull request to implement this feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions