Commit f430bd28 authored by Matthias Klumpp's avatar Matthias Klumpp
Browse files

validator: Add methods to query tag severity/explanation explicitly

This can be useful if you only know the tag, but want its
explanation/severity without actually having the AsValidatorIssue.
parent 5ba24bc7
......@@ -2257,6 +2257,42 @@ as_validator_get_report_yaml (AsValidator *validator)
return g_string_free (yaml_result, FALSE);
}
/**
* as_validator_get_tag_explanation:
* @validator: An instance of #AsValidator.
*
* Get the explanatory text for a given issue tag.
*
* Returns: Explanation text.
*/
const gchar*
as_validator_get_tag_explanation (AsValidator *validator, const gchar *tag)
{
AsValidatorPrivate *priv = GET_PRIVATE (validator);
const AsValidatorIssueTag *tag_data = g_hash_table_lookup (priv->issue_tags, tag);
if (tag_data == NULL)
return NULL;
return tag_data->explanation;
}
/**
* as_validator_get_tag_severity:
* @validator: An instance of #AsValidator.
*
* Get the severity for a given issue tag.
*
* Returns: The #AsIssueSeverity
*/
AsIssueSeverity
as_validator_get_tag_severity (AsValidator *validator, const gchar *tag)
{
AsValidatorPrivate *priv = GET_PRIVATE (validator);
const AsValidatorIssueTag *tag_data = g_hash_table_lookup (priv->issue_tags, tag);
if (tag_data == NULL)
return AS_ISSUE_SEVERITY_UNKNOWN;
return tag_data->severity;
}
/**
* as_validator_class_init:
**/
......
......@@ -26,6 +26,7 @@
#define __AS_VALIDATOR_H
#include <glib-object.h>
#include "as-validator-issue.h"
G_BEGIN_DECLS
......@@ -62,6 +63,11 @@ gboolean as_validator_get_check_urls (AsValidator *validator);
void as_validator_set_check_urls (AsValidator *validator,
gboolean value);
const gchar *as_validator_get_tag_explanation (AsValidator *validator,
const gchar *tag);
AsIssueSeverity as_validator_get_tag_severity (AsValidator *validator,
const gchar *tag);
G_END_DECLS
#endif /* __AS_VALIDATOR_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment