You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by jongyoul <gi...@git.apache.org> on 2016/07/12 13:53:27 UTC

[GitHub] zeppelin pull request #1168: [MINOR] Add formatter

GitHub user jongyoul opened a pull request:

    https://github.com/apache/zeppelin/pull/1168

    [MINOR] Add formatter

    ### What is this PR for?
    Unifying the format of codes
    
    ### What type of PR is it?
    [Feature]
    
    ### Todos
    * [x] - Add formatter
    * [x] - Convert sample file
    
    ### What is the Jira issue?
    N/A
    
    ### How should this be tested?
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No


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

    $ git pull https://github.com/jongyoul/zeppelin minor/add-formatter

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

    https://github.com/apache/zeppelin/pull/1168.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 #1168
    
----
commit 84f50062ae9179139510a0d9267c254dd0f0154b
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T13:40:00Z

    Added formatter for Intellij and Eclipse

commit 72d4307278c651f063ae48d5856b156be5cb581f
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T13:40:50Z

    Adjusted new style on ZeppelinServer.java

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin pull request #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
GitHub user jongyoul reopened a pull request:

    https://github.com/apache/zeppelin/pull/1168

    [MINOR] Add formatter

    ### What is this PR for?
    Unifying the format of codes
    
    ### What type of PR is it?
    [Feature]
    
    ### Todos
    * [x] - Add formatter
    * [x] - Convert sample file
    
    ### What is the Jira issue?
    N/A
    
    ### How should this be tested?
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No


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

    $ git pull https://github.com/jongyoul/zeppelin minor/add-formatter

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

    https://github.com/apache/zeppelin/pull/1168.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 #1168
    
----
commit 66232b4c9112355fd8be140ce6c7920b81290309
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T13:40:00Z

    Added formatter for Intellij and Eclipse

commit 7281cf73aea957b27473f2cfbcf89c83df7c81ac
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T13:40:50Z

    Adjusted new style on ZeppelinServer.java

commit baf94f9e5deb8c70a3cf178cb9e03ad549195363
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T14:53:40Z

    Adjusted new style on JsonResponse.java

commit 6c94abf4be20cb72305ddfef1e9cdfdf139ba443
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T15:47:58Z

    Added license information into *style.xml

commit 1409a143d60c853e8da3813430811be34a013992
Author: Jongyoul Lee <jo...@gmail.com>
Date:   2016-07-12T16:00:30Z

    Added docs

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by 1ambda <gi...@git.apache.org>.
Github user 1ambda commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @bzz 
    
    I created a JIRA issue for this: https://issues.apache.org/jira/browse/ZEPPELIN-1709
    
    We can resolve this in 1 PR or can split it into multiples. I think we can resolve these things
    
    - update checkstyle.xml
    - update maven plugin or introduce more recent a new plugin https://github.com/checkstyle/checkstyle (some apache projects use both)
    - write a detailed guide about how to format your zeppelin code while making contribution


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @jongyoul how do you think, could you interactively rebase this branch to have only `./_tools/*` changes? Or is it better to start a JIRA issue and close this guy?
    
    @1ambda do you know any way of getting cross-ide formatters, consistent with checkstyle rules for the [Java style guide](https://google.github.io/styleguide/javaguide.html)?
    
    Should we just try bringin in: 
     - eclipse https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml
     - intelij https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml and 
     - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
    
    here and then see if they produce same results re-formatting a single class? What do you guys think?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @bzz Thanks for the suggestion. I think we need to update docs and it's time to install Eclipse by myself in order to check the difference between Eclipse and Intellij. Thanks Alex.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin pull request #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul closed the pull request at:

    https://github.com/apache/zeppelin/pull/1168


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    Got it. Let's may be change PR title to WIP or even may be close it for now but keep the branch and create a dedicated JIRA issue and link this work there? 
    
    It's a bigger effort that we initially think, so we can add sub-tasts like  
     - InteliJ formatter
     - Eclipse formatter
     - Build time check of the code conventions to conform our styleguide
    
    One problem that I can see though - it will be not very useful commit, retrofitting whole codebase to the styleguilde: it will touch all the files in the project and just re-formatting it. This complicates navigating the history of changes and makes 'git blame' less useful.
    
    What would be great if we could provide consistent formatters for IDEs first, advise everyone to use them AND then make mandatory style checks ONLY for the new code.
    
    I think this should be possible! I can look into that.
    
    But we still need 2 consistent formatters.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    I have applied `ZeppelinStyle` Java formatter in Eclipse and re-formatted `ZeppelinServer.java` here is the diff below
    
    ```
    diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
    index 4ef6f44..686d6ea 100644
    --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
    +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
    @@ -1,18 +1,16 @@
     /*
    - * Licensed to the Apache Software Foundation (ASF) under one or more
    - * contributor license agreements.  See the NOTICE file distributed with
    - * this work for additional information regarding copyright ownership.
    - * The ASF licenses this file to You under the Apache License, Version 2.0
    - * (the "License"); you may not use this file except in compliance with
    - * the License.  You may obtain a copy of the License at
    - *
    - *    http://www.apache.org/licenses/LICENSE-2.0
    - *
    - * Unless required by applicable law or agreed to in writing, software
    - * distributed under the License is distributed on an "AS IS" BASIS,
    - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    - * See the License for the specific language governing permissions and
    - * limitations under the License.
    + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
    + * agreements. See the NOTICE file distributed with this work for additional information regarding
    + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance with the License. You may obtain a
    + * copy of the License at
    + * 
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing, software distributed under the License
    + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    + * or implied. See the License for the specific language governing permissions and limitations under
    + * the License.
      */
     
     package org.apache.zeppelin.server;
    @@ -105,8 +103,9 @@ public class ZeppelinServer extends Application {
         this.notebookIndex = new LuceneSearch();
         this.notebookAuthorization = new NotebookAuthorization(conf);
         this.credentials = new Credentials(conf.credentialsPersist(), conf.getCredentialsPath());
    -    notebook = new Notebook(conf, notebookRepo, schedulerFactory, replFactory, notebookWsServer,
    -        notebookIndex, notebookAuthorization, credentials);
    +    notebook =
    +        new Notebook(conf, notebookRepo, schedulerFactory, replFactory, notebookWsServer,
    +            notebookIndex, notebookAuthorization, credentials);
     
         // to update notebook from application event from remote process.
         heliumApplicationFactory.setNotebook(notebook);
    @@ -135,12 +134,12 @@ public class ZeppelinServer extends Application {
         // Notebook server
         setupNotebookServer(webApp, conf);
     
    -    //Below is commented since zeppelin-docs module is removed.
    -    //final WebAppContext webAppSwagg = setupWebAppSwagger(conf);
    +    // Below is commented since zeppelin-docs module is removed.
    +    // final WebAppContext webAppSwagg = setupWebAppSwagger(conf);
     
         LOG.info("Starting zeppelin server");
         try {
    -      jettyWebServer.start(); //Instantiates ZeppelinServer
    +      jettyWebServer.start(); // Instantiates ZeppelinServer
         } catch (Exception e) {
           LOG.error("Error while running jettyServer", e);
           System.exit(-1);
    @@ -148,7 +147,8 @@ public class ZeppelinServer extends Application {
         LOG.info("Done, zeppelin server started");
     
         Runtime.getRuntime().addShutdownHook(new Thread() {
    -      @Override public void run() {
    +      @Override
    +      public void run() {
             LOG.info("Shutting down Zeppelin Server ... ");
             try {
               jettyWebServer.stop();
    @@ -192,13 +192,13 @@ public class ZeppelinServer extends Application {
           HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
           SecureRequestCustomizer src = new SecureRequestCustomizer();
           // Only with Jetty 9.3.x
    -      //      src.setStsMaxAge(2000);
    -      //      src.setStsIncludeSubDomains(true);
    +      // src.setStsMaxAge(2000);
    +      // src.setStsIncludeSubDomains(true);
           httpsConfig.addCustomizer(src);
     
    -      connector = new ServerConnector(server,
    -          new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString()),
    -          new HttpConnectionFactory(httpsConfig));
    +      connector =
    +          new ServerConnector(server, new SslConnectionFactory(getSslContextFactory(conf),
    +              HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
     
     
         } else {
    @@ -260,8 +260,8 @@ public class ZeppelinServer extends Application {
         webapp.setSessionHandler(new SessionHandler());
         webapp.addServlet(cxfServletHolder, "/api/*");
     
    -    webapp
    -        .setInitParameter("shiroConfigLocations", new File(conf.getShiroPath()).toURI().toString());
    +    webapp.setInitParameter("shiroConfigLocations", new File(conf.getShiroPath()).toURI()
    +        .toString());
     
         SecurityUtils.initSecurityManager(conf.getShiroPath());
         webapp.addFilter(org.apache.shiro.web.servlet.ShiroFilter.class, "/api/*",
    @@ -300,12 +300,14 @@ public class ZeppelinServer extends Application {
     
       }
     
    -  @Override public Set<Class<?>> getClasses() {
    +  @Override
    +  public Set<Class<?>> getClasses() {
         Set<Class<?>> classes = new HashSet<Class<?>>();
         return classes;
       }
     
    -  @Override public Set<Object> getSingletons() {
    +  @Override
    +  public Set<Object> getSingletons() {
         Set<Object> singletons = new HashSet<>();
     
         /** Rest-api root endpoint */
    @@ -336,4 +338,3 @@ public class ZeppelinServer extends Application {
         return singletons;
       }
     }
    -
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @bzz I've found Intellij doesn't export all of some configurations. We need to enforce the format by configuring checkstyle.xml.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @jongyoul do you think we should update our documentation for contributors, mentioning this IDE setup as well?



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    checkstyle in my PR is too strict and if we push it, too many error occurs while checking style. I don't know how to handle with it. What do you think of it?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    I think we are already on the path of multiple PRs, wich sounds great to me!
    
    @jongyoul shall we close this guy then?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    Yes, I think it's good idea on having stricter checkstyle.
    Let me know if you want me to try again!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    Do you think we should merge it as is and address eclipse formatter in the separate issue?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    Ready to review. Could you please check Eclipse's one? Open ZeppelinServer.java and reformat it and check if something's different or not.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by bzz <gi...@git.apache.org>.
Github user bzz commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    Sounds good! Let's rebase on master and make CI happy again first? :)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin pull request #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul closed the pull request at:

    https://github.com/apache/zeppelin/pull/1168


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @bzz Yes, I also don't think it's good idea to reformat all of codes. I like your suggestion to adopt IDE formatter first. Let's find a way to sync both of IntelliJ and Eclipse formatters.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] zeppelin issue #1168: [MINOR] Add formatter

Posted by jongyoul <gi...@git.apache.org>.
Github user jongyoul commented on the issue:

    https://github.com/apache/zeppelin/pull/1168
  
    @bzz Sure, I agree. it's kind of separate issue. I think enforcing code format at first supporting formatter later would be a good plan. How about you?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---