The Sanity Check
Structure
The sanity check consists of two parts: The first part is a script with a number
of git grep
calls using regex to find typical errors. The second parts is a java program that checks for correct closure of all SugarCube macros and HTML tags and has some additional functionality.
The Java Check
Structure
The java check has 3 main parts:
-
A checks for correct closure of all SugarCube macros and HTML tags in the .tw files.
-
A check to find variable names that are only used once to find misspelled variables and leftovers from removed variables.
-
A search through all files against a dictionary to find common misspellings and deprecated code.
Maintenance
In order to keep the number of false positives to a minimum this check has to be regularly maintained:
-
When new macros or HTML tags are introduced in the project code they have to be added to
devTools/javaSanityCheck/twineTags
ordevTools/javaSanityCheck/htmlTags
. -
When removing variables they often have a reference left in some kind of BC related code. This is a common example when a false positive occurs and that variable has to be added to
devTools/javaSanityCheck/ignoredVariables
. -
When fully removing variables that were ignored, they have to be removed from
devTools/javaSanityCheck/ignoredVariables
too. -
When adding variables it can happen that only one usage is identified by the check, which means that it throws a false positive. To remove this add the variable to
devTools/javaSanityCheck/ignoredVariables
. When the variable is used in more places later and found more than once it has to be removed again to keep the check as efficient as possible. -
When you find common missspellings you can add them to
devTools/dictionary_phrases.txt
ordevTools/dictionary_wholeWord.txt
. -
When a file produces so many false positives that they are impossible to clean up it may be added to
devTools/javaSanityCheck/excluded
.
Source code
The source code can either be found at gitgud.io.