Skip to content

Test files mess with code completition #636

Closed
@mabar

Description

@mabar

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions