Skip to content

New Feature: only load sniffs containing fixers when PHPCBF is run #165

Open
@jrfnl

Description

@jrfnl

Is your feature request related to a problem?

Some standards, like, for instance, PHPCompatibility contain a lot of sniff (150+), but barely any fixers. Another example is the VariableAnalysis standard, which only contains one non-fixable sniff, but has to do a lot of work for that one sniff, which makes it a slow sniff.

As things are, when running phpcbf all sniffs are loaded, whether they contain fixers or not. This also means that all sniffs are run in all fixer loops as PHPCS will only know about fixable errors/warnings once the sniff triggers an error/warning.

All in all, this can make PHPCBF much slower than is needed when a ruleset contains a lot of non-fixable sniffs.

Describe the solution you'd like

A preliminary idea is to have a FixableSniff and a NonFixableSniff interface.

When running phpcbf PHPCS could then decide when reading the ruleset and loading the sniffs whether sniffs should actually be run, which could lead to a significant performance boost in cases when the ruleset contains quite some sniffs not containing fixers.

Opinions ? Other ideas to tackle this ?

/cc @kukulich @wimg @GaryJones @dingo-d @fredden @michalbundyra @stronk7

Additional context (optional)

If there is interest in this idea, I'd be looking to introduce this feature in the 4.0 release.

The Sniff interface would then be (soft) deprecated in 4.0, to be removed in 5.0, which should give standard maintainers time to switch over to the new interfaces.

If when running on 4.x, the Sniff interface is still used, it would be treated as if it were the FixableSniff interface and the sniff would still run in phpcbf mode.

  • I intend to create a pull request to implement this feature.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions