Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: Fix rubocop cleanup #1139

Merged
merged 1 commit into from
Jan 7, 2022

Conversation

bastelfreak
Copy link
Member

On master, the following code:

elasticsearch_plugin { 'ingest-attachment':
  ensure   => 'present',
}

produces the following error:

Debug: Runtime environment: puppet_version=7.13.1, ruby_version=2.7.3, run_mode=user, default_encoding=UTF-8
Debug: Evicting cache entry for environment :production
Debug: Deleted text domain :production: false
Debug: Caching environment :production (ttl = 0 sec)
Debug: Evicting cache entry for environment :production
Debug: Deleted text domain :production: false
Debug: Facter: Resolving facts sequentially
Debug: Facter: resolving fact with user_query: osfamily
Debug: Facter: Searching fact: osfamily in file: osfamily.rb
Debug: Facter: Searching fact: osfamily in core facts and external facts
Debug: Facter: Loading all internal facts
Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x000055817d4a4738 @name="osfamily", @fact_class=Facts::Linux::Os::Family, @user_query="osfamily", @type=:legacy, @file=nil>]
Debug: Facter: Loading external facts
Debug: Facter: fact "osfamily" has resolved to: Debian
Debug: Loaded state in 0.08 seconds
Debug: Elasticsearch_plugin[ingest-attachment](provider=elasticsearch_plugin): ingest-attachment: exists? method in elastic_plugin.rb
Error: /Elasticsearch_plugin[ingest-attachment]: Could not evaluate: wrong number of arguments (given 3, expected 2)
Debug: Finishing transaction 10000
Debug: Storing state
Debug: Pruned old state cache entries in 0.00 seconds
Debug: Stored state in 0.03 seconds
Debug: Elasticsearch_plugin[ingest-attachment](provider=elasticsearch_plugin): ingest-attachment: exists? method in elastic_plugin.rb
Error: Could not run: wrong number of arguments (given 3, expected 2)

Before RuboCop went rouge, the method header looked like this:

def self.plugin_split(original_string, position, soft_fail = true)

master has soft_fail as a symbol and that produces the above error
messsage. This commits reverts it and it works locally for me again.

Pull Request (PR) description

This Pull Request (PR) fixes the following issues

@bastelfreak bastelfreak added the bug Something isn't working label Dec 23, 2021
@bastelfreak bastelfreak requested a review from smortex December 23, 2021 23:43
@bastelfreak bastelfreak self-assigned this Dec 23, 2021
On master, the following code:
```puppet
elasticsearch_plugin { 'ingest-attachment':
  ensure   => 'present',
}
```

produces the following error:
```
Debug: Runtime environment: puppet_version=7.13.1, ruby_version=2.7.3, run_mode=user, default_encoding=UTF-8
Debug: Evicting cache entry for environment :production
Debug: Deleted text domain :production: false
Debug: Caching environment :production (ttl = 0 sec)
Debug: Evicting cache entry for environment :production
Debug: Deleted text domain :production: false
Debug: Facter: Resolving facts sequentially
Debug: Facter: resolving fact with user_query: osfamily
Debug: Facter: Searching fact: osfamily in file: osfamily.rb
Debug: Facter: Searching fact: osfamily in core facts and external facts
Debug: Facter: Loading all internal facts
Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x000055817d4a4738 @name="osfamily", @fact_class=Facts::Linux::Os::Family, @user_query="osfamily", @type=:legacy, @file=nil>]
Debug: Facter: Loading external facts
Debug: Facter: fact "osfamily" has resolved to: Debian
Debug: Loaded state in 0.08 seconds
Debug: Elasticsearch_plugin[ingest-attachment](provider=elasticsearch_plugin): ingest-attachment: exists? method in elastic_plugin.rb
Error: /Elasticsearch_plugin[ingest-attachment]: Could not evaluate: wrong number of arguments (given 3, expected 2)
Debug: Finishing transaction 10000
Debug: Storing state
Debug: Pruned old state cache entries in 0.00 seconds
Debug: Stored state in 0.03 seconds
Debug: Elasticsearch_plugin[ingest-attachment](provider=elasticsearch_plugin): ingest-attachment: exists? method in elastic_plugin.rb
Error: Could not run: wrong number of arguments (given 3, expected 2)
```

Before RuboCop went rouge, the method header looked like this:
```
def self.plugin_split(original_string, position, soft_fail = true)
```

master has `soft_fail` as a symbol and that produces the above error
messsage. This commits reverts it and it works locally for me again.
@bastelfreak bastelfreak merged commit 0008e4d into voxpupuli:master Jan 7, 2022
@bastelfreak bastelfreak deleted the regression branch January 7, 2022 21:10
@@ -17,7 +17,7 @@ def self.plugin_version(raw_name)
end

# Attempt to guess at the plugin's final directory name
def self.plugin_split(original_string, position, soft_fail: true)
def self.plugin_split(original_string, position, soft_fail = true) # rubocop:disable Style/OptionalBooleanParameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be called only once on line 13. What about following rubocop advice and fix that line:

-      v = plugin_split(raw_name, 2, false).gsub(%r{^[^0-9]*}, '')
+      v = plugin_split(raw_name, 2, soft_fail: false).gsub(%r{^[^0-9]*}, '')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants