-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-20278][R] Disable 'multiple_dots_linter' lint rule that is against project's code style #17590
Conversation
cc @felixcheung, could you take a look and see if it makes sense to you? |
Test build #75656 has finished for PR 17590 at commit
|
Changes look fine. I think we should get some feedback on style/guideline changes like this though.
Also do you know why we don't ever see these types of error in Jenkins? Is it because it's running an older lintr?
R/functions.R:2462:31: style: Words within variable and function names should be separated by '_' rather than '.'.
|
I think it is because it only checks multiple dots and the case I described above was finally found before (in my previous PR related with I think multiple dots are still valid per ...
Yea, maybe. I am fine with leaving this open for some days more to see if there is any objection. Probably, let me cc who I saw made many contributions to SparkR. cc @shivaram, @yanboliang, @wangmiao1981 and @actuaryzhang here. Please let me know if there is any concern. |
The change is fine to me. With this, we can define function/argument names using multiple styles such as |
This is my thought on it.
Note that, I think this does not necessarily mean we should sweep all existing
|
I think @HyukjinKwon interpretation is good ! |
Thanks @HyukjinKwon for addressing this and @actuaryzhang, @shivaram for chiming in. |
merged to master. |
Sure, thank you. |
…inst 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 - apache/spark-website#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 <[email protected]> Closes apache#17590 from HyukjinKwon/disable-dot-in-name.
What changes were proposed in this pull request?
Currently, multi-dot separated variables in R is not allowed. For example,
produces an error as below:
This seems against https://google.github.io/styleguide/Rguide.xml#identifiers which says
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, 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 - apache/spark-website#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.
How was this patch tested?
Manually tested
./dev/lint-r
with the manual change below inR/functions.R
:Before
After