Skip to content

Commit 0519c01

Browse files
authored
Merge pull request #16 from pedrocodacy/add-duplication-api-FT-4900
added duplication tool trait and case classes for configs and results of duplication
2 parents 3a65713 + 0ea7347 commit 0519c01

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

.circleci/config.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ jobs:
1313
- save_cache:
1414
key: scala-library-dependencies-{{ checksum "build.sbt" }}
1515
paths: [ "~/.m2", "~/.ivy2", "~/.cache/coursier" ]
16-
- run: sbt coverage test
17-
- run: sbt coverageReport
18-
- run: sbt coverageAggregate
19-
- run: sbt codacyCoverage
16+
- run: ./scripts/test.sh

build.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ crossScalaVersions := Seq(scalaVersion.value, "2.12.4")
88

99
organization := "com.codacy"
1010

11-
libraryDependencies += "org.specs2" %% "specs2-core" % "4.0.2" % Test
11+
libraryDependencies ++= Seq(
12+
"org.specs2" %% "specs2-core" % "4.0.2" % Test
13+
)
1214

1315
organizationName := "Codacy"
1416

scripts/test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ -n "$1" ]; then
6+
export CODACY_PROJECT_TOKEN="$1"
7+
fi
8+
9+
sbt coverage test
10+
sbt coverageReport
11+
sbt coverageAggregate
12+
13+
if [ -z "$CODACY_PROJECT_TOKEN" ]; then
14+
echo "CODACY_PROJECT_TOKEN not found. Skipping send coverage to Codacy."
15+
else
16+
sbt codacyCoverage
17+
fi

src/main/scala/codacy/docker/api/DockerApi.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,15 @@ object MetricsConfiguration {
5050

5151
trait Value extends Any
5252
}
53+
54+
case class DuplicationConfiguration(language: Option[Language],
55+
params: Option[Map[DuplicationConfiguration.Key, DuplicationConfiguration.Value]])
56+
57+
object DuplicationConfiguration {
58+
59+
case class Key(value: String) extends AnyVal
60+
61+
trait Value extends Any
62+
}
63+
64+
case class CodacyConfiguration(duplication: DuplicationConfiguration)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package codacy.docker.api.duplication
2+
3+
case class DuplicationCloneFile(filePath: String, startLine: Int, endLine: Int)
4+
5+
case class DuplicationClone(cloneLines: String, nrTokens: Int, nrLines: Int, files: Seq[DuplicationCloneFile])
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package codacy.docker.api.duplication
2+
3+
import codacy.docker.api.{DuplicationConfiguration, Source}
4+
import com.codacy.api.dtos.Language
5+
6+
import scala.util.Try
7+
8+
trait DuplicationTool {
9+
def apply(path: Source.Directory,
10+
language: Option[Language],
11+
options: Map[DuplicationConfiguration.Key, DuplicationConfiguration.Value]): Try[List[DuplicationClone]]
12+
}
13+
14+
object DuplicationTool {
15+
16+
case class Name(value: String) extends AnyVal {
17+
override def toString: String = value
18+
}
19+
20+
}

0 commit comments

Comments
 (0)