From 1646993195b2fcf1efdccfdcc437d7d808293528 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 27 May 2017 18:05:26 +0100 Subject: Add the limits in the validation output messages Resolves: https://github.com/hughsie/appstream-glib/issues/171 --- libappstream-glib/as-app-validate.c | 53 +++++++++++++++++++++---------------- libappstream-glib/as-self-test.c | 3 +++ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c index f70496d..a055752 100644 --- a/libappstream-glib/as-app-validate.c +++ b/libappstream-glib/as-app-validate.c @@ -184,12 +184,14 @@ as_app_validate_description_li (const gchar *text, AsAppValidateHelper *helper) if (str_len < length_li_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - "
  • is too short [%s]", text); + "
  • is too short [%s] minimum is %u chars", + text, length_li_min); } if (str_len > length_li_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - "
  • is too long [%s]", text); + "
  • is too long [%s] maximum is %u chars", + text, length_li_max); } if (ai_app_validate_fullstop_ending (text)) { ai_app_validate_add (helper, @@ -252,7 +254,8 @@ as_app_validate_description_para (const gchar *text, AsAppValidateHelper *helper if (str_len > length_para_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - "

    is too long [%s]", text); + "

    is too long [%s], maximum is %u chars", + text, length_para_max); } if (g_str_has_prefix (text, "This application")) { ai_app_validate_add (helper, @@ -530,26 +533,26 @@ ai_app_validate_image_check (AsImage *im, AsAppValidateHelper *helper) if (screenshot_width < ss_size_width_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_ATTRIBUTE_INVALID, - " width too small [%s]", - url); + " width too small [%s] minimum is %upx", + url, ss_size_width_min); } if (screenshot_height < ss_size_height_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_ATTRIBUTE_INVALID, - " height too small [%s]", - url); + " height too small [%s] minimum is %upx", + url, ss_size_height_min); } if (screenshot_width > ss_size_width_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_ATTRIBUTE_INVALID, - " width too large [%s]", - url); + " width too large [%s] maximum is %upx", + url, ss_size_width_max); } if (screenshot_height > ss_size_height_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_ATTRIBUTE_INVALID, - " height too large [%s]", - url); + " height too large [%s] maximum is %upx", + url, ss_size_height_max); } /* check padding */ @@ -778,12 +781,14 @@ as_app_validate_screenshots (AsApp *app, AsAppValidateHelper *helper) if (screenshots->len < number_screenshots_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - "Not enough tags"); + "Not enough tags, minimum is %u", + number_screenshots_min); } if (screenshots->len > number_screenshots_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - "Too many tags"); + "Too many tags, maximum is %u", + number_screenshots_max); } for (i = 0; i < screenshots->len; i++) { ss = g_ptr_array_index (screenshots, i); @@ -1472,12 +1477,14 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) if (str_len < length_name_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - " is too short [%s]", name); + " is too short [%s] minimum is %u chars", + name, length_name_min); } if (str_len > length_name_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - " is too long [%s]", name); + " is too long [%s] maximum is %u chars", + name, length_name_max); } if (ai_app_validate_fullstop_ending (name)) { ai_app_validate_add (helper, @@ -1511,14 +1518,14 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) if (str_len < length_summary_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - "

    is too short [%s]", - summary); + " is too short [%s] minimum is %u chars", + summary, length_summary_min); } if (str_len > length_summary_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - " is too long [%s]", - summary); + " is too long [%s] maximum is %u chars", + summary, length_summary_max); } if (ai_app_validate_fullstop_ending (summary)) { ai_app_validate_add (helper, @@ -1596,14 +1603,14 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) if (str_len < length_name_min) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - " is too short [%s]", - name); + " is too short [%s] minimum is %u chars", + name, length_name_min); } if (str_len > length_name_max) { ai_app_validate_add (helper, AS_PROBLEM_KIND_STYLE_INCORRECT, - " is too long [%s]", - name); + " is too long [%s] maximum is %u chars", + name, length_name_max); } if (as_app_validate_has_hyperlink (name)) { ai_app_validate_add (helper, diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 218f4b6..9783c73 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -1926,6 +1926,9 @@ as_test_app_validate_check (GPtrArray *array, continue; message_no_data = g_strdup (as_problem_get_message (problem)); tmp = g_strrstr (message_no_data, " ["); + if (tmp != NULL) + *tmp = '\0'; + tmp = g_strrstr (message_no_data, ", "); if (tmp != NULL) *tmp = '\0'; if (g_strcmp0 (message_no_data, message) == 0) -- cgit v1.2.1