Skip to content

Commit 2770cc5

Browse files
author
Johann Egger
committed
First version that contains all the types we need so far
0 parents  commit 2770cc5

File tree

8 files changed

+139
-0
lines changed

8 files changed

+139
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/RUNNING_PID
2+
/logs/
3+
/project/*-shim.sbt
4+
/project/project/
5+
/project/target/
6+
/target/
7+
/.idea/
8+
/libexec/
9+
/bin/

build.sbt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name := """codacy-plugins-api"""
2+
3+
version := "0.1.0-SNAPSHOT"
4+
5+
scalaVersion := "2.11.8"
6+
7+
crossScalaVersions := Seq("2.10.6", scalaVersion.value)
8+
9+
organization := "com.codacy"

project/build.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Activator-generated Properties
2+
#Tue Jul 19 17:27:06 EEST 2016
3+
template.uuid=e17acfbb-1ff5-41f5-b8cf-2c40be6a8340
4+
sbt.version=0.13.12
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package codacy.docker.api
2+
3+
sealed trait Source extends Any{
4+
def path:String
5+
override def toString: String = path
6+
}
7+
8+
object Source{
9+
case class Directory(path: String) extends AnyVal with Source
10+
case class File(path: String) extends AnyVal with Source
11+
}
12+
13+
case class ErrorMessage(value: String) extends AnyVal{
14+
override def toString: String = value
15+
}
16+
17+
case class Configuration(tools: Set[Tool.Configuration], files: Option[Set[Source.File]])
18+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package codacy.docker.api
2+
3+
object Parameter {
4+
5+
sealed trait Value extends Any{
6+
def value:Any
7+
override def toString: String = value.toString
8+
}
9+
10+
object Value{
11+
12+
def unapply(arg: Value): Option[Any] = Some(arg.value)
13+
14+
def apply(value:String):Value = Str(value)
15+
def apply(value:BigDecimal):Value = Num(value)
16+
def apply(value:Boolean):Value = Bool(value)
17+
def apply(value:List[Value]):Value = Arr(value)
18+
19+
case class Arr(value:List[Parameter.Value]) extends AnyVal with Parameter.Value
20+
case class Str(value:String) extends Parameter.Value
21+
case class Bool(value:Boolean) extends Parameter.Value
22+
case class Num(value:BigDecimal) extends Parameter.Value
23+
}
24+
25+
case class Name(value: String) extends AnyVal{
26+
override def toString: String = value
27+
}
28+
29+
case class Definition(name: Parameter.Name, value: Parameter.Value)
30+
31+
case class Specification(name: Parameter.Name, default: Parameter.Value)
32+
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package codacy.docker.api
2+
3+
object Pattern {
4+
5+
case class Id(value: String) extends AnyVal{
6+
override def toString: String = value
7+
}
8+
9+
case class Definition(patternId: Pattern.Id, parameters: Option[Set[Parameter.Definition]])
10+
11+
case class Specification(patternId: Pattern.Id, level:Result.Level, category: Category, parameters: Option[Set[Parameter.Specification]])
12+
13+
type Category = Category.Value
14+
object Category extends Enumeration{
15+
val Security, CodeStyle, ErrorProne, Performance, Compatibility, UnusedCode,
16+
//Deprecated
17+
Complexity, BestPractice, Comprehensibility, Duplication, Documentation = Value
18+
}
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package codacy.docker.api
2+
3+
sealed trait Result
4+
5+
object Result {
6+
7+
case class Message(value: String) extends AnyVal{
8+
override def toString: String = value
9+
}
10+
11+
case class Line(value: Int) extends AnyVal{
12+
override def toString: String = value.toString
13+
}
14+
15+
case class Issue(file: Source.File, message: Result.Message, patternId: Pattern.Id, line: Result.Line) extends Result
16+
17+
case class FileError(file: Source.File, message: Option[ErrorMessage]) extends Result
18+
19+
type Level = Level.Value
20+
21+
object Level extends Enumeration{
22+
val Err = Value("Error")
23+
val Warn = Value("Warning")
24+
val Info = Value("Info")
25+
}
26+
}
27+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package codacy.docker.api
2+
3+
import scala.util.Try
4+
5+
trait Tool {
6+
def apply(source: Source.Directory, configuration: Option[List[Pattern.Definition]], files: Option[Set[Source.File]])
7+
(implicit specification: Tool.Specification): Try[List[Result]]
8+
}
9+
10+
object Tool {
11+
12+
case class Name(value: String) extends AnyVal{
13+
override def toString: String = value
14+
}
15+
16+
case class Configuration(name: Tool.Name, patterns: Option[List[Pattern.Definition]])
17+
18+
//there are other fields like name and description but i don't care about them inside the tool
19+
case class Specification(name: Tool.Name, patterns: Set[Pattern.Specification])
20+
}

0 commit comments

Comments
 (0)