language: minimal
dist: bionic
addons:
  apt:
    packages:
    - python3-pip
    - python3-setuptools

install:
  - pip3 install --user codespell
  - go get -u github.com/client9/misspell/cmd/misspell

script:
  - git grep -n --color $'\r' -- "*.asciidoc" "*.md" && echo "^ Possible Windows style line ending detected. Please use Unix style line endings (\n)." && exit 0 || true
  - git grep -n --color ' $' -- "*.asciidoc" "*.md" && echo "^ Trailing space detected at end of line. Please remove." && exit 0 || true
  - git grep  -n --color  $'\t' -- "*.asciidoc" "*.md" && echo "^ Use of tabs detected. Please use space for indentation." && exit 0 || true
  - git grep -iE  -n --color '(^| )(\w+) \2(\.|,|:|;| |$)' -- "*.asciidoc" "*.md" && echo "^ Detected lexical illusion in the form of a duplicated word. Please correct." && exit 0 || true
  - for FILE in $(git ls-files -- "*.asciidoc" "*.md"); do if [[ $(tail -c1 $FILE) != "" ]]; then echo "File ${FILE} does not end with a newline character (\n)."; exit 0; fi; done
  - git grep "" -- "*.asciidoc" "*.md" | uniq -c | grep -1 "^      [2-9] " | cut -b9- | sed 's/:$/:[more-than-one-blank-line-here-please-remove]/' | grep ":" && echo "^ Multiple blank lines detected. Please use only one blank line between paragraphs." && exit 0 || true
  - codespell --ignore-words-list=que $(git ls-files -- "*.asciidoc" "*.md")
  - misspell $(git ls-files -- "*.asciidoc" "*.md")
