Browse Source

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>
Sebastiaan van Stijn 6 years ago
parent
commit
a0d58b2248

+ 1 - 1
integration-cli/docker_cli_build_test.go

@@ -3427,7 +3427,7 @@ func (s *DockerSuite) TestBuildLabelsCache(c *testing.T) {
 func (s *DockerSuite) TestBuildNotVerboseSuccess(c *testing.T) {
 func (s *DockerSuite) TestBuildNotVerboseSuccess(c *testing.T) {
 	// This test makes sure that -q works correctly when build is successful:
 	// 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.
 	// 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")
 	buildFlags := cli.WithFlags("-q")
 
 
 	tt := []struct {
 	tt := []struct {

+ 2 - 2
integration-cli/docker_cli_by_digest_test.go

@@ -22,8 +22,8 @@ import (
 var (
 var (
 	remoteRepoName  = "dockercli/busybox-by-dgst"
 	remoteRepoName  = "dockercli/busybox-by-dgst"
 	repoName        = fmt.Sprintf("%s/%s", privateRegistryURL, remoteRepoName)
 	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) {
 func setupImage(c *testing.T) (digest.Digest, error) {

+ 1 - 1
integration-cli/docker_cli_import_test.go

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

+ 1 - 1
integration-cli/docker_cli_registry_user_agent_test.go

@@ -45,7 +45,7 @@ func regexpCheckUA(c *testing.T, ua string) {
 	// check upstreamUA looks correct
 	// check upstreamUA looks correct
 	// Expecting something like:  Docker-Client/1.11.0-dev (linux)
 	// Expecting something like:  Docker-Client/1.11.0-dev (linux)
 	upstreamUA := unescapeBackslashSemicolonParens(upstreamUAEscaped)
 	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)
 	bMatchUpstreamUA := reUpstreamUA.MatchString(upstreamUA)
 	assert.Assert(c, bMatchUpstreamUA, "(Upstream) Docker Client User-Agent malformed")
 	assert.Assert(c, bMatchUpstreamUA, "(Upstream) Docker Client User-Agent malformed")
 }
 }

+ 1 - 1
integration-cli/docker_cli_save_load_test.go

@@ -236,7 +236,7 @@ func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *testing.T) {
 	lines := strings.Split(strings.TrimSpace(out), "\n")
 	lines := strings.Split(strings.TrimSpace(out), "\n")
 	var actual []string
 	var actual []string
 	for _, l := range lines {
 	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"))
 			actual = append(actual, strings.TrimSuffix(l, ".json"))
 		}
 		}
 	}
 	}