Skip to content
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

Test files mess with code completition #636

Closed
2 tasks done
mabar opened this issue Oct 19, 2024 · 1 comment
Closed
2 tasks done

Test files mess with code completition #636

mabar opened this issue Oct 19, 2024 · 1 comment

Comments

@mabar
Copy link

mabar commented Oct 19, 2024

Is your feature request related to a problem?

Codesniffer tests have a lot of definitions that match common keywords and it messes up code completition (in PHPStorm):

  • names of test functions like func, true, false and null show up along with coresponding PHP keywords/constants/etc., sometimes even before them
  • in code in global scope variable types get combined (e.g. inside conditions) for variables with the same name (e.g. $container) even when proper phpdoc is defined in the file. In case of the DI container, we have defined method get() with generic return type which does not work (it is random, can't reliably replicate) because of the combined type and the PSR container (used in tests) having method with the same name.

When working with tens of packages, including third-party, working around the problem gets quite annoying. I am currently using drupal/core-vendor-hardening package to remove the test directories, with following config:

	"extra": {
		"drupal-core-vendor-hardening": {
			"squizlabs/php_codesniffer": [
				"tests",
				"src/Standards/Generic/Tests",
				"src/Standards/MySource/Tests",
				"src/Standards/PEAR/Tests",
				"src/Standards/PSR1/Tests",
				"src/Standards/PSR2/Tests",
				"src/Standards/PSR12/Tests",
				"src/Standards/Squiz/Tests",
				"src/Standards/Zend/Tests",
				"src/Standards/Generic/Tests",
				"src/Standards/Generic/Tests"
			]
		}
	},

Describe the solution you'd like

  • remove tests from released package
  • or move them into a single tests directory so they are easier to remove via Composer plugin

Additional context

image
image

@jrfnl
Copy link
Member

jrfnl commented Oct 19, 2024

@mabar This is a known issue and will be fixed in the 4.0 release.

See squizlabs/PHP_CodeSniffer#1908 and squizlabs/PHP_CodeSniffer#548 for historical context and the reasoning for the decision to change this in the 4.0 release (and not before).

@jrfnl jrfnl closed this as completed Oct 19, 2024
@jrfnl jrfnl added this to the 4.0.0 milestone Oct 19, 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

2 participants