You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2018/03/29 02:16:32 UTC

zeppelin git commit: ZEPPELIN-3144. Fixed Checkstyle issues in markdown module

Repository: zeppelin
Updated Branches:
  refs/heads/master 4e9d2c449 -> 930907959


ZEPPELIN-3144. Fixed Checkstyle issues in markdown module

### What is this PR for?
Fixed the Checkstyle issues in the markdown module.

### What type of PR is it?
Improvement

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3144

### How should this be tested?
* CI pass

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Jan Hentschel <ja...@ultratendency.com>

Closes #2897 from HorizonNet/ZEPPELIN-3144 and squashes the following commits:

1503c04 [Jan Hentschel] ZEPPELIN-3144. Fixed Checkstyle issues in markdown module


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

Branch: refs/heads/master
Commit: 93090795942ddc331b2f4cb3ec6aac4fd7be55d5
Parents: 4e9d2c4
Author: Jan Hentschel <ja...@ultratendency.com>
Authored: Tue Mar 27 13:39:47 2018 +0200
Committer: Jeff Zhang <zj...@apache.org>
Committed: Thu Mar 29 10:16:27 2018 +0800

----------------------------------------------------------------------
 markdown/pom.xml                                | 10 ++-
 .../org/apache/zeppelin/markdown/Markdown.java  |  9 ++-
 .../zeppelin/markdown/Markdown4jParser.java     |  2 -
 .../markdown/PegdownWebSequencelPlugin.java     | 23 +++----
 .../zeppelin/markdown/PegdownYumlPlugin.java    | 25 ++++---
 .../zeppelin/markdown/Markdown4jParserTest.java | 10 +--
 .../zeppelin/markdown/PegdownParserTest.java    | 71 +++++++++++++-------
 7 files changed, 86 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/pom.xml
----------------------------------------------------------------------
diff --git a/markdown/pom.xml b/markdown/pom.xml
index 4feb3bc..79cabc1 100644
--- a/markdown/pom.xml
+++ b/markdown/pom.xml
@@ -93,7 +93,13 @@
       <plugin>
         <artifactId>maven-resources-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <skip>false</skip>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
-
-</project>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
----------------------------------------------------------------------
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
index 45fa6ce..83b4069 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
@@ -17,21 +17,20 @@
 
 package org.apache.zeppelin.markdown;
 
-import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.zeppelin.interpreter.Interpreter;
 import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
 import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResult.Code;
 import org.apache.zeppelin.interpreter.InterpreterUtils;
 import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
 import org.apache.zeppelin.scheduler.Scheduler;
 import org.apache.zeppelin.scheduler.SchedulerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * MarkdownInterpreter interpreter for Zeppelin.
@@ -74,7 +73,7 @@ public class Markdown extends Interpreter {
     if (MarkdownParserType.PEGDOWN.toString().equals(parserType)) {
       return new PegdownParser();
     } else {
-      /** default parser. */
+      // default parser
       return new Markdown4jParser();
     }
   }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
----------------------------------------------------------------------
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
index 78f8137..215540d 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
@@ -18,8 +18,6 @@
 package org.apache.zeppelin.markdown;
 
 import org.markdown4j.Markdown4jProcessor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownWebSequencelPlugin.java
----------------------------------------------------------------------
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownWebSequencelPlugin.java b/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownWebSequencelPlugin.java
index 8a5d6ea..6238f95 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownWebSequencelPlugin.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownWebSequencelPlugin.java
@@ -38,10 +38,9 @@ import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 
 /**
- * Pegdown plugin for Websequence diagram
+ * Pegdown plugin for Websequence diagram.
  */
 public class PegdownWebSequencelPlugin extends Parser implements BlockPluginParser {
-
   private static final String WEBSEQ_URL = "http://www.websequencediagrams.com";
 
   public PegdownWebSequencelPlugin() {
@@ -57,29 +56,29 @@ public class PegdownWebSequencelPlugin extends Parser implements BlockPluginPars
 
   public static final String TAG = "%%%";
 
-  Rule StartMarker() {
+  Rule startMarker() {
     return Sequence(Spn1(), TAG, Sp(), "sequence", Sp());
   }
 
-  String EndMarker() {
+  String endMarker() {
     return TAG;
   }
 
-  Rule Body() {
+  Rule body() {
     return OneOrMore(TestNot(TAG), BaseParser.ANY);
   }
 
-  Rule BlockRule() {
+  Rule blockRule() {
     StringBuilderVar style = new StringBuilderVar();
     StringBuilderVar body = new StringBuilderVar();
 
     return NodeSequence(
-        StartMarker(),
+        startMarker(),
         Optional(
             String("style="),
             Sequence(OneOrMore(Letter()), style.append(match()), Spn1())),
-        Sequence(Body(), body.append(match())),
-        EndMarker(),
+        Sequence(body(), body.append(match())),
+        endMarker(),
         push(
             new ExpImageNode("title",
                 createWebsequenceUrl(style.getString(), body.getString()),
@@ -87,9 +86,7 @@ public class PegdownWebSequencelPlugin extends Parser implements BlockPluginPars
     );
   }
 
-  public static String createWebsequenceUrl(String style,
-                                            String content) {
-
+  public static String createWebsequenceUrl(String style, String content) {
     style = StringUtils.defaultString(style, "default");
 
     OutputStreamWriter writer = null;
@@ -144,6 +141,6 @@ public class PegdownWebSequencelPlugin extends Parser implements BlockPluginPars
 
   @Override
   public Rule[] blockPluginRules() {
-    return new Rule[]{BlockRule()};
+    return new Rule[]{blockRule()};
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownYumlPlugin.java
----------------------------------------------------------------------
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownYumlPlugin.java b/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownYumlPlugin.java
index 083bc5b..c9e942a 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownYumlPlugin.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/PegdownYumlPlugin.java
@@ -33,10 +33,9 @@ import java.net.URLEncoder;
 import java.util.Map;
 
 /**
- * Pegdown plugin for YUML
+ * Pegdown plugin for YUML.
  */
 public class PegdownYumlPlugin extends Parser implements BlockPluginParser {
-
   public PegdownYumlPlugin() {
     super(PegdownParser.OPTIONS,
         PegdownParser.PARSING_TIMEOUT_AS_MILLIS,
@@ -52,41 +51,41 @@ public class PegdownYumlPlugin extends Parser implements BlockPluginParser {
 
   public static final String TAG = "%%%";
 
-  Rule StartMarker() {
+  Rule startMarker() {
     return Sequence(Spn1(), TAG, Sp(), "yuml", Sp());
   }
 
-  String EndMarker() {
+  String endMarker() {
     return TAG;
   }
 
-  Rule ParameterName() {
+  Rule parameterName() {
     return FirstOf("type", "style", "scale", "format", "dir");
   }
 
-  Rule Body() {
+  Rule body() {
     return OneOrMore(TestNot(TAG), BaseParser.ANY);
   }
 
-  Rule BlockRule() {
-    ParamVar<String, String> params = new ParamVar<String, String>();
+  Rule blockRule() {
+    ParamVar<String, String> params = new ParamVar<>();
     StringBuilderVar name = new StringBuilderVar();
     StringBuilderVar value = new StringBuilderVar();
     StringBuilderVar body = new StringBuilderVar();
 
     return NodeSequence(
-        StartMarker(),
+        startMarker(),
         ZeroOrMore(
             Sequence(
-                ParameterName(), name.append(match()),
+                parameterName(), name.append(match()),
                 String("="),
                 OneOrMore(Alphanumeric()), value.append(match())),
             Sp(),
             params.put(name.getString(), value.getString()),
             name.clear(), value.clear()),
-        Body(),
+        body(),
         body.append(match()),
-        EndMarker(),
+        endMarker(),
         push(
             new ExpImageNode(
                 "title", createYumlUrl(params.get(), body.getString()), new TextNode("")))
@@ -138,6 +137,6 @@ public class PegdownYumlPlugin extends Parser implements BlockPluginParser {
 
   @Override
   public Rule[] blockPluginRules() {
-    return new Rule[]{BlockRule()};
+    return new Rule[]{blockRule()};
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/src/test/java/org/apache/zeppelin/markdown/Markdown4jParserTest.java
----------------------------------------------------------------------
diff --git a/markdown/src/test/java/org/apache/zeppelin/markdown/Markdown4jParserTest.java b/markdown/src/test/java/org/apache/zeppelin/markdown/Markdown4jParserTest.java
index 460fce2..fe381ee 100644
--- a/markdown/src/test/java/org/apache/zeppelin/markdown/Markdown4jParserTest.java
+++ b/markdown/src/test/java/org/apache/zeppelin/markdown/Markdown4jParserTest.java
@@ -17,21 +17,21 @@
 
 package org.apache.zeppelin.markdown;
 
-import org.apache.zeppelin.interpreter.InterpreterResult;
+import static org.junit.Assert.assertEquals;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 import java.util.Properties;
 
-import static org.junit.Assert.assertEquals;
+import org.apache.zeppelin.interpreter.InterpreterResult;
 
 public class Markdown4jParserTest {
-
   Markdown md;
 
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     Properties props = new Properties();
     props.put(Markdown.MARKDOWN_PARSER_TYPE, Markdown.PARSER_TYPE_MARKDOWN4J);
     md = new Markdown(props);
@@ -39,7 +39,7 @@ public class Markdown4jParserTest {
   }
 
   @After
-  public void tearDown() throws Exception {
+  public void tearDown() {
     md.close();
   }
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/93090795/markdown/src/test/java/org/apache/zeppelin/markdown/PegdownParserTest.java
----------------------------------------------------------------------
diff --git a/markdown/src/test/java/org/apache/zeppelin/markdown/PegdownParserTest.java b/markdown/src/test/java/org/apache/zeppelin/markdown/PegdownParserTest.java
index 2e1d857..a608a05 100644
--- a/markdown/src/test/java/org/apache/zeppelin/markdown/PegdownParserTest.java
+++ b/markdown/src/test/java/org/apache/zeppelin/markdown/PegdownParserTest.java
@@ -18,20 +18,24 @@
 package org.apache.zeppelin.markdown;
 
 import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Properties;
-import org.apache.zeppelin.interpreter.InterpreterResult;
+import static org.junit.Assert.assertThat;
 
 import static org.apache.zeppelin.markdown.PegdownParser.wrapWithMarkdownClassDiv;
-import static org.junit.Assert.assertThat;
 
 import org.hamcrest.CoreMatchers;
-import org.junit.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.ErrorCollector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ArrayList;
+import java.util.Properties;
+
+import org.apache.zeppelin.interpreter.InterpreterResult;
+
 public class PegdownParserTest {
   Logger logger = LoggerFactory.getLogger(PegdownParserTest.class);
   Markdown md;
@@ -40,7 +44,7 @@ public class PegdownParserTest {
   public ErrorCollector collector = new ErrorCollector();
 
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     Properties props = new Properties();
     props.put(Markdown.MARKDOWN_PARSER_TYPE, Markdown.PARSER_TYPE_PEGDOWN);
     md = new Markdown(props);
@@ -48,13 +52,13 @@ public class PegdownParserTest {
   }
 
   @After
-  public void tearDown() throws Exception {
+  public void tearDown() {
     md.close();
   }
 
   @Test
   public void testMultipleThread() {
-    ArrayList<Thread> arrThreads = new ArrayList<Thread>();
+    ArrayList<Thread> arrThreads = new ArrayList<>();
     for (int i = 0; i < 10; i++) {
       Thread t = new Thread() {
         public void run() {
@@ -112,14 +116,16 @@ public class PegdownParserTest {
   public void testStrikethrough() {
     InterpreterResult result = md.interpret("This is ~~deleted~~ text", null);
     assertEquals(
-        wrapWithMarkdownClassDiv("<p>This is <del>deleted</del> text</p>"), result.message().get(0).getData());
+        wrapWithMarkdownClassDiv("<p>This is <del>deleted</del> text</p>"),
+            result.message().get(0).getData());
   }
 
   @Test
   public void testItalics() {
     InterpreterResult result = md.interpret("This is *italics* text", null);
     assertEquals(
-        wrapWithMarkdownClassDiv("<p>This is <em>italics</em> text</p>"), result.message().get(0).getData());
+        wrapWithMarkdownClassDiv("<p>This is <em>italics</em> text</p>"),
+            result.message().get(0).getData());
   }
 
   @Test
@@ -179,7 +185,8 @@ public class PegdownParserTest {
             .append("[I'm an inline-style link](https://www.google.com)\n")
             .append("\n")
             .append(
-                "[I'm an inline-style link with title](https://www.google.com \"Google's Homepage\")\n")
+                "[I'm an inline-style link with title](https://www.google.com "
+                        + "\"Google's Homepage\")\n")
             .append("\n")
             .append("[I'm a reference-style link][Arbitrary case-insensitive reference text]\n")
             .append("\n")
@@ -205,17 +212,24 @@ public class PegdownParserTest {
             .append(
                 "<p><a href=\"https://www.google.com\">I&rsquo;m an inline-style link</a></p>\n")
             .append(
-                "<p><a href=\"https://www.google.com\" title=\"Google&#39;s Homepage\">I&rsquo;m an inline-style link with title</a></p>\n")
+                "<p><a href=\"https://www.google.com\" title=\"Google&#39;s Homepage\">I&rsquo;m "
+                        + "an inline-style link with title</a></p>\n")
             .append(
                 "<p><a href=\"https://www.mozilla.org\">I&rsquo;m a reference-style link</a></p>\n")
             .append(
-                "<p><a href=\"../blob/master/LICENSE\">I&rsquo;m a relative reference to a repository file</a></p>\n")
+                "<p><a href=\"../blob/master/LICENSE\">I&rsquo;m a relative reference to a "
+                        + "repository file</a></p>\n")
             .append(
-                "<p><a href=\"http://slashdot.org\">You can use numbers for reference-style link definitions</a></p>\n")
+                "<p><a href=\"http://slashdot.org\">You can use numbers for reference-style link "
+                        + "definitions</a></p>\n")
             .append(
-                "<p>Or leave it empty and use the <a href=\"http://www.reddit.com\">link text itself</a>.</p>\n")
+                "<p>Or leave it empty and use the <a href=\"http://www.reddit.com\">link text "
+                        + "itself</a>.</p>\n")
             .append(
-                "<p>URLs and URLs in angle brackets will automatically get turned into links.<br/><a href=\"http://www.example.com\">http://www.example.com</a> or <a href=\"http://www.example.com\">http://www.example.com</a> and sometimes<br/>example.com (but not on Github, for example).</p>\n")
+                "<p>URLs and URLs in angle brackets will automatically get turned into links."
+                        + "<br/><a href=\"http://www.example.com\">http://www.example.com</a> or "
+                        + "<a href=\"http://www.example.com\">http://www.example.com</a> and "
+                        + "sometimes<br/>example.com (but not on Github, for example).</p>\n")
             .append("<p>Some text to show that the reference links can follow later.</p>")
             .toString();
 
@@ -242,19 +256,26 @@ public class PegdownParserTest {
     assertEquals(
         wrapWithMarkdownClassDiv(
             "<blockquote>\n"
-                + "  <p>Blockquotes are very handy in email to emulate reply text.<br/>This line is part of the same quote.</p>\n"
-                + "</blockquote>"),
+                    + "  <p>Blockquotes are very handy in email to emulate reply text.<br/>This "
+                    + "line is part of the same quote.</p>\n"
+                    + "</blockquote>"),
         r1.message().get(0).getData());
 
     InterpreterResult r2 =
         md.interpret(
-            "> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **MarkdownInterpreter** into a blockquote. ",
+            "> This is a very long line that will still be quoted properly when it "
+                    + "wraps. Oh boy let's keep writing to make sure this is long enough to "
+                    + "actually wrap for everyone. Oh, you can *put* **MarkdownInterpreter** "
+                    + "into a blockquote. ",
             null);
     assertEquals(
         wrapWithMarkdownClassDiv(
             "<blockquote>\n"
-                + "  <p>This is a very long line that will still be quoted properly when it wraps. Oh boy let&rsquo;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>MarkdownInterpreter</strong> into a blockquote. </p>\n"
-                + "</blockquote>"),
+                    + "  <p>This is a very long line that will still be quoted properly when "
+                    + "it wraps. Oh boy let&rsquo;s keep writing to make sure this is long enough "
+                    + "to actually wrap for everyone. Oh, you can <em>put</em> "
+                    + "<strong>MarkdownInterpreter</strong> into a blockquote. </p>\n"
+                    + "</blockquote>"),
         r2.message().get(0).getData());
   }
 
@@ -354,7 +375,8 @@ public class PegdownParserTest {
     // To make unittest independent from websequence service,
     // catch exception, log and pass instead of assert.
     //
-    //assertThat(result.message().get(0).getData(), CoreMatchers.containsString("<img src=\"http://www.websequencediagrams.com/?png="));
+    // assertThat(result.message().get(0).getData(),
+    // CoreMatchers.containsString("<img src=\"http://www.websequencediagrams.com/?png="));
 
     System.err.println(result.message().get(0).getData());
     if (!result.message().get(0).getData().contains(
@@ -375,6 +397,7 @@ public class PegdownParserTest {
         .toString();
 
     InterpreterResult result = md.interpret(input, null);
-    assertThat(result.message().get(0).getData(), CoreMatchers.containsString("<img src=\"http://yuml.me/diagram/"));
+    assertThat(result.message().get(0).getData(),
+            CoreMatchers.containsString("<img src=\"http://yuml.me/diagram/"));
   }
 }