Skip to content

Commit

Permalink
Stop using backticks for emphasis (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Dec 13, 2023
1 parent 69526ee commit 9259d0e
Show file tree
Hide file tree
Showing 27 changed files with 219 additions and 207 deletions.
19 changes: 8 additions & 11 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,27 @@ func (cli *CLI) Run(args []string) int {

func unknownOptionHandler(option string, arg flags.SplitArgument, args []string) ([]string, error) {
if option == "debug" {
return []string{}, errors.New("`debug` option was removed in v0.8.0. Please set `TFLINT_LOG` environment variables instead")
}
if option == "fast" {
return []string{}, errors.New("`fast` option was removed in v0.9.0. The `aws_instance_invalid_ami` rule is already fast enough")
return []string{}, errors.New("--debug option was removed in v0.8.0. Please set TFLINT_LOG environment variables instead")
}
if option == "error-with-issues" {
return []string{}, errors.New("`error-with-issues` option was removed in v0.9.0. The behavior is now default")
return []string{}, errors.New("--error-with-issues option was removed in v0.9.0. The behavior is now default")
}
if option == "quiet" || option == "q" {
return []string{}, errors.New("`quiet` option was removed in v0.11.0. The behavior is now default")
return []string{}, errors.New("--quiet option was removed in v0.11.0. The behavior is now default")
}
if option == "ignore-rule" {
return []string{}, errors.New("`ignore-rule` option was removed in v0.12.0. Please use `--disable-rule` instead")
return []string{}, errors.New("--ignore-rule option was removed in v0.12.0. Please use --disable-rule instead")
}
if option == "deep" {
return []string{}, errors.New("`deep` option was removed in v0.23.0. Deep checking is now a feature of the AWS plugin, so please configure the plugin instead")
return []string{}, errors.New("--deep option was removed in v0.23.0. Deep checking is now a feature of the AWS plugin, so please configure the plugin instead")
}
if option == "aws-access-key" || option == "aws-secret-key" || option == "aws-profile" || option == "aws-creds-file" || option == "aws-region" {
return []string{}, fmt.Errorf("`%s` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead", option)
return []string{}, fmt.Errorf("--%s option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead", option)
}
if option == "loglevel" {
return []string{}, errors.New("`loglevel` option was removed in v0.40.0. Please set `TFLINT_LOG` environment variables instead")
return []string{}, errors.New("--loglevel option was removed in v0.40.0. Please set TFLINT_LOG environment variables instead")
}
return []string{}, fmt.Errorf("`%s` is unknown option. Please run `tflint --help`", option)
return []string{}, fmt.Errorf(`--%s is unknown option. Please run "tflint --help"`, option)
}

func findWorkingDirs(opts Options) ([]string, error) {
Expand Down
8 changes: 4 additions & 4 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ func (cli *CLI) init(opts Options) int {

_, err := plugin.FindPluginPath(installCfg)
if os.IsNotExist(err) {
fmt.Fprintf(cli.outStream, "Installing `%s` plugin...\n", pluginCfg.Name)
fmt.Fprintf(cli.outStream, `Installing "%s" plugin...\n`, pluginCfg.Name)

sigchecker := plugin.NewSignatureChecker(installCfg)
if !sigchecker.HasSigningKey() {
_, _ = color.New(color.FgYellow).Fprintln(cli.outStream, "No signing key configured. Set `signing_key` to verify that the release is signed by the plugin developer")
_, _ = color.New(color.FgYellow).Fprintln(cli.outStream, `No signing key configured. Set "signing_key" to verify that the release is signed by the plugin developer`)
}

_, err = installCfg.Install()
if err != nil {
return fmt.Errorf("Failed to install a plugin; %w", err)
}

fmt.Fprintf(cli.outStream, "Installed `%s` (source: %s, version: %s)\n", pluginCfg.Name, pluginCfg.Source, pluginCfg.Version)
fmt.Fprintf(cli.outStream, `Installed "%s" (source: %s, version: %s)\n`, pluginCfg.Name, pluginCfg.Source, pluginCfg.Version)
continue
}

if err != nil {
return fmt.Errorf("Failed to find a plugin; %w", err)
}

fmt.Fprintf(cli.outStream, "Plugin `%s` is already installed\n", pluginCfg.Name)
fmt.Fprintf(cli.outStream, `Plugin "%s" is already installed\n`, pluginCfg.Name)
}

if opts.Recursive && !found {
Expand Down
10 changes: 5 additions & 5 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,31 +279,31 @@ func launchPlugins(config *tflint.Config, fix bool) (*plugin.Plugin, error) {
// VersionConstraints endpoint is available in tflint-plugin-sdk v0.14+.
return rulesetPlugin, fmt.Errorf(`Plugin "%s" SDK version is incompatible. Compatible versions: %s`, name, plugin.SDKVersionConstraints)
} else {
return rulesetPlugin, fmt.Errorf("Failed to get TFLint version constraints to `%s` plugin; %w", name, err)
return rulesetPlugin, fmt.Errorf(`Failed to get TFLint version constraints to "%s" plugin; %w`, name, err)
}
}
if !constraints.Check(tflint.Version) {
return rulesetPlugin, fmt.Errorf("Failed to satisfy version constraints; tflint-ruleset-%s requires %s, but TFLint version is %s", name, constraints, tflint.Version)
}

if err := ruleset.ApplyGlobalConfig(pluginConf); err != nil {
return rulesetPlugin, fmt.Errorf("Failed to apply global config to `%s` plugin; %w", name, err)
return rulesetPlugin, fmt.Errorf(`Failed to apply global config to "%s" plugin; %w`, name, err)
}
configSchema, err := ruleset.ConfigSchema()
if err != nil {
return rulesetPlugin, fmt.Errorf("Failed to fetch config schema from `%s` plugin; %w", name, err)
return rulesetPlugin, fmt.Errorf(`Failed to fetch config schema from "%s" plugin; %w`, name, err)
}
content := &hclext.BodyContent{}
if plugin, exists := config.Plugins[name]; exists {
var diags hcl.Diagnostics
content, diags = plugin.Content(configSchema)
if diags.HasErrors() {
return rulesetPlugin, fmt.Errorf("Failed to parse `%s` plugin config; %w", name, diags)
return rulesetPlugin, fmt.Errorf(`Failed to parse "%s" plugin config; %w`, name, diags)
}
}
err = ruleset.ApplyConfig(content, config.Sources())
if err != nil {
return rulesetPlugin, fmt.Errorf("Failed to apply config to `%s` plugin; %w", name, err)
return rulesetPlugin, fmt.Errorf(`Failed to apply config to "%s" plugin; %w`, name, err)
}

rulesets = append(rulesets, ruleset)
Expand Down
4 changes: 2 additions & 2 deletions cmd/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ type Options struct {
func (opts *Options) toConfig() *tflint.Config {
ignoreModules := map[string]bool{}
for _, module := range opts.IgnoreModules {
// For the backward compatibility, allow specifying like `source1,source2` style
// For the backward compatibility, allow specifying like "source1,source2" style
for _, m := range strings.Split(module, ",") {
ignoreModules[m] = true
}
}

varfiles := []string{}
for _, vf := range opts.Varfiles {
// For the backward compatibility, allow specifying like `varfile1,varfile2` style
// For the backward compatibility, allow specifying like "varfile1,varfile2" style
varfiles = append(varfiles, strings.Split(vf, ",")...)
}
if opts.Variables == nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func Test_toConfig(t *testing.T) {
},
},
{
Name: "multiple `--ignore-module`",
Name: "multiple --ignore-module",
Command: "./tflint --ignore-module module1 --ignore-module module2",
Expected: &tflint.Config{
CallModuleType: terraform.CallLocalModule,
Expand Down Expand Up @@ -140,7 +140,7 @@ func Test_toConfig(t *testing.T) {
},
},
{
Name: "multiple `--var-file`",
Name: "multiple --var-file",
Command: "./tflint --var-file example1.tfvars --var-file example2.tfvars",
Expected: &tflint.Config{
CallModuleType: terraform.CallLocalModule,
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ After declaring the `version` and `source`, `tflint --init` can automatically in

```console
$ tflint --init
Installing `foo` plugin...
Installed `foo` (source: github.com/org/tflint-ruleset-foo, version: 0.1.0)
Installing "foo" plugin...
Installed "foo" (source: github.com/org/tflint-ruleset-foo, version: 0.1.0)
$ tflint -v
TFLint version 0.28.1
+ ruleset.foo (0.1.0)
Expand Down
63 changes: 28 additions & 35 deletions integrationtest/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,95 +85,88 @@ func TestIntegration(t *testing.T) {
stderr: "Failed to load configurations;",
},
{
name: "removed `debug` options",
name: "removed --debug options",
command: "./tflint --debug",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`debug` option was removed in v0.8.0. Please set `TFLINT_LOG` environment variables instead",
stderr: "--debug option was removed in v0.8.0. Please set TFLINT_LOG environment variables instead",
},
{
name: "removed `fast` option",
command: "./tflint --fast",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`fast` option was removed in v0.9.0. The `aws_instance_invalid_ami` rule is already fast enough",
},
{
name: "removed `--error-with-issues` option",
name: "removed --error-with-issues option",
command: "./tflint --error-with-issues",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`error-with-issues` option was removed in v0.9.0. The behavior is now default",
stderr: "--error-with-issues option was removed in v0.9.0. The behavior is now default",
},
{
name: "removed `--quiet` option",
name: "removed --quiet option",
command: "./tflint --quiet",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`quiet` option was removed in v0.11.0. The behavior is now default",
stderr: "--quiet option was removed in v0.11.0. The behavior is now default",
},
{
name: "removed `--ignore-rule` option",
name: "removed --ignore-rule option",
command: "./tflint --ignore-rule aws_instance_example_type",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`ignore-rule` option was removed in v0.12.0. Please use `--disable-rule` instead",
stderr: "--ignore-rule option was removed in v0.12.0. Please use --disable-rule instead",
},
{
name: "removed `--deep` option",
name: "removed --deep option",
command: "./tflint --deep",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`deep` option was removed in v0.23.0. Deep checking is now a feature of the AWS plugin, so please configure the plugin instead",
stderr: "--deep option was removed in v0.23.0. Deep checking is now a feature of the AWS plugin, so please configure the plugin instead",
},
{
name: "removed `--aws-access-key` option",
name: "removed --aws-access-key option",
command: "./tflint --aws-access-key AWS_ACCESS_KEY_ID",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`aws-access-key` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
stderr: "--aws-access-key option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
},
{
name: "removed `--aws-secret-key` option",
name: "removed --aws-secret-key option",
command: "./tflint --aws-secret-key AWS_SECRET_ACCESS_KEY",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`aws-secret-key` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
stderr: "--aws-secret-key option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
},
{
name: "removed `--aws-profile` option",
name: "removed --aws-profile option",
command: "./tflint --aws-profile AWS_PROFILE",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`aws-profile` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
stderr: "--aws-profile option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
},
{
name: "removed `--aws-creds-file` option",
name: "removed --aws-creds-file option",
command: "./tflint --aws-creds-file FILE",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`aws-creds-file` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
stderr: "--aws-creds-file option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
},
{
name: "removed `--aws-region` option",
name: "removed --aws-region option",
command: "./tflint --aws-region us-east-1",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`aws-region` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
stderr: "--aws-region option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
},
{
name: "removed `--loglevel` option",
name: "removed --loglevel option",
command: "./tflint --loglevel debug",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`loglevel` option was removed in v0.40.0. Please set `TFLINT_LOG` environment variables instead",
stderr: "--loglevel option was removed in v0.40.0. Please set TFLINT_LOG environment variables instead",
},
{
name: "invalid options",
command: "./tflint --unknown",
dir: "no_issues",
status: cmd.ExitCodeError,
stderr: "`unknown` is unknown option. Please run `tflint --help`",
stderr: `--unknown is unknown option. Please run "tflint --help"`,
},
{
name: "invalid format",
Expand All @@ -197,35 +190,35 @@ func TestIntegration(t *testing.T) {
stdout: fmt.Sprintf("%s (aws_instance_example_type)", color.New(color.Bold).Sprint("instance type is t2.micro")),
},
{
name: "`--force` option with issues",
name: "--force option with issues",
command: "./tflint --force",
dir: "issues_found",
status: cmd.ExitCodeOK,
stdout: fmt.Sprintf("%s (aws_instance_example_type)", color.New(color.Bold).Sprint("instance type is t2.micro")),
},
{
name: "`--minimum-failure-severity` option with warning issues and minimum-failure-severity notice",
name: "--minimum-failure-severity option with warning issues and minimum-failure-severity notice",
command: "./tflint --minimum-failure-severity=notice",
dir: "warnings_found",
status: cmd.ExitCodeIssuesFound,
stdout: fmt.Sprintf("%s (aws_s3_bucket_with_config_example)", color.New(color.Bold).Sprint("bucket name is test, config=bucket")),
},
{
name: "`--minimum-failure-severity` option with warning issues and minimum-failure-severity warning",
name: "--minimum-failure-severity option with warning issues and minimum-failure-severity warning",
command: "./tflint --minimum-failure-severity=warning",
dir: "warnings_found",
status: cmd.ExitCodeIssuesFound,
stdout: fmt.Sprintf("%s (aws_s3_bucket_with_config_example)", color.New(color.Bold).Sprint("bucket name is test, config=bucket")),
},
{
name: "`--minimum-failure-severity` option with warning issues and minimum-failure-severity error",
name: "--minimum-failure-severity option with warning issues and minimum-failure-severity error",
command: "./tflint --minimum-failure-severity=error",
dir: "warnings_found",
status: cmd.ExitCodeOK,
stdout: fmt.Sprintf("%s (aws_s3_bucket_with_config_example)", color.New(color.Bold).Sprint("bucket name is test, config=bucket")),
},
{
name: "`--no-color` option",
name: "--no-color option",
command: "./tflint --no-color",
dir: "issues_found",
status: cmd.ExitCodeIssuesFound,
Expand Down
12 changes: 6 additions & 6 deletions integrationtest/init/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ func TestIntegration(t *testing.T) {
}

cli.Run([]string{"./tflint"})
if !strings.Contains(errStream.String(), "Plugin `aws` not found. Did you run `tflint --init`?") {
if !strings.Contains(errStream.String(), `Plugin "aws" not found. Did you run "tflint --init"?`) {
t.Fatalf("Expected to contain an initialization error, but did not: stdout=%s, stderr=%s", outStream, errStream)
}

cli.Run([]string{"./tflint", "--init"})
if !strings.Contains(outStream.String(), "Installing `aws` plugin...") {
if !strings.Contains(outStream.String(), `Installing "aws" plugin...`) {
t.Fatalf("Expected to contain an installation log, but did not: stdout=%s, stderr=%s", outStream, errStream)
}
if !strings.Contains(outStream.String(), "Installed `aws` (source: github.com/terraform-linters/tflint-ruleset-aws, version: 0.21.1)") {
if !strings.Contains(outStream.String(), `Installed "aws" (source: github.com/terraform-linters/tflint-ruleset-aws, version: 0.21.1)`) {
t.Fatalf("Expected to contain an installed log, but did not: stdout=%s, stderr=%s", outStream, errStream)
}

cli.Run([]string{"./tflint", "--init"})
if !strings.Contains(outStream.String(), "Plugin `aws` is already installed") {
if !strings.Contains(outStream.String(), `Plugin "aws" is already installed`) {
t.Fatalf("Expected to contain an already installed log, but did not: stdout=%s, stderr=%s", outStream, errStream)
}

Expand All @@ -74,7 +74,7 @@ func TestIntegration(t *testing.T) {
}

cli.Run([]string{"./tflint", "--chdir", "basic", "--init"})
if !strings.Contains(outStream.String(), "Plugin `aws` is already installed") {
if !strings.Contains(outStream.String(), `Plugin "aws" is already installed`) {
t.Fatalf("Expected to contain an already installed log, but did not: stdout=%s, stderr=%s", outStream, errStream)
}

Expand Down Expand Up @@ -103,7 +103,7 @@ func TestIntegration(t *testing.T) {
if !strings.Contains(outStream.String(), "working directory: basic") {
t.Fatalf("Expected to contain working dir log, but did not: stdout=%s, stderr=%s", outStream, errStream)
}
if !strings.Contains(outStream.String(), "Plugin `aws` is already installed") {
if !strings.Contains(outStream.String(), `Plugin "aws" is already installed`) {
t.Fatalf("Expected to contain an already installed log, but did not: stdout=%s, stderr=%s", outStream, errStream)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"issues": [],
"errors": [
{
"message": "Failed to check ruleset; failed to check \"aws_s3_bucket_with_config_example\" rule: This rule cannot be enabled with the `--enable-rule` option because it lacks the required configuration",
"message": "Failed to check ruleset; failed to check \"aws_s3_bucket_with_config_example\" rule: This rule cannot be enabled with the --enable-rule option because it lacks the required configuration",
"severity": "error"
}
]
Expand Down
Loading

0 comments on commit 9259d0e

Please sign in to comment.