GitHub user HyukjinKwon opened a pull request:
https://github.com/apache/spark/pull/12413
[MINOR] Remove inappropriate type notation and extra anonymous closure
within functional transformations
## What changes were proposed in this pull request?
This PR removes
- Inappropriate type notations
For example, from
```scala
words.foreachRDD { (rdd: RDD[String], time: Time) =>
...
```
to
```scala
words.foreachRDD { (rdd, time) =>
...
```
- Extra anonymous closure within functional transformations.
For example,
```scala
.map(item => {
...
})
```
which can be just simply as below:
```scala
.map { item =>
...
}
```
and corrects some obvious style nits.
## How was this patch tested?
This was tested after adding rules in `scalastyle-config.xml`, which ended
up with not finding all perfectly.
The rules applied were below:
- For the first correction,
```xml
<check customId="NoExtraClosure" level="error"
class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters><parameter
name="regex">(?m)\.[a-zA-Z_][a-zA-Z0-9]*\(\s*[^,]+s*=>\s*\{[^\}]+\}\s*\)</parameter></parameters>
</check>
```
```xml
<check customId="NoExtraClosure" level="error"
class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters><parameter
name="regex">\.[a-zA-Z_][a-zA-Z0-9]*\s*[\{|\(]([^\n>,]+=>)?\s*\{([^()]|(?R))*\}^[,]</parameter></parameters>
</check>
```
- For the second correction
```xml
<check customId="TypeNotation" level="error"
class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters><parameter
name="regex">\.[a-zA-Z_][a-zA-Z0-9]*\s*[\{|\(]\s*\([^):]*:R))*\}^[,]</parameter></parameters>
</check>
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HyukjinKwon/spark SPARK-style
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12413.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #12413
----
commit f075df3520a22436cb2a9b5eb39ccf985dadb58d
Author: hyukjinkwon <[email protected]>
Date: 2016-04-15T03:48:40Z
Add the initial style pattern
commit 2ede93e7f5431d006fb6e0244e49788cd964b4ca
Author: hyukjinkwon <[email protected]>
Date: 2016-04-15T04:46:35Z
Update pattern and correct more of them
commit ff93278f821688e22b2b4a2bf91d3909ecd12e33
Author: hyukjinkwon <[email protected]>
Date: 2016-04-15T07:30:16Z
Add more styles
commit 4aa5ce642858184f8fe4274b8778c2dd4c1d8591
Author: hyukjinkwon <[email protected]>
Date: 2016-04-15T08:51:39Z
Merge upstream
commit bd7dec4c9d72e65917ab41c4bff005b9cae1cc6f
Author: hyukjinkwon <[email protected]>
Date: 2016-04-15T09:08:39Z
Remove the change in the rules and correct weirdly written types
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]