Repository: spark
Updated Branches:
  refs/heads/master ad935f526 -> 86d251c58


[SPARK-20278][R] Disable 'multiple_dots_linter' lint rule that is against 
project's code style

## What changes were proposed in this pull request?

Currently, multi-dot separated variables in R is not allowed. For example,

```diff
 setMethod("from_json", signature(x = "Column", schema = "structType"),
-          function(x, schema, asJsonArray = FALSE, ...) {
+          function(x, schema, as.json.array = FALSE, ...) {
             if (asJsonArray) {
               jschema <- callJStatic("org.apache.spark.sql.types.DataTypes",
                                      "createArrayType",
```

produces an error as below:

```
R/functions.R:2462:31: style: Words within variable and function names should 
be separated by '_' rather than '.'.
          function(x, schema, as.json.array = FALSE, ...) {
                              ^~~~~~~~~~~~~
```

This seems against https://google.github.io/styleguide/Rguide.xml#identifiers 
which says

> The preferred form for variable names is all lower case letters and words 
> separated with dots

This looks because lintr by default https://github.com/jimhester/lintr follows 
http://r-pkgs.had.co.nz/style.html as written in the README.md. Few cases seems 
not following Google's one as "a few tweaks".

Per [SPARK-6813](https://issues.apache.org/jira/browse/SPARK-6813), we follow 
Google's R Style Guide with few exceptions 
https://google.github.io/styleguide/Rguide.xml. This is also merged into 
Spark's website - https://github.com/apache/spark-website/pull/43

Also, it looks we have no limit on function name. This rule also looks 
affecting to the name of functions as written in the README.md.

> `multiple_dots_linter`: check that function and variable names are separated 
> by _ rather than ..

## How was this patch tested?

Manually tested `./dev/lint-r`with the manual change below in `R/functions.R`:

```diff
 setMethod("from_json", signature(x = "Column", schema = "structType"),
-          function(x, schema, asJsonArray = FALSE, ...) {
+          function(x, schema, as.json.array = FALSE, ...) {
             if (asJsonArray) {
               jschema <- callJStatic("org.apache.spark.sql.types.DataTypes",
                                      "createArrayType",
```

**Before**

```R
R/functions.R:2462:31: style: Words within variable and function names should 
be separated by '_' rather than '.'.
          function(x, schema, as.json.array = FALSE, ...) {
                              ^~~~~~~~~~~~~
```

**After**

```
lintr checks passed.
```

Author: hyukjinkwon <gurwls...@gmail.com>

Closes #17590 from HyukjinKwon/disable-dot-in-name.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/86d251c5
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/86d251c5
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/86d251c5

Branch: refs/heads/master
Commit: 86d251c58591278a7c88745a1049e7a41db11964
Parents: ad935f5
Author: hyukjinkwon <gurwls...@gmail.com>
Authored: Sun Apr 16 11:27:27 2017 -0700
Committer: Felix Cheung <felixche...@apache.org>
Committed: Sun Apr 16 11:27:27 2017 -0700

----------------------------------------------------------------------
 R/pkg/.lintr | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/86d251c5/R/pkg/.lintr
----------------------------------------------------------------------
diff --git a/R/pkg/.lintr b/R/pkg/.lintr
index 038236f..ae50b28 100644
--- a/R/pkg/.lintr
+++ b/R/pkg/.lintr
@@ -1,2 +1,2 @@
-linters: with_defaults(line_length_linter(100), camel_case_linter = NULL, 
open_curly_linter(allow_single_line = TRUE), 
closed_curly_linter(allow_single_line = TRUE))
+linters: with_defaults(line_length_linter(100), multiple_dots_linter = NULL, 
camel_case_linter = NULL, open_curly_linter(allow_single_line = TRUE), 
closed_curly_linter(allow_single_line = TRUE))
 exclusions: list("inst/profile/general.R" = 1, "inst/profile/shell.R")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to