You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/12/23 09:00:01 UTC

[jira] [Commented] (KAFKA-2620) Introduce Scalariform

    [ https://issues.apache.org/jira/browse/KAFKA-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16302289#comment-16302289 ] 

ASF GitHub Bot commented on KAFKA-2620:
---------------------------------------

ijuma closed pull request #284: KAFKA-2620: Introduce Scalariform
URL: https://github.com/apache/kafka/pull/284
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/build.gradle b/build.gradle
index 313d229fe70..28b0e3f3117 100644
--- a/build.gradle
+++ b/build.gradle
@@ -236,6 +236,7 @@ project(':core') {
   println "Building project 'core' with Scala version $scalaVersion"
 
   apply plugin: 'scala'
+  apply from: file("$rootDir/gradle/scalariform.gradle")
   archivesBaseName = "kafka_${baseScalaVersion}"
 
   dependencies {
diff --git a/gradle/resources/scalariform.properties b/gradle/resources/scalariform.properties
new file mode 100644
index 00000000000..40aaa3efc68
--- /dev/null
+++ b/gradle/resources/scalariform.properties
@@ -0,0 +1,22 @@
+alignParameters=false
+alignArguments=false
+alignSingleLineCaseStatements=false
+alignSingleLineCaseStatements.maxArrowIndent=40
+compactControlReadability=false
+compactStringConcatenation=false
+doubleIndentClassDeclaration=true
+formatXml=true
+indentLocalDefs=false
+indentPackageBlocks=true
+indentSpaces=2
+indentWithTabs=false
+multilineScaladocCommentsStartOnFirstLine=false
+placeScaladocAsterisksBeneathSecondAsterisk=false
+preserveSpaceBeforeArguments=false
+preserveDanglingCloseParenthesis=false
+rewriteArrowSymbols=false
+spaceBeforeColon=false
+spaceInsideBrackets=false
+spaceInsideParentheses=false
+spacesWithinPatternBinders=true
+spacesAroundMultiImports=false
diff --git a/gradle/scalariform.gradle b/gradle/scalariform.gradle
new file mode 100644
index 00000000000..fb4f3743244
--- /dev/null
+++ b/gradle/scalariform.gradle
@@ -0,0 +1,32 @@
+buildscript {
+    repositories {
+        repositories {
+            jcenter()
+        }
+    }
+
+    dependencies {
+        classpath "org.scalariform:scalariform_$baseScalaVersion:0.1.7"
+    }
+}
+
+task formatScala() {
+    def scalaVersion = "$scalaVersion"
+    def prefsFile = "$rootDir/gradle/resources/scalariform.properties"
+
+    doLast {
+        // Format Scala
+        def prefs = scalariform.formatter.preferences.PreferencesImporterExporter$.newInstance().loadPreferences(prefsFile)
+        project.fileTree(project.projectDir).include("**/*.scala").each { File f ->
+            String contents = f.text
+            logger.debug("Formatting $f")
+            def formattedContents = scalariform.formatter.ScalaFormatter$.newInstance().format(contents, prefs, scala.Option.apply("\n"), 0, scalaVersion)
+            if (!formattedContents.equals(contents)) {
+                logger.println("Formatted $f")
+            }
+            f.write(formattedContents, "UTF-8")
+        }
+    }
+}
+//compileScala.dependsOn('formatScala')
+//compileTestScala.dependsOn('formatScala')


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Introduce Scalariform
> ---------------------
>
>                 Key: KAFKA-2620
>                 URL: https://issues.apache.org/jira/browse/KAFKA-2620
>             Project: Kafka
>          Issue Type: Bug
>          Components: build
>            Reporter: Grant Henke
>            Assignee: Grant Henke
>
> Many of our reviews include nit comments related to Scala style. Adding [Scalariform|https://github.com/daniel-trinh/scalariform] allows us to reformat the code based on configurable standards at build time, ensuring uniform readability and a short review/commit cycle. 
> I expect this will have some discussion around the rules we would like to include, and if we actually want to adopt this. I will submit a sample patch to start the discussion.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)