guardian / typerighter

Even if you’re the right typer, couldn’t hurt to use Typerighter!
Apache License 2.0
276 stars 12 forks source link

Include dictionary rules in json artefact used by Checker #405

Closed rhystmills closed 1 year ago

rhystmills commented 1 year ago

What does this change?

This PR includes dictionary rules in the published artefact ingested by the Checker service.

It also includes some fixes to problems caused by the much larger number of rules now included in the Rule Manager.

Separately, we encountered an odd issue where a duplicated word in the dictionary ended up with an empty string as its pattern in our live table. We didn't get to the bottom of the mechanism behind this, but added a words.distinct.filterNot(_ == "") filter to our word list to resolve the problem.

How to test

  1. Run the application locally according to the instructions in the readme. Make sure you run the setup script to pull the dictionary xml files locally.
  2. Hit the /api/refreshDictionary endpoint with a POST request (e.g. in Postman, with cookies from a valid browser request)
  3. Check the artefact in the your localstack instance, e.g. with these commands run in the Docker localstack_main container CLI to pull, pretty print, and find rows containing 'DictionaryRule':
    awslocal s3 cp s3://typerighter-app-local/local/rules/typerighter-rules.json /etc
    sed 's/},{/},\n{/g' /etc/typerighter-rules.json > /etc/parsed.json
    grep -hnr "DictionaryRule" /etc/parsed.json
  4. Do dictionary rules appear in the artefact?