From 5cd080dfac8a2bcd726447a55b137c23c65d1c03 Mon Sep 17 00:00:00 2001 From: "Nicola Spanti (RyDroid)" Date: Fri, 24 Mar 2017 14:50:38 +0100 Subject: [PATCH 1/2] Add a specific message for stupid users that put useless spaces in license --- src/Composer/Util/ConfigValidator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index f36ff8e6f..667d2a681 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -84,10 +84,16 @@ class ConfigValidator } $licenseValidator = new SpdxLicenses(); - if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license'])) { + if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license']) && $licenseValidator->validate(trim($manifest['license']))) { + $warnings[] = sprintf( + 'Trim the license identifier (remove useless spaces, etc).', + json_encode($manifest['license']) + ); + } else if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license'])) { $warnings[] = sprintf( 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' - ."\nIf the software is closed-source, you may use \"proprietary\" as license.", + . PHP_EOL . + 'If the software is closed-source, you may use "proprietary" as license.', json_encode($manifest['license']) ); } From 0efc66d9686f1fae77e51ff93a23daeb3fc357e8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 26 Mar 2017 13:43:05 +0200 Subject: [PATCH 2/2] Tweak message --- src/Composer/Util/ConfigValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index 667d2a681..ecc035150 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -86,7 +86,7 @@ class ConfigValidator $licenseValidator = new SpdxLicenses(); if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license']) && $licenseValidator->validate(trim($manifest['license']))) { $warnings[] = sprintf( - 'Trim the license identifier (remove useless spaces, etc).', + 'License %s must not contain extra spaces, make sure to trim it.', json_encode($manifest['license']) ); } else if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license'])) {