You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/10/16 08:05:52 UTC

git commit: [Core] Upgrading ScalaStyle version to 0.5 and removing SparkSpaceAfterCommentStartChecker.

Repository: spark
Updated Branches:
  refs/heads/master 293a0b5db -> 044583a24


[Core] Upgrading ScalaStyle version to 0.5 and removing SparkSpaceAfterCommentStartChecker.

Author: prudhvi <pr...@gmail.com>

Closes #2799 from prudhvije/ScalaStyle/space-after-comment-start and squashes the following commits:

fc263a1 [prudhvi] [Core] Using scalastyle to check the space after comment start


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

Branch: refs/heads/master
Commit: 044583a241203e7fe759366b273ad32fd9bf7c05
Parents: 293a0b5
Author: prudhvi <pr...@gmail.com>
Authored: Thu Oct 16 02:05:44 2014 -0400
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Thu Oct 16 02:05:44 2014 -0400

----------------------------------------------------------------------
 project/plugins.sbt                             |  2 +-
 .../SparkSpaceAfterCommentStartChecker.scala    | 58 --------------------
 scalastyle-config.xml                           |  2 +-
 3 files changed, 2 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/044583a2/project/plugins.sbt
----------------------------------------------------------------------
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 8096c61..678f5ed 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -17,7 +17,7 @@ addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
 
 addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")
 
-addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.4.0")
+addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.5.0")
 
 addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.6")
 

http://git-wip-us.apache.org/repos/asf/spark/blob/044583a2/project/spark-style/src/main/scala/org/apache/spark/scalastyle/SparkSpaceAfterCommentStartChecker.scala
----------------------------------------------------------------------
diff --git a/project/spark-style/src/main/scala/org/apache/spark/scalastyle/SparkSpaceAfterCommentStartChecker.scala b/project/spark-style/src/main/scala/org/apache/spark/scalastyle/SparkSpaceAfterCommentStartChecker.scala
deleted file mode 100644
index 80d3faa..0000000
--- a/project/spark-style/src/main/scala/org/apache/spark/scalastyle/SparkSpaceAfterCommentStartChecker.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.spark.scalastyle
-
-import java.util.regex.Pattern
-
-import org.scalastyle.{PositionError, ScalariformChecker, ScalastyleError}
-import scalariform.lexer.{MultiLineComment, ScalaDocComment, SingleLineComment, Token}
-import scalariform.parser.CompilationUnit
-
-class SparkSpaceAfterCommentStartChecker extends ScalariformChecker {
-  val errorKey: String = "insert.a.single.space.after.comment.start.and.before.end"
-
-  private def multiLineCommentRegex(comment: Token) =
-    Pattern.compile( """/\*\S+.*""", Pattern.DOTALL).matcher(comment.text.trim).matches() ||
-      Pattern.compile( """/\*.*\S\*/""", Pattern.DOTALL).matcher(comment.text.trim).matches()
-
-  private def scalaDocPatternRegex(comment: Token) =
-    Pattern.compile( """/\*\*\S+.*""", Pattern.DOTALL).matcher(comment.text.trim).matches() ||
-      Pattern.compile( """/\*\*.*\S\*/""", Pattern.DOTALL).matcher(comment.text.trim).matches()
-
-  private def singleLineCommentRegex(comment: Token): Boolean =
-    comment.text.trim.matches( """//\S+.*""") && !comment.text.trim.matches( """///+""")
-
-  override def verify(ast: CompilationUnit): List[ScalastyleError] = {
-    ast.tokens
-      .filter(hasComment)
-      .map {
-      _.associatedWhitespaceAndComments.comments.map {
-        case x: SingleLineComment if singleLineCommentRegex(x.token) => Some(x.token.offset)
-        case x: MultiLineComment if multiLineCommentRegex(x.token) => Some(x.token.offset)
-        case x: ScalaDocComment if scalaDocPatternRegex(x.token) => Some(x.token.offset)
-        case _ => None
-      }.flatten
-    }.flatten.map(PositionError(_))
-  }
-
-
-  private def hasComment(x: Token) =
-    x.associatedWhitespaceAndComments != null && !x.associatedWhitespaceAndComments.comments.isEmpty
-
-}

http://git-wip-us.apache.org/repos/asf/spark/blob/044583a2/scalastyle-config.xml
----------------------------------------------------------------------
diff --git a/scalastyle-config.xml b/scalastyle-config.xml
index c54f8b7..0ff5217 100644
--- a/scalastyle-config.xml
+++ b/scalastyle-config.xml
@@ -141,5 +141,5 @@
  <check level="error" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
  <check level="error" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
  <check level="error" class="org.apache.spark.scalastyle.NonASCIICharacterChecker" enabled="true"></check>
- <check level="error" class="org.apache.spark.scalastyle.SparkSpaceAfterCommentStartChecker" enabled="true"></check>
+ <check level="error" class="org.scalastyle.scalariform.SpaceAfterCommentStartChecker" enabled="true"></check>
 </scalastyle>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org