Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task
jrfnl opened this issue Jan 27, 2024 · 1 comment
Open
1 task

Comments

@jrfnl
Copy link
Member

jrfnl commented Jan 27, 2024

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.
@jrfnl
Copy link
Member Author

jrfnl commented Jan 27, 2024

For now, I've made an edit to the wiki information about the Performance report to mention that it should not be run with the cached turned on.

@jrfnl jrfnl changed the title Config: automatically turn result caching off when Performance report is used Automatically turn result caching off when Performance report is used Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant