Skip to content

Commit 92790ec

Browse files
authored
Merge pull request #46 from codacy/add-copy
feature: Add copy to Specification :breaking:
2 parents e51d679 + 32b0aee commit 92790ec

File tree

5 files changed

+22
-92
lines changed

5 files changed

+22
-92
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
* @lolgab @ljmf00 @andreaTP @rtfpessoa @bmbferreira @DReigada @pedrocodacy
2-
3-
*.yml @h314to @paulopontesm
4-
1+
* @codacy/toss

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
val scala211 = "2.11.12"
2-
val scala212 = "2.12.8"
2+
val scala212 = "2.12.10"
33
val scala213 = "2.13.1"
44

55
name := "codacy-plugins-api"
@@ -9,7 +9,7 @@ scalaVersion := scala212
99

1010
crossScalaVersions := Seq(scala211, scala212, scala213)
1111

12-
libraryDependencies ++= Seq("org.specs2" %% "specs2-core" % "4.7.1" % Test)
12+
libraryDependencies ++= Seq("org.specs2" %% "specs2-core" % "4.8.3" % Test)
1313

1414
unmanagedSourceDirectories in Compile += {
1515
val sourceDir = (sourceDirectory in Compile).value

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.2
1+
sbt.version=1.3.6

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
resolvers += Resolver.jcenterRepo
22

3-
addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "17.1.2")
3+
addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "17.1.5")

src/main/scala/com/codacy/plugins/api/results/Pattern.scala

Lines changed: 17 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -28,95 +28,28 @@ object Pattern {
2828

2929
case class Definition(patternId: Pattern.Id, parameters: Option[Set[Parameter.Definition]])
3030

31-
trait Specification {
32-
val patternId: Pattern.Id
33-
val level: Result.Level
34-
val category: Category
35-
val subcategory: Option[Subcategory]
36-
val parameters: Option[Set[Parameter.Specification]]
37-
val languages: Option[Set[Language]]
31+
case class Specification(patternId: Pattern.Id,
32+
level: Result.Level,
33+
category: Specification.Category,
34+
subcategory: Option[Specification.Subcategory],
35+
parameters: Option[Set[Parameter.Specification]],
36+
languages: Option[Set[Language]] = None) {
37+
require(subcategory.isEmpty || category == Specification.Category.Security,
38+
"Security is the only category having subcategories")
3839
}
39-
4040
object Specification {
41-
private case class SpecificationImpl(patternId: Pattern.Id,
42-
level: Result.Level,
43-
category: Category,
44-
subcategory: Option[Subcategory],
45-
parameters: Option[Set[Parameter.Specification]],
46-
languages: Option[Set[Language]] = None)
47-
extends Specification
48-
49-
def unapply(s: Pattern.Specification): Option[(Pattern.Id,
50-
Result.Level,
51-
Category,
52-
Option[Subcategory],
53-
Option[Set[Parameter.Specification]],
54-
Option[Set[Language]])] = s match {
55-
case si: SpecificationImpl =>
56-
SpecificationImpl.unapply(si)
41+
type Category = Category.Value
42+
object Category extends Enumeration {
43+
val Security, CodeStyle, ErrorProne, Performance, Compatibility, UnusedCode, Complexity, BestPractice,
44+
Comprehensibility, Duplication, Documentation = Value
5745
}
5846

59-
def apply(patternId: Pattern.Id,
60-
level: Result.Level,
61-
category: Category,
62-
subcategory: Option[Subcategory],
63-
parameters: Option[Set[Parameter.Specification]],
64-
languages: Option[Set[Language]] = None): Specification = {
65-
val spec = SpecificationImpl(patternId, level, category, subcategory, parameters, languages)
66-
67-
spec.subcategory match {
68-
case Some(sc) =>
69-
sc match {
70-
case Subcategory.XSS | Subcategory.Input_validation | Subcategory.File_Access | Subcategory.HTTP |
71-
Subcategory.Cookies | Subcategory.Unexpected_behaviour | Subcategory.Mass_assignment |
72-
Subcategory.Insecure_Storage | Subcategory.Insecure_modules_libraries | Subcategory.Visibility |
73-
Subcategory.CSRF | Subcategory.Android | Subcategory.Malicious_code | Subcategory.Cryptography |
74-
Subcategory.Command_Injection | Subcategory.Firefox_OS | Subcategory.Auth | Subcategory.DoS |
75-
Subcategory.SQL_Injection | Subcategory.Routes | Subcategory.Regex | Subcategory.SSL | Subcategory.Other
76-
if category == Category.Security =>
77-
spec
47+
type Subcategory = Subcategory.Value
7848

79-
case _ => throw new Exception("invalid sub category")
80-
}
81-
case None => spec
82-
}
49+
object Subcategory extends Enumeration {
50+
val XSS, InputValidation, FileAccess, HTTP, Cookies, UnexpectedBehaviour, MassAssignment, InsecureStorage,
51+
InsecureModulesLibraries, Visibility, CSRF, Android, MaliciousCode, Cryptography, CommandInjection, FirefoxOS,
52+
Auth, DoS, SQLInjection, Routes, Regex, SSL, Other = Value
8353
}
8454
}
85-
86-
type Category = Category.Value
87-
88-
object Category extends Enumeration {
89-
90-
val Security, CodeStyle, ErrorProne, Performance, Compatibility, UnusedCode, Complexity, BestPractice,
91-
Comprehensibility, Duplication, Documentation = Value
92-
}
93-
94-
type Subcategory = Subcategory.Value
95-
96-
object Subcategory extends Enumeration {
97-
val XSS = Value("XSS")
98-
val Input_validation = Value("Input validation")
99-
val File_Access = Value("File Access")
100-
val HTTP = Value("HTTP")
101-
val Cookies = Value("Cookies")
102-
val Unexpected_behaviour = Value("Unexpected behaviour")
103-
val Mass_assignment = Value("Mass assignment")
104-
val Insecure_Storage = Value("Insecure Storage")
105-
val Insecure_modules_libraries = Value("Insecure modules/libraries")
106-
val Visibility = Value("Visibility")
107-
val CSRF = Value("CSRF")
108-
val Android = Value("Android")
109-
val Malicious_code = Value("Malicious code")
110-
val Cryptography = Value("Cryptography")
111-
val Command_Injection = Value("Command Injection")
112-
val Firefox_OS = Value("Firefox OS")
113-
val Auth = Value("Auth")
114-
val DoS = Value("DoS")
115-
val SQL_Injection = Value("SQL Injection")
116-
val Routes = Value("Routes")
117-
val Regex = Value("Regex")
118-
val SSL = Value("SSL")
119-
val Other = Value("Other")
120-
}
121-
12255
}

0 commit comments

Comments
 (0)