I want to write a custom regex for scalastyle so that it could catch cases when a developer forget a whitespaces before and after operators, but the regex shouldn't catch anything inside the string. Let's see the examples:
val asdf123=sdf // should be catched
val as = sd // shouldn't be watched
val a /=10 // should be
def check() =as // should be
def check= { // should be
val isEqual = a == b // shouldn't
val b += 2 // shouldn't
val e = true!=false //should
val a = 2!=3 //dhould
val a = 2 != 3 // shouldn't
val a = 2 <= 3 // shouldn't
val a = b&&s // should
val a = b % s // shouldn't
val a/= s // should
val a /= b // shouldn't
def validateSeq[T](input: Seq[T], validationFunc: (T =>Option[Message])*): Either[ValidationError, Seq[T]] = { // should, because of =>Option
val url = "/docs/swagger-ui/index.html?url=/docs/swagger" // shouldn't because =/ is inside string
"Access-Control-Allow-Credentials" // shouldn't
Here is what I have so far, but it doesn't handle strings properly:
([a-zA-Z0-9]+([-+&<>!=\/&%]+)[a-zA-Z0-9]|[a-zA-Z0-9]([-+&<>!=\/&%]+)|([-+&<>!=\/&%]+)[a-zA-Z0-9])