Skip to content

resource completion quotes ensure parameter #391

Open
@sprd-tmu

Description

@sprd-tmu

Describe the Bug

The Puppet language style guide states here in section Quoting:

If a string is a value from an enumerable set of options, such as present and absent, it SHOULD NOT be enclosed in quotes at all.

For example:

Good:
ensure => present
Bad:
ensure => "present"

The completion of resources in VScode encloses the parameter value in single ticks, which is a violation of the language style guide.

Current behavior

quoted

Expected Behavior

unquoted

Steps to Reproduce

Steps to reproduce the behavior:
In a Puppet file, add a supported resource like file, service, package etc.

Environment

  • Version 2.0.4 (added by official VScode extension Puppet version 1.5.4)
  • Platform Gentoo

Additional Context

Seems, that this is caused by this line.

In the meantime, I edited the file locally like so:

diff --git a/lib/puppet-languageserver/manifest/completion_provider.rb b/lib/puppet-languageserver/manifest/completion_provider.rb
index e41c41d..086876f 100644
--- a/lib/puppet-languageserver/manifest/completion_provider.rb
+++ b/lib/puppet-languageserver/manifest/completion_provider.rb
@@ -276,7 +276,7 @@ module PuppetLanguageServer
           attr_names.each_index do |index|
             name = attr_names[index]
             value_text = (name == 'ensure') ? 'present' : 'value' # rubocop:disable Style/TernaryParentheses  In this case it's easier to read.
-            snippet += "\t#{name.ljust(max_length, ' ')} => '${#{index + 2}:#{value_text}}'\n"
+            snippet += "\t#{name.ljust(max_length, ' ')} => ${#{index + 2}:#{value_text}}\n"
           end
           snippet += '}'
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions