diff --git a/r/README.Rmd b/r/README.Rmd index cb57d1ab992..2442b83435f 100644 --- a/r/README.Rmd +++ b/r/README.Rmd @@ -161,6 +161,24 @@ remotes::install_github("romainfrancois/decor") install.packages(c("dplyr", "purrr", "glue")) ``` +We use Google C++ style in our C++ code. Check for style errors with + +``` +./lint.sh +``` + +Fix any style issues before committing with + +``` +./lint.sh --fix +``` + +The lint script requires Python 3 and `clang-format-7`. If the command isn't +found, you can explicitly provide the path to it like +`CLANG_FORMAT=$(which clang-format-7) ./lint.sh`. On macOS, +you can get this by installing LLVM via Homebrew and running the script as +`CLANG_FORMAT=$(brew --prefix llvm@7)/bin/clang-format ./lint.sh` + ### Useful functions Within an R session, these can help with package development: diff --git a/r/README.md b/r/README.md index 937f00d85af..9d542973045 100644 --- a/r/README.md +++ b/r/README.md @@ -233,6 +233,20 @@ remotes::install_github("romainfrancois/decor") install.packages(c("dplyr", "purrr", "glue")) ``` +We use Google C++ style in our C++ code. Check for style errors with + + ./lint.sh + +Fix any style issues before committing with + + ./lint.sh --fix + +The lint script requires Python 3 and `clang-format-7`. If the command +isn’t found, you can explicitly provide the path to it like +`CLANG_FORMAT=$(which clang-format-7) ./lint.sh`. On macOS, you can get +this by installing LLVM via Homebrew and running the script as +`CLANG_FORMAT=$(brew --prefix llvm@7)/bin/clang-format ./lint.sh` + ### Useful functions Within an R session, these can help with package development: diff --git a/r/lint.sh b/r/lint.sh index fed64c1b31c..bd0f7a81100 100755 --- a/r/lint.sh +++ b/r/lint.sh @@ -17,11 +17,14 @@ # specific language governing permissions and limitations # under the License. +# This script requires Python 3 and clang-format, which should already be +# on your system. See r/README.md for further guidance + SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CPP_BUILD_SUPPORT=$SOURCE_DIR/../cpp/build-support # Run clang-format -CLANG_FORMAT=clang-format-7 +: ${CLANG_FORMAT:=clang-format-7} $CPP_BUILD_SUPPORT/run_clang_format.py \ --clang_format_binary=$CLANG_FORMAT \ --exclude_glob=$CPP_BUILD_SUPPORT/lint_exclusions.txt \