GitHub user HyukjinKwon opened a pull request:

    https://github.com/apache/spark/pull/14490

    [SPARK-16877][BUILD] Add rules for preventing to use Java annotations 
(Deprecated and Override)

    ## What changes were proposed in this pull request?
    
    This PR adds both rules for preventing to use `@Deprecated` and `@Override`.
    
    - Java's `@Override`
      It seems Scala compiler just ignores this. This can be problematic when 
traits or abstract classes as inherited. Scala compiles seems `override` 
modifier is only mandatory for " that override some other **concrete member 
definition** in a parent class" but not for for **incomplete member 
definition** (such as ones from trait or abstract), see 
(http://www.scala-lang.org/files/archive/spec/2.11/05-classes-and-objects.html#override)
    
      For a simple example,
    
      - Normal class - needs `override` modifier
    
      ```bash
      scala> class A { def say = {}}
      defined class A
    
      scala> class B extends A { def say = {}}
      <console>:8: error: overriding method say in class A of type => Unit;
       method say needs `override' modifier
             class B extends A { def say = {}}
                                     ^
      ```
    
      - Trait - does not need `override` modifier
    
      ```bash
      scala> trait A { def say }
      defined trait A
    
      scala> class B extends A { def say = {}}
      defined class B
      ```
    
      To cut this short, in the latter case, we can write `@Override` 
annotation (meaning nothing) which might confuse engineers that Java's 
annotation is working fine. It might be great if we prevent those potential 
confusion.
    
    - Java's `@Deprecated`
      When `@Deprecated` is used,  it seems Scala compiler recognises this 
correctly but it seems we use Scala one `@deprecated` across codebase.
    
    ## How was this patch tested?
    
    Manually tested, by inserting both `@Override` and `@Deprecated`. This will 
shows the error messages as below:
    
    ```bash
    Scalastyle checks failed at following occurrences:
    [error] ... : @deprecated should be used instead of @java.lang.
    ```
    
    ```basg
    Scalastyle checks failed at following occurrences:
    [error] ... : override modifier should be used instead of 
@java.lang.Override.
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HyukjinKwon/spark SPARK-16877

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/14490.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 #14490
    
----
commit 79eaef7f55779e949d7e8dc0b4e4749d76f99c9f
Author: hyukjinkwon <[email protected]>
Date:   2016-08-04T02:02:25Z

    Add rules for preventing to use Java annotations (Deprecated and Override)

----


---
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]

Reply via email to