integration-cli: use raw strings for regexes (gosimple)

```
14:26:43 integration-cli/docker_cli_build_test.go:3430:15: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
14:26:43 	outRegexp := regexp.MustCompile("^(sha256:|)[a-z0-9]{64}\\n$")
14:26:43 	             ^
14:26:43 integration-cli/docker_cli_by_digest_test.go:26:20: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
14:26:43 	pushDigestRegex = regexp.MustCompile("[\\S]+: digest: ([\\S]+) size: [0-9]+")
14:26:43 	                  ^
14:26:43 integration-cli/docker_cli_by_digest_test.go:27:20: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
14:26:43 	digestRegex     = regexp.MustCompile("Digest: ([\\S]+)")
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-08-05 16:53:46 +02:00
parent fdc1b22030
commit a0d58b2248
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 6 additions and 6 deletions

View File

@ -3427,7 +3427,7 @@ func (s *DockerSuite) TestBuildLabelsCache(c *testing.T) {
func (s *DockerSuite) TestBuildNotVerboseSuccess(c *testing.T) {
// This test makes sure that -q works correctly when build is successful:
// stdout has only the image ID (long image ID) and stderr is empty.
outRegexp := regexp.MustCompile("^(sha256:|)[a-z0-9]{64}\\n$")
outRegexp := regexp.MustCompile(`^(sha256:|)[a-z0-9]{64}\n$`)
buildFlags := cli.WithFlags("-q")
tt := []struct {

View File

@ -22,8 +22,8 @@ import (
var (
remoteRepoName = "dockercli/busybox-by-dgst"
repoName = fmt.Sprintf("%s/%s", privateRegistryURL, remoteRepoName)
pushDigestRegex = regexp.MustCompile("[\\S]+: digest: ([\\S]+) size: [0-9]+")
digestRegex = regexp.MustCompile("Digest: ([\\S]+)")
pushDigestRegex = regexp.MustCompile(`[\S]+: digest: ([\S]+) size: [0-9]+`)
digestRegex = regexp.MustCompile(`Digest: ([\S]+)`)
)
func setupImage(c *testing.T) (digest.Digest, error) {

View File

@ -110,7 +110,7 @@ func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) {
split := strings.Split(out, "\n")
assert.Equal(c, len(split), 3, "expected 3 lines from image history")
r := regexp.MustCompile("[\\s]{2,}")
r := regexp.MustCompile(`[\s]{2,}`)
split = r.Split(split[1], -1)
assert.Equal(c, message, split[3], "didn't get expected value in commit message")

View File

@ -45,7 +45,7 @@ func regexpCheckUA(c *testing.T, ua string) {
// check upstreamUA looks correct
// Expecting something like: Docker-Client/1.11.0-dev (linux)
upstreamUA := unescapeBackslashSemicolonParens(upstreamUAEscaped)
reUpstreamUA := regexp.MustCompile("^\\(Docker-Client/[0-9A-Za-z+]")
reUpstreamUA := regexp.MustCompile(`^\(Docker-Client/[0-9A-Za-z+]`)
bMatchUpstreamUA := reUpstreamUA.MatchString(upstreamUA)
assert.Assert(c, bMatchUpstreamUA, "(Upstream) Docker Client User-Agent malformed")
}

View File

@ -236,7 +236,7 @@ func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *testing.T) {
lines := strings.Split(strings.TrimSpace(out), "\n")
var actual []string
for _, l := range lines {
if regexp.MustCompile("^[a-f0-9]{64}\\.json$").Match([]byte(l)) {
if regexp.MustCompile(`^[a-f0-9]{64}\.json$`).Match([]byte(l)) {
actual = append(actual, strings.TrimSuffix(l, ".json"))
}
}