Docs
Checks
metric

metric

Learn about the metric extension point.

NameTypeDescription
formulastringA formula of pre-defined variables to be evaluated.
conditionstringA binary condition upon which formula will trigger an alert.

metric enforces arbitrary formulas based on pre-defined, built-in variables.

yaml
extends: metric message: 'Try to keep the Flesch-Kincaid grade level (%s) below 8.' link: | https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests formula: | (0.39 * (words / sentences)) + (11.8 * (syllables / words)) - 15.59 condition: '> 8.0'

Variables

The table below summarizes all available variables:

VariableDescription
blockquoteThe number of blockquote tags.
charactersThe number of characters.
complex_wordsThe number of polysyllabic words without common suffixes (es, ed, ing, …).
heading.h{n}The number of headings at the specified level (for example, heading.h1).
listThe number of ol and ul tags.
long_wordsThe number of words with more than 6 characters.
paragraphsThe number of paragraphs.
polysyllabic_wordsThe number of words with more than 2 syllables.
preThe number of pre tags.
sentencesThe number of sentences.
syllablesThe number of syllables.
wordsThe number of words.

Since the pre-defined variables are calculated using the entire document, all metric-based rules are summary-scoped.

Operators

In addition to using the variables listed above, a formula may also use the following operators:

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division
math.sqrt(x)Square root of x
math.abs(x)Absolute value of x

A condition may use one of >, <, ==, >=, and <=.

message

The result of a formula will be compared to its condition and inserted into its message format specifier (%s).