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

(FACT-3428) Resolve RSpec cops #2669

Merged
merged 56 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4148e4b
(FACT-3428) Update rubocop & rubocop-rspec
joshcooper Oct 6, 2023
7bdbb9d
(FACT-3428) Disable Metrics cops
joshcooper Dec 20, 2023
d2785a5
(FACT-3428) Lint/NonDeterministicRequireOrder
joshcooper Oct 6, 2023
9db6829
(FACT-3428) Lint/RedundantStringCoercion
joshcooper Oct 6, 2023
395e129
(FACT-3428) Lint/DuplicateRequire
joshcooper Oct 6, 2023
1f73f7a
(FACT-3428) Lint/ElseLayout
joshcooper Oct 6, 2023
9a8fda9
(FACT-3428) Lint/ConstantDefinitionInBlock
joshcooper Oct 6, 2023
eae7a2d
(FACT-3428) Lint/RedundantCopDisableDirective
joshcooper Jan 8, 2024
552b869
(FACT-3428) Style/RedundantFileExtensionInRequire
joshcooper Oct 6, 2023
1b09798
(FACT-3428) Style/RedundantRegexpEscape
joshcooper Oct 6, 2023
9a2fba2
(FACT-3428) Style/RedundantSelfAssignment
joshcooper Oct 6, 2023
a2f0fcf
(FACT-3428) Style/RedundantAssignment
joshcooper Oct 6, 2023
b1837ff
(FACT-3428) Style/ClassEqualityComparison
joshcooper Oct 6, 2023
f336bf8
(FACT-3428) Style/RedundantReturn
joshcooper Oct 6, 2023
1fd9f19
(FACT-3428) Style/ExplicitBlockArgument
joshcooper Oct 6, 2023
d40d8e7
(FACT-3428) Style/RedundantRegexpCharacterClass
joshcooper Oct 6, 2023
7bf46a4
(FACT-3428) Style/CommentAnnotation
joshcooper Oct 6, 2023
24a63a9
(FACT-3428) Style/SafeNavigation
joshcooper Oct 6, 2023
3de0da5
(FACT-3428) Style/AccessorGrouping
joshcooper Oct 6, 2023
20196cd
(FACT-3428) Style/StringLiteralsInInterpolation
joshcooper Oct 6, 2023
89404da
(FACT-3428) Style/StringConcatenation
joshcooper Dec 20, 2023
a20fc6b
(FACT-3428) Style/OptionalBooleanParameter
joshcooper Oct 6, 2023
9cd98bb
(FACT-3428) Style/SoleNestedConditional
joshcooper Oct 6, 2023
c4af979
(FACT-3428) Style/FrozenStringLiteralComment
joshcooper Oct 6, 2023
2c291fe
(FACT-3428) Style/HashEachMethods
joshcooper Dec 9, 2023
8a43bc2
(FACT-3428) Style/RedundantParentheses
joshcooper Dec 9, 2023
8ac6277
(FACT-3428) Style/GlobalStdStream
joshcooper Dec 20, 2023
ff54f75
(FACT-3428) Style/HashTransformKeys
joshcooper Dec 9, 2023
bd07a8f
(FACT-3428) Style/MissingRespondToMissing
joshcooper Dec 20, 2023
c774f09
(FACT-3428) Style/IfUnlessModifier
joshcooper Dec 9, 2023
90884f7
(FACT-3428) Style/CaseEquality
joshcooper Dec 9, 2023
f65222b
(FACT-3428) Style/ClassVars
joshcooper Dec 9, 2023
0a50606
(FACT-3428) Style/Documentation
joshcooper Dec 9, 2023
8938ebb
(FACT-3428) Style/FormatStringToken
joshcooper Dec 20, 2023
e924abd
(FACT-3428) Layout/SpaceAroundMethodCallOperator
joshcooper Oct 6, 2023
d0ed6b2
(FACT-3428) Layout/EmptyLinesAroundAttributeAccessor
joshcooper Dec 20, 2023
5d6adad
(FACT-3428) Layout/LeadingCommentSpace
joshcooper Oct 6, 2023
9647d7a
(FACT-3428) Layout/MultilineMethodCallIndentation
joshcooper Oct 6, 2023
99e5897
(FACT-3428) Layout/LineLength
joshcooper Dec 20, 2023
41b7877
(FACT-3428) Layout/FirstHashElementIndentation
joshcooper Dec 20, 2023
82e2ac1
(FACT-3428) Layout/LeadingCommentSpace
joshcooper Dec 20, 2023
a031a63
(FACT-3428) Layout/SpaceInsideHashLiteralBraces
joshcooper Dec 20, 2023
ed1956f
(FACT-3428) Naming/VariableNumber
joshcooper Dec 20, 2023
dea028c
(FACT-3428) Naming/PredicateName
joshcooper Dec 20, 2023
eca5591
(FACT-3428) Naming/{ClassAndModuleCamelCase,MethodName}
joshcooper Dec 20, 2023
d029768
(FACT-3428) RSpec/StubbedMock
joshcooper Oct 6, 2023
ae1ffc8
(FACT-3428) RSpec/MultipleMemoizedHelpers
joshcooper Dec 20, 2023
aa9542a
(FACT-3428) RSpec/{NestedGroups,DescribedClass,ExampleLength}
joshcooper Dec 20, 2023
1527f36
(FACT-3428) RSpec/InstanceVariable
joshcooper Dec 20, 2023
ece4eb7
(FACT-3428) RSpec/MessageSpies
joshcooper Dec 9, 2023
31b2205
(FACT-3428) RSpec/Multiple*
joshcooper Dec 9, 2023
03baf04
(FACT-3428) RSpec/SubjectStub
joshcooper Dec 9, 2023
6e7970e
(FACT-3428) RSpec/VerifyingDoubles
joshcooper Dec 9, 2023
658c096
(FACT-3428) RSpec/LeakyConstantDeclaration
joshcooper Dec 20, 2023
a7e3f9c
(FACT-3428) RSpec/ExampleWording
joshcooper Jan 8, 2024
c8c09ef
(FACT-3428) Performance/RegexpMatch
joshcooper Oct 6, 2023
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
187 changes: 64 additions & 123 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,163 +12,104 @@ require:
- rubocop-rspec

Layout/LineLength:
Max: 120
Exclude:
- spec/facter/resolvers/gce_spec.rb

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Metrics/MethodLength:
Max: 20
Exclude:
- 'lib/facter/custom_facts/util/values.rb'
- 'lib/facter/custom_facts/util/confine.rb'
- 'lib/facter/custom_facts/core/execution/windows.rb'
- 'lib/facter/custom_facts/core/execution/base.rb'
- 'lib/facter/framework/detector/os_detector.rb'
- 'lib/facter/resolvers/bsd/ffi/ffi_helper.rb'
- 'install.rb'
- 'scripts/generate_changelog.rb'
- 'lib/facter/resolvers/aix/ffi/ffi_helper.rb'

Enabled: false

Metrics/ModuleLength:
Max: 100
Exclude:
- 'lib/facter.rb'
- 'lib/facter/config.rb'
- 'lib/facter/resolvers/aix/ffi/ffi_helper.rb'
Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Exclude:
- !ruby/regexp /(?:(?!.+_spec.rb).)*$/
Enabled: false

Naming/ClassAndModuleCamelCase:
Exclude:
- 'spec/mocks/**/*'
Metrics/ClassLength:
Enabled: false

Metrics/AbcSize:
Metrics/CyclomaticComplexity:
Enabled: false

Metrics/PerceivedComplexity:
Exclude:
- 'lib/facter/custom_facts/util/values.rb'
- 'lib/facter/custom_facts/util/confine.rb'
- 'lib/facter/custom_facts/core/execution/windows.rb'
- 'lib/facter/custom_facts/core/execution/posix.rb'
- 'install.rb'
- 'lib/facter/resolvers/aix/ffi/ffi_helper.rb'
Metrics/MethodLength:
Enabled: false

Metrics/CyclomaticComplexity:
Exclude:
- 'lib/facter/resolvers/windows/product_release.rb'
- 'lib/facter/custom_facts/util/values.rb'
- 'lib/facter/custom_facts/util/confine.rb'
- 'lib/facter/custom_facts/core/execution/windows.rb'
- 'lib/facter/custom_facts/core/execution/posix.rb'
- 'lib/facter/facts/linux/cloud/provider.rb'
- 'lib/facter/facts/windows/cloud/provider.rb'
- 'lib/facter/framework/detector/os_detector.rb'
- 'install.rb'
- 'scripts/generate_changelog.rb'
- 'lib/facter/resolvers/aix/ffi/ffi_helper.rb'
Metrics/ModuleLength:
Enabled: false

Metrics/ClassLength:
Metrics/PerceivedComplexity:
Enabled: false

Naming/AccessorMethodName:
Naming/ClassAndModuleCamelCase:
Exclude:
- 'lib/facter/custom_facts/core/suitable.rb'
- 'spec/mocks/win32.rb'

Naming/MethodName:
Exclude:
- 'spec/mocks/**/*'
- 'spec/mocks/win32ole.rb'
- 'spec/mocks/ffi.rb'

Naming/PredicateName:
Exclude:
- 'lib/facter/custom_facts/core/suitable.rb'
- 'spec/**/*'

Naming/FileName:
Naming/VariableNumber:
Exclude:
- 'lib/facter.rb'
- 'lib/facter/resolvers/windows/ffi/networking_ffi.rb'
- 'lib/facter/util/facts/windows_release_finder.rb'

Performance/RegexpMatch:
Exclude:
- 'install.rb'

RSpec/ExampleLength:
RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/DescribedClass:
EnforcedStyle: explicit

RSpec/MultipleExpectations:
Max: 3

RSpec/NestedGroups:
Max: 6

Style/Documentation:
RSpec/StubbedMock:
Enabled: false

Style/ClassVars:
Exclude:
- !ruby/regexp /(?:(?!.+_resolver.rb).)*$/
Style/IfUnlessModifier:
Enabled: false

Style/FormatStringToken:
# $stdout is preferred because it refers to the *current* stdout stream, while
# STDOUT refers to the original stream. However, we can't just switch to using
# $stdout, because it may have been assigned to a different object than STDOUT,
# such as a IO to a file.
Style/GlobalStdStream:
Exclude:
- 'lib/facter/resolvers/amzn/os_release_rpm.rb'
- 'spec/facter/resolvers/amzn/os_release_rpm_spec.rb'
- 'lib/facter.rb'
- 'lib/facter/framework/cli/cli_launcher.rb'
- 'lib/facter/framework/logging/logger.rb'
- 'spec/framework/core/fact/internal/internal_fact_manager_spec.rb'
- 'spec/framework/logging/logger_spec.rb'

Style/FrozenStringLiteralComment:
Exclude:
- 'spec/custom_facts/util/normalization_spec.rb'
- 'spec/custom_facts/core/execution/windows_spec.rb'
- 'spec/custom_facts/core/execution/posix_spec.rb'
- 'lib/facter/custom_facts/util/resolution.rb'
- 'lib/facter/custom_facts/core/execution/windows.rb'
- 'lib/facter/custom_facts/core/execution/posix.rb'
RSpec/DescribedClass:
EnforcedStyle: explicit

Style/TrivialAccessors:
AllowDSLWriters: true
RSpec/ExampleLength:
Enabled: false

Style/CaseEquality:
Exclude:
- 'spec/custom_facts/util/confine_spec.rb'
- 'lib/facter/custom_facts/util/confine.rb'
# It is sometimes better to expect().to receive().and_return
# or to receive different messages.
RSpec/MessageSpies:
Enabled: false

Style/DoubleNegation:
Exclude:
- 'lib/facter/custom_facts/util/confine.rb'
- 'lib/facter/custom_facts/util/confine.rb'
- 'lib/facter/custom_facts/core/execution/windows.rb'
- 'lib/facter/custom_facts/core/execution/posix.rb'
RSpec/MultipleExpectations:
Max: 3

Style/MethodMissingSuper:
Exclude:
- 'lib/facter.rb'
RSpec/MultipleMemoizedHelpers:
Enabled: false

Style/MissingRespondToMissing:
Exclude:
- 'lib/facter.rb'
RSpec/NestedGroups:
Enabled: 6

Style/StderrPuts:
RSpec/SubjectStub:
Exclude:
- 'lib/facter/custom_facts/core/logging.rb'
- 'spec/custom_facts/core/aggregate_spec.rb'
- 'spec/custom_facts/core/resolvable_spec.rb'
- 'spec/custom_facts/util/fact_spec.rb'
- 'spec/custom_facts/util/resolution_spec.rb'

Style/ModuleFunction:
# Prefer instance_double/instance_spy over double/spy because only methods
# defined on the underlying object can be stubbed. FFI and some Windows
# code can't be verified because of the way we fake out those classes.
RSpec/VerifiedDoubles:
Enabled: true
Exclude:
- 'lib/facter/custom_facts/core/logging.rb'

Style/HashEachMethods:
Enabled: false # not implemented in ruby 2.3

Style/HashTransformKeys:
Enabled: false # not implemented in ruby 2.3

Style/HashTransformValues:
Enabled: false # not implemented in ruby 2.3
- 'spec/custom_facts/**/*'
- 'spec/facter/resolvers/aix/hardware_spec.rb'
- 'spec/facter/resolvers/*/ffi_helper_spec.rb'
- 'spec/facter/resolvers/windows/*'
- 'spec/facter/util/windows/network_utils_spec.rb'
- 'spec/facter/util/windows/win32ole_spec.rb'
98 changes: 25 additions & 73 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,38 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-09-27 16:56:42 +0300 using RuboCop version 0.81.0.
# on 2024-01-08 20:12:30 UTC using RuboCop version 1.59.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: 3
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 164

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'repro.rb'

# Offense count: 3
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 2
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 68
# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Offense count: 70
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Enabled: false

# Offense count: 15
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/custom_facts/core/execution/fact_manager_spec.rb'
- 'spec/custom_facts/util/collection_spec.rb'
- 'spec/custom_facts/util/confine_spec.rb'

# Offense count: 8
RSpec/LeakyConstantDeclaration:
# Need to remove logger class variables
Style/ClassVars:
Exclude:
- 'spec/custom_facts/core/resolvable_spec.rb'
- 'spec/custom_facts/core/suitable_spec.rb'
- 'spec/custom_facts/util/collection_spec.rb'
- 'spec/facter/resolvers/macosx/mountpoints_spec.rb'
- 'spec/facter/util/windows/network_utils_spec.rb'

# Offense count: 75
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Enabled: false

# Offense count: 6
RSpec/SubjectStub:
Exclude:
- 'spec/custom_facts/core/aggregate_spec.rb'
- 'spec/custom_facts/core/resolvable_spec.rb'
- 'spec/custom_facts/util/fact_spec.rb'
- 'spec/custom_facts/util/resolution_spec.rb'

# Offense count: 111
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false
- 'lib/facter/framework/logging/logger.rb'
- 'spec/custom_facts/puppetlabs_spec/files.rb'
- 'spec/facter/util/file_helper_spec.rb'
- 'spec/framework/core/fact/internal/internal_fact_manager_spec.rb'
- 'spec/framework/logging/logger_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Style/Documentation:
Exclude:
- 'spec/custom_facts/util/normalization_spec.rb'
- 'spec/custom_facts/core/execution/windows_spec.rb'
- 'spec/custom_facts/core/execution/posix_spec.rb'
- 'lib/facter/custom_facts/util/resolution.rb'
- 'lib/facter/custom_facts/core/execution/windows.rb'
- 'lib/facter/custom_facts/core/execution/posix.rb'
- 'repro.rb'
- 'lib/facter.rb' # should be documented
- 'lib/facter/config.rb' # should be documented
- 'lib/facter/custom_facts/**/*' # should be documented
- 'lib/facter/facts/**/*' # don't care
- 'lib/facter/framework/**/*' # should be documented
- 'lib/facter/models/**/*' # should be documented
- 'lib/facter/resolvers/**/*' # don't care
- 'lib/facter/util/**/*'
- 'lib/facter/version.rb' # auto updated
- 'spec/**/*'
- 'spec_integration/**/*'
- 'scripts/*'
- 'install.rb'
2 changes: 1 addition & 1 deletion bin/facter
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require 'pathname'
require 'facter/framework/cli/cli_launcher.rb'
require 'facter/framework/cli/cli_launcher'

Facter::OptionsValidator.validate(ARGV)
processed_arguments = CliLauncher.prepare_arguments(ARGV)
Expand Down
4 changes: 2 additions & 2 deletions facter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'ffi', '1.15.5'
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.81.0'
spec.add_development_dependency 'rubocop', '~> 1.28' # last version to support 2.5
spec.add_development_dependency 'rubocop-performance', '~> 1.5.2'
spec.add_development_dependency 'rubocop-rspec', '~> 1.38'
spec.add_development_dependency 'rubocop-rspec', '~> 2.10' # last version to support 2.5
spec.add_development_dependency 'simplecov', '~> 0.17.1'
spec.add_development_dependency 'sys-filesystem', '~> 1.4'
spec.add_development_dependency 'webmock', '~> 3.12'
Expand Down
Loading