Validation warns if script description for nonexistent script is present

Fixes #7010
main
Martin Hujer 7 years ago
parent 015927d0b0
commit bbee0d7c6c

@ -118,6 +118,18 @@ class ConfigValidator
}
}
// report scripts-descriptions for non-existent scripts
$scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
$scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
if (!array_key_exists($scriptName, $scripts)) {
$warnings[] = sprintf(
'Description for non-existent script "%s" found in "scripts-descriptions"',
$scriptName
);
}
}
// check for empty psr-0/psr-4 namespace prefixes
if (isset($manifest['autoload']['psr-0'][''])) {
$warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";

@ -34,4 +34,15 @@ class ConfigValidatorTest extends TestCase
$warnings
);
}
public function testConfigValidatorWarnsOnScriptDescriptionForNonexistentScript()
{
$configValidator = new ConfigValidator(new NullIO());
list(, , $warnings) = $configValidator->validate(__DIR__ . '/Fixtures/composer_scripts-descriptions.json');
$this->assertContains(
'Description for non-existent script "phpcsxxx" found in "scripts-descriptions"',
$warnings
);
}
}

@ -0,0 +1,10 @@
{
"scripts": {
"test": "phpunit",
"phpcs": "phpcs --standard=PSR2 src"
},
"scripts-descriptions": {
"test": "Launches the preconfigured PHPUnit",
"phpcsxxx": "Checks that the application code conforms to coding standard"
}
}
Loading…
Cancel
Save