propensive / fury-old

A new build tool for JVM languages
Apache License 2.0
413 stars 34 forks source link

tidy up all regular expressions #133

Closed propensive closed 5 years ago

propensive commented 5 years ago

Fury uses a number of different datatypes and values which can be used as input on the command line, or in the layer.fury file. These are dotted through the source code (but mainly in the data.scala file, but should be brought into the same place, and made as consistent as possible.

We should decide upon an appropriate regex for most identifier types (project, module, repo, etc), and use the same regex for each of these. For the design of the regexes, simpler is preferable.

Finally, a variety of positive and negative regex tests should be written to check these.

PawelLipski commented 5 years ago

For reference, that's the state as of commit 2cff2092:

➜  fury git:(master) ✗ git --no-pager grep -n '\<r"' '*.scala' 
src/core/data.scala:87:      case r"$g@([\.\-_a-zA-Z0-9]*)\:$a@([\.\-_a-zA-Z0-9]*)\:$v@([\.\-_a-zA-Z0-9]*)" =>
src/core/data.scala:116:          case r"version.number=$version@(.*)$$" =>
src/core/data.scala:154:    case r"$org@([a-z][a-z0-9_\-\.]*):$id@([a-z][a-z0-9_\-\.]*):$version@([0-9a-z][A-Za-z0-9_\-\.]*)" =>
src/core/data.scala:543:      case r"$projectId@([a-z][a-z0-9\-]*[a-z0-9])\/$moduleId@([a-z][a-z0-9\-]*[a-z0-9])" =>
src/core/data.scala:545:      case r"[a-z][a-z0-9\-]*[a-z0-9]" =>
src/core/data.scala:573:    case r"[a-z0-9\-\.]*[a-z0-9]$$" =>
src/core/data.scala:605:    case r"gh:$group@([A-Za-z0-9_\-\.]+)/$project@([A-Za-z0-9\._\-]+)" =>
src/core/data.scala:607:    case r"gl:$group@([A-Za-z0-9_\-\.]+)/$project@([A-Za-z0-9\._\-]+)" =>
src/core/data.scala:609:    case r"bb:$group@([A-Za-z0-9_\-\.]+)/$project@([A-Za-z0-9\._\-]+)" =>
src/core/data.scala:739:    case r"git@github.com:$group@(.*)/$project@(.*)\.git"    => s"gh:$group/$project"
src/core/data.scala:740:    case r"git@bitbucket.com:$group@(.*)/$project@(.*)\.git" => s"bb:$group/$project"
src/core/data.scala:741:    case r"git@gitlab.com:$group@(.*)/$project@(.*)\.git"    => s"gl:$group/$project"
src/core/data.scala:746:    case r".*/$project@([^\/]*).git" => Success(RepoId(project))
src/core/data.scala:763:    case r"$repo@([a-z0-9\.\-]*[a-z0-9]):$schema@([a-zA-Z0-9\-\.]*[a-zA-Z0-9])$$" =>
src/core/data.scala:936:    case r"shared:$path@(.*)" =>
src/core/data.scala:938:    case r"$repo@([a-z][a-z0-9\.\-]*[a-z0-9]):$path@(.*)" =>
src/core/data.scala:940:    case r"$path@(.*)" => Some(LocalSource(Path(path)))
src/core/diff.scala:104:    if (l == r) Nil else List(Difference(msg"value", msg"", msg"$l", msg"$r"))
src/core/diff.scala:111:    (l, r) => if (l == r) Nil else List(Difference(msg"ref", msg"", msg"$l", msg"$r"))
src/core/diff.scala:114:    (l, r) => if (l == r) Nil else List(Difference(msg"source", msg"", msg"$l", msg"$r"))
src/core/json.scala:40:    "\"" + string.replaceAll("\n", "\\n").replaceAll("\r", "\\r").replaceAll("\"", "\\\"") + "\""
src/core/tables.scala:47:    case s @ r"X.*" => Ansi.brightYellow("-" + s)
src/core/tables.scala:48:    case s @ r"D.*" => Ansi.yellow("-" + s)
src/core/tables.scala:49:    case s @ r"J.*" => Ansi.magenta("-" + s)
src/core/tables.scala:50:    case s @ r"Y.*" => Ansi.red("-" + s)
src/ogdl/fury/io/Path.scala:38:    case r"""$dir@([^*?:;,&|"\%<>]*)/""" =>
src/strings/strings.scala:56:      .map { case (l, r) => s"$l$r" }