Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
include:
- ruby_version: '2.7'
puppet_version: '~> 7.0'
- ruby_version: '3.2'
puppet_version: '~> 8.0'
name: "spec (ruby ${{ matrix.ruby_version }} | puppet ${{ matrix.puppet_version }})"
Expand All @@ -38,11 +35,8 @@ jobs:
strategy:
matrix:
ruby_version:
- "2.7"
- "3.2"
include:
- ruby-version: '2.7'
puppet_version: '~> 7.0'
- ruby_version: '3.2'
puppet_version: '~> 8.0'
runs_on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/custom_acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
ruby_version:
description: "The target Ruby version."
required: false
default: "2.7"
default: "3.1"
type: "string"
puppet_version:
description: "The target Puppet version."
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
include:
- ruby_version: '2.7'
puppet_version: '~> 7.0'
- ruby_version: '3.2'
puppet_version: '~> 8.0'
name: "spec (ruby ${{ matrix.ruby_version }} | puppet ${{ matrix.puppet_version }})"
Expand All @@ -30,11 +27,8 @@ jobs:
strategy:
matrix:
ruby_version:
- "2.7"
- "3.2"
include:
- ruby-version: '2.7'
puppet_version: '~> 7.0'
- ruby_version: '3.2'
puppet_version: '~> 8.0'
runs_on:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
- vendor/bundle/**/*
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: '2.7'
TargetRubyVersion: '3.1'

# Disabled
Style/ClassAndModuleChildren:
Expand Down
87 changes: 66 additions & 21 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-30 16:36:55 UTC using RuboCop version 1.50.2.
# on 2025-04-09 15:12:12 UTC using RuboCop version 1.70.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Exclude:
- 'ruby-pwsh.gemspec'

# Offense count: 1
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
Lint/DuplicateBranch:
Exclude:
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'
Expand All @@ -32,28 +25,29 @@ Lint/IncompatibleIoSelectWithFiberScheduler:
Exclude:
- 'lib/pwsh.rb'

# Offense count: 17

# Offense count: 16
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 83
Max: 63

# Offense count: 2
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 35
Max: 28

# Offense count: 2
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 553
Max: 296

# Offense count: 12
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 24

# Offense count: 23
# Offense count: 22
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 42
Expand All @@ -63,12 +57,21 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Max: 24

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, BlockForwardingName.
# SupportedStyles: anonymous, explicit
Naming/BlockForwarding:
Exclude:
- 'lib/pwsh.rb'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'Rakefile.rb'
- 'lib/ruby-pwsh.rb'

# Offense count: 1
Expand Down Expand Up @@ -118,12 +121,12 @@ RSpec/DescribeClass:
- 'spec/acceptance/dsc/complex.rb'
- 'spec/unit/pwsh_spec.rb'

# Offense count: 32
# Offense count: 38
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 70

# Offense count: 105
# Offense count: 151
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand All @@ -134,7 +137,7 @@ RSpec/MultipleDescribes:
Exclude:
- 'spec/unit/pwsh_spec.rb'

# Offense count: 151
# Offense count: 157
RSpec/MultipleExpectations:
Max: 15

Expand All @@ -156,22 +159,64 @@ RSpec/NoExpectationExample:
- 'spec/unit/pwsh/windows_powershell_spec.rb'
- 'spec/unit/pwsh_spec.rb'

# Offense count: 56
# Offense count: 86
RSpec/StubbedMock:
Exclude:
- 'spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb'
- 'spec/unit/pwsh/util_spec.rb'
- 'spec/unit/pwsh/windows_powershell_spec.rb'

# Offense count: 65
# Offense count: 71
RSpec/SubjectStub:
Exclude:
- 'spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb'


# Offense count: 1
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: Thread.current
Style/HashEachMethods:
Exclude:
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashExcept:
Exclude:
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'
- 'spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapIntoArray:
Exclude:
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'


# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpArgument:
Exclude:
- 'spec/unit/pwsh_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantSelfAssignmentBranch:
Exclude:
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, AllowedPatterns.
Style/ReturnNilInPredicateMethodDefinition:
Exclude:
- 'lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb'
6 changes: 1 addition & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ def location_for(place_or_version, fake_version = nil)
end

group :development do
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "deep_merge", '~> 1.0', require: false
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
gem "facterdb", '~> 1.18', require: false
Expand All @@ -30,7 +26,7 @@ group :development do
gem "pry", '~> 0.10', require: false
gem "simplecov-console", '~> 0.9', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "rubocop", '~> 1.50.0', require: false
gem "rubocop", '~> 1.70.0', require: false
gem "rubocop-performance", '1.22.1', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ def invoke_get_method(context, name_hash) # rubocop:disable Metrics/AbcSize
# Canonicalize the results to match the type definition representation;
# failure to do so will prevent the resource_api from comparing the result
# to the should hash retrieved from the resource definition in the manifest.
data.keys.each do |key| # rubocop:disable Style/HashEachMethods
type_key = "dsc_#{key.downcase}".to_sym
data.keys.each do |key|
type_key = :"dsc_#{key.downcase}"
data[type_key] = data.delete(key)

# Special handling for CIM Instances
Expand Down Expand Up @@ -598,7 +598,7 @@ def logon_failed_already?(credential_hash)
# @param enumerable [Enumerable] a string, array, hash, or other object to attempt to recursively downcase
def downcase_hash_keys!(enumerable)
if enumerable.is_a?(Hash)
enumerable.keys.each do |key| # rubocop:disable Style/HashEachMethods
enumerable.keys.each do |key|
name = key.dup.downcase
enumerable[name] = enumerable.delete(key)
downcase_hash_keys!(enumerable[name]) if enumerable[name].is_a?(Enumerable)
Expand Down Expand Up @@ -1063,7 +1063,7 @@ def escape_quotes(text)
# With multiple methods which need to discover secrets it is necessary to keep a single regex
# which can discover them. This will lazily match everything in a single-quoted string which
# ends with the secret postfix id and mark the actual contents of the string as the secret.
SECRET_DATA_REGEX = /'(?<secret>[^']+)+?#{Regexp.quote(SECRET_POSTFIX)}'/.freeze
SECRET_DATA_REGEX = /'(?<secret>[^']+)+?#{Regexp.quote(SECRET_POSTFIX)}'/

# Strings containing sensitive data have a secrets postfix. These strings cannot be passed
# directly either to debug streams or to PowerShell and must be handled; this method contains
Expand Down
6 changes: 3 additions & 3 deletions lib/pwsh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def self.instance(cmd, args, options = {})
#
# @return [Bool] true if enabled
def self.win32console_enabled?
@win32console_enabled ||= defined?(Win32) &&
defined?(Win32::Console) &&
Win32::Console.instance_of?(Class)
@win32console_enabled ||=
defined?(Win32::Console) &&
Win32::Console.instance_of?(Class)
end

# TODO: This thing isn't called anywhere and the variable it sets is never referenced...
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 7.0.0 < 9.0.0"
"version_requirement": ">= 8.0.0 < 9.0.0"
}
],
"pdk-version": "3.0.1",
Expand Down
3 changes: 2 additions & 1 deletion ruby-pwsh.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
spec.metadata['rubygems_mfa_required'] = 'true'
end