Skip to content
Permalink
Browse files

UCS_0_0 and UCS_0_1

  • Loading branch information...
Michal Nowak
Michal Nowak committed Mar 14, 2019
1 parent 1e15121 commit 02a3ade4adb9892b4adff14510d466747c4dd22f
Showing with 49 additions and 8 deletions.
  1. +1 −1 QL/Source/Shared/LowerCamelCaseString.qll
  2. +16 −0 QL/Source/Shared/PascalCaseString.qll
  3. +8 −7 QL/Source/UCS_0_0.ql
  4. +24 −0 QL/Source/UCS_0_1.ql
@@ -11,6 +11,6 @@ class LowerCamelCaseString extends string
bindingset[this]
LowerCamelCaseString()
{
this.regexpMatch("[a-z]+((\\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?")
this.regexpMatch("^[a-z]+(?:[A-Z0-9][a-z0-9]+)*$")
}
}
@@ -0,0 +1,16 @@
import csharp

/**
* Pascal case string.
*/
class PascalCaseString extends string
{
/**
* PascalCaseString constructor.
*/
bindingset[this]
PascalCaseString()
{
this.regexpMatch("^[A-Z][a-z]+(?:[A-Z][a-z]+)*$")
}
}
@@ -7,18 +7,19 @@
* @id UCS_0_0
*/

import Shared.MutableLocalVariable
import Shared.LowerCamelCaseString
import Shared.PascalCaseString

from
MutableLocalVariable mutableLocalVariable
Class c

where
not mutableLocalVariable.getName() instanceof LowerCamelCaseString
c.fromSource()
and
not c.getName() instanceof PascalCaseString

select
mutableLocalVariable, "Mutable local variable '$@' should follow PascalCasing.",
mutableLocalVariable, mutableLocalVariable.toString()
c, "Class '$@' name should follow PascalCasing.",
c, c.toString()

order
by mutableLocalVariable asc
by c asc
@@ -0,0 +1,24 @@
/**
* @name UCS_0_1
* @description Mutable local variable should follow lowerCamelCase.
* @kind problem
* @problem.severity error
* @precision very high
* @id UCS_0_1
*/

import Shared.MutableLocalVariable
import Shared.LowerCamelCaseString

from
MutableLocalVariable mutableLocalVariable

where
not mutableLocalVariable.getName() instanceof LowerCamelCaseString

select
mutableLocalVariable, "Mutable local variable '$@' name should follow PascalCasing.",
mutableLocalVariable, mutableLocalVariable.toString()

order
by mutableLocalVariable asc

0 comments on commit 02a3ade

Please sign in to comment.
You can’t perform that action at this time.