Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into to/#93-battery-storag…
Browse files Browse the repository at this point in the history
…e-conversion

# Conflicts:
#	src/main/scala/edu/ie3/powerFactory2psdm/util/Formatter.scala
  • Loading branch information
t-ober committed Sep 8, 2021
2 parents f1e0ffd + e8569c5 commit 23a88bd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 41 deletions.
8 changes: 2 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

# use LF line endings within the project
* text eol=lf
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'java' // java support
id 'scala' // scala support
id 'pmd' //code check, working on source code
id 'com.diffplug.spotless' version '5.14.3'//code format
id 'com.diffplug.spotless' version '5.15.0'//code format
id "org.sonarqube" version "3.3" // sonarqube
id 'org.scoverage' version '7.0.0' // Code coverage plugin for scala
id "com.github.maiflai.scalatest" version "0.31" // run scalatest without specific spec task
Expand Down Expand Up @@ -46,9 +46,9 @@ dependencies {
implementation "io.circe:circe-parser_${scalaVersion}:${circeVersion}"

// https://mvnrepository.com/artifact/org.scalameta/scalafmt-interfaces
implementation group: 'org.scalameta', name: 'scalafmt-interfaces', version: '3.0.1'
implementation group: 'org.scalameta', name: 'scalafmt-interfaces', version: '3.0.2'
// https://mvnrepository.com/artifact/org.scalameta/scalafmt-dynamic
implementation group: 'org.scalameta', name: "scalafmt-dynamic_${scalaVersion}", version: '3.0.1'
implementation group: 'org.scalameta', name: "scalafmt-dynamic_${scalaVersion}", version: '3.0.2'


implementation('com.github.ie3-institute:PowerSystemDataModel:2.0.1') {
Expand Down
63 changes: 31 additions & 32 deletions src/main/scala/edu/ie3/powerFactory2psdm/util/Formatter.scala
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/

package edu.ie3.powerFactory2psdm.util

import java.nio.file.{Files, Paths}
import org.scalafmt.interfaces.Scalafmt

import java.io.File

object Formatter {

def format(str: String, fmtPath: Option[String]): String = {
val classLoader = this.getClass.getClassLoader
val scalafmt = Scalafmt.create(classLoader)
val configFile = new File(classLoader.getResource(".scalafmt.conf").getFile)
val defaultConfigPath =
Paths.get(configFile.getPath)
val defaultConfig =
if (Files.exists(defaultConfigPath)) defaultConfigPath else Paths.get("")
val config = fmtPath.fold(defaultConfig)(Paths.get(_))
val result = scalafmt
.withRespectVersion(false)
.format(config, Paths.get("Nil.scala"), str)
scalafmt.clear()
result
}

}
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/

package edu.ie3.powerFactory2psdm.util

import java.nio.file.{Files, Paths}
import org.scalafmt.interfaces.Scalafmt
import java.io.File

object Formatter {

def format(str: String, fmtPath: Option[String]): String = {
val classLoader = this.getClass.getClassLoader
val scalafmt = Scalafmt.create(classLoader)
val configFile = new File(classLoader.getResource(".scalafmt.conf").getFile)
val defaultConfigPath =
Paths.get(configFile.getPath)
val defaultConfig =
if (Files.exists(defaultConfigPath)) defaultConfigPath else Paths.get("")
val config = fmtPath.fold(defaultConfig)(Paths.get(_))
val result = scalafmt
.withRespectVersion(false)
.format(config, Paths.get("Nil.scala"), str)
scalafmt.clear()
result
}

}

0 comments on commit 23a88bd

Please sign in to comment.