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

Fix file detection to gather kmod fact #75

Merged
merged 2 commits into from
Feb 2, 2022
Merged

Fix file detection to gather kmod fact #75

merged 2 commits into from
Feb 2, 2022

Conversation

kajinamit
Copy link
Contributor

@kajinamit kajinamit commented Feb 2, 2022

Pull Request (PR) description

File.exists? can't be used with confine. It should be used in actual
logics, otherwise fact gathering fails with the following error.

error while resolving custom facts in .../lib/facter/kmod.rb: expected argument to be a String, Symbol, or Hash

This Pull Request (PR) fixes the following issues

Fixes #74

File.exists? can't be used with confine. It should be used in actual
logics, otherwise fact gathering fails with the following error.

error while resolving custom facts in .../lib/facter/kmod.rb: expected
argument to be a String, Symbol, or Hash

Fixes #74
Fixes the following lint errors detected by rubocop.

lib/facter/kmod.rb:2:11: C: Style/HashSyntax: Use the new Ruby 1.9 hash
syntax. (https://github.com/bbatsov/ruby-style-guide#hash-literals)
  confine :kernel => :linux
          ^^^^^^^^^^
lib/facter/kmod.rb:7:13: W: Lint/DeprecatedClassMethods: File.exists?
is deprecated in favor of File.exist?.
    if File.exists?('/sys/module')
            ^^^^^^^
lib/facter/kmod.rb:9:9: C: Style/MultipleComparison: Avoid comparing
a variable with multiple items in a conditional, use Array#include?
instead.
        next if directory == '.' or directory == '..'
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/facter/kmod.rb:9:34: C: Style/AndOr: Use || instead of or.
(https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
        next if directory == '.' or directory == '..'
                                 ^^
lib/facter/kmod.rb:19:15: C: Style/MultipleComparison: Avoid comparing
a variable with multiple items in a conditional, use Array#include?
instead.
              next if param == '.' or param == '..'
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/facter/kmod.rb:19:36: C: Style/AndOr: Use || instead of or.
(https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
              next if param == '.' or param == '..'
                                   ^^
lib/facter/kmod.rb:30:15: C: Style/MultipleComparison: Avoid comparing
a variable with multiple items in a conditional, use Array#include?
instead.
              next if used == '.' or used == '..'
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/facter/kmod.rb:30:35: C: Style/AndOr: Use || instead of or.
(https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
              next if used == '.' or used == '..'
                                  ^^
@bastelfreak
Copy link
Member

thanks!

@bastelfreak bastelfreak merged commit f195797 into voxpupuli:master Feb 2, 2022
@bastelfreak bastelfreak added the bug Something isn't working label Feb 2, 2022
@kajinamit kajinamit deleted the issue/74 branch February 2, 2022 12:26
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.

kmod fact consistently fails with 'expected argument to be a String, Symbol, or Hash'
2 participants