From 323ca5cd43e491232f163c024b013a063f277455 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sat, 13 Feb 2021 19:36:34 +1000 Subject: [PATCH] feat: add a GitHub Action to check for trailing whitespace in all files --- .github/workflows/lint.yml | 9 ++++ doc/index.md | 2 +- doc/library/math.md | 58 +++++++++++++------------- utils/check-for-trailing-whitespace.sh | 13 ++++++ 4 files changed, 52 insertions(+), 30 deletions(-) create mode 100755 utils/check-for-trailing-whitespace.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dc75fbd..69963cc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,6 +21,15 @@ jobs: - uses: actions/checkout@v2 - name: 🧹 ShellCheck uses: ludeeus/action-shellcheck@master + trailing-whitespace: + name: 🧋 Trailing whitespace + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: 🧹 Check for trailing whitespace + run: | + cd utils || exit + sh ./check-for-trailing-whitespace.sh || exit 1 yamllint: name: 🍺 YAML runs-on: ubuntu-latest diff --git a/doc/index.md b/doc/index.md index 5b5de3d..e4e4ca8 100644 --- a/doc/index.md +++ b/doc/index.md @@ -1,3 +1,3 @@ ## Library -[math](https://github.com/matz/streem/doc/library/math.md) +[math](https://github.com/matz/streem/doc/library/math.md) diff --git a/doc/library/math.md b/doc/library/math.md index 04fc091..9dfad98 100644 --- a/doc/library/math.md +++ b/doc/library/math.md @@ -1,6 +1,6 @@ # Math -Streem has a lot Mathematical functions defined by the C standard. +Streem has a lot Mathematical functions defined by the C standard. ## Constants @@ -15,7 +15,7 @@ print(PI) ### E -The mathematical constant e = 2.718281…, to available precision. +The mathematical constant e = 2.718281…, to available precision. ``` # Output: 2.718281828459 @@ -26,7 +26,7 @@ print(E) ### ceil(x) -Return the ceiling of x. +Return the ceiling of x. ``` # Output: 46 @@ -35,7 +35,7 @@ print(ceil(45.54)) ### fabs(x) -Return the absolute value of x. +Return the absolute value of x. ``` # Output: 2 @@ -53,20 +53,20 @@ print(gcd(4,10)) ### trunc(x) -Return the Real value x truncated to an Integral. +Return the Real value x truncated to an Integral. ``` Output: 9 print(trunc(9.13)) -``` +``` ### int(x) -Same as trunc(x). +Same as trunc(x). ### floor(x) -Return the floor of x. +Return the floor of x. ``` # Output: 2 @@ -75,7 +75,7 @@ print(floor(2.7)) ### round(x) -Return the rounding of x. +Return the rounding of x. ``` # Output: 10 @@ -104,80 +104,80 @@ print(ldexp(6,3)) ### sin(x) -Return the sine of x. +Return the sine of x. ### cos(x) -Return the cosine of x. +Return the cosine of x. ### tan(x) -Return the tangent of x. +Return the tangent of x. ### asin(x) -Return the arc sine of x. +Return the arc sine of x. ### acos(x) -Return the arc cosine of x. +Return the arc cosine of x. ### atan(x) -Return the arc tangent of x. +Return the arc tangent of x. ### hypot(x, y) -Return the `sqrt(x * x + y * y)`(Euclidean norm). +Return the `sqrt(x * x + y * y)`(Euclidean norm). ``` # Output: 5 print(hypot(3,4)) -``` +``` ## Hyperbolic functions ### asinh(x) -Return the inverse hyperbolic sine of x. +Return the inverse hyperbolic sine of x. ### acosh(x) -Return the inverse hyperbolic cosine of x. +Return the inverse hyperbolic cosine of x. ### atanh(x) -Return the inverse hyperbolic tangent of x. +Return the inverse hyperbolic tangent of x. ### cosh(x) -Return the hyperbolic cosine of x. +Return the hyperbolic cosine of x. ### sinh(x) -Return the hyperbolic sine of x. +Return the hyperbolic sine of x. ### tanh(x) -Return the hyperbolic tangent of x. +Return the hyperbolic tangent of x. ## logarithmic functions ### exp(x) -Return e raised to the power x. +Return e raised to the power x. ### log(x) -Return the natural logarithm of x. +Return the natural logarithm of x. ### log2(x) -Return the base-2 logarithm of x. +Return the base-2 logarithm of x. ### log10(x) -Return the base-10 logarithm of x. +Return the base-10 logarithm of x. ## Power functions @@ -188,7 +188,7 @@ Return x raised to the power y. ``` # Output: 25 print(pow(5,2)) -``` +``` ### sqrt(x) @@ -197,4 +197,4 @@ Return the square root of x. ``` # Output: 5 print(sqrt(25)) -``` +``` diff --git a/utils/check-for-trailing-whitespace.sh b/utils/check-for-trailing-whitespace.sh new file mode 100755 index 0000000..00be038 --- /dev/null +++ b/utils/check-for-trailing-whitespace.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +cd .. || exit +# print first +grep -EHInr '( +)$' ./* + +var=$(grep -EHInr '( +)$' ./*) +# then exit with fail if found +if test -z "$var"; then + exit 0 +else + exit 1 +fi