diff --git a/.ci/fixtures/new_provider_sync.yml b/.ci/fixtures/new_provider_sync.yml index 63c67d6c..4badc906 100644 --- a/.ci/fixtures/new_provider_sync.yml +++ b/.ci/fixtures/new_provider_sync.yml @@ -6,6 +6,6 @@ Gemfile: spec/spec_helper.rb: mock_with: ':rspec' .rubocop.yml: - default_configs: + cop_overrides: Performance/CaseWhenSplat: Enabled: false diff --git a/.ci/test_script.sh b/.ci/test_script.sh index e1535f90..2a7e1cb1 100755 --- a/.ci/test_script.sh +++ b/.ci/test_script.sh @@ -13,9 +13,9 @@ pdk new module new_module --template-url="file://$TEMPLATE_PR_DIR" --template-re pushd new_module grep template < metadata.json cp "$TEMPLATE_PR_DIR/.ci/fixtures/new_provider_sync.yml" ./.sync.yml -grep -A 1 "Performance/CaseWhenSplat" ./.rubocop.yml | grep -q "true" # Ensure that the template is applied +grep -A 5 "AllCops" ./.rubocop.yml | grep -q "NewCops" # Ensure the slim template is applied (NewCops governs cops, not per-cop enumeration) pdk update --force -grep -A 1 "Performance/CaseWhenSplat" ./.rubocop.yml | grep -q "false" # Ensure that the update command changes the template +grep -A 1 "Performance/CaseWhenSplat" ./.rubocop.yml | grep -q "false" # Ensure the cop_overrides override is rendered after update pdk new class new_module pdk new defined_type test_type pdk new fact test_fact || true # not available in pdk 1.18 yet diff --git a/.gitignore b/.gitignore index e44bdbb7..9ed68b13 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ # Rubocop profile builder temporary files /rubocop/.rubocop.yml /rubocop/.rubocop_todo.yml +# GSD planning docs (kept local, not tracked) +/.planning/ diff --git a/CLAUDE.md b/CLAUDE.md index 4afed92a..2df81f29 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -11,7 +11,6 @@ This repository contains the default templates used by [Puppet Development Kit ( - `moduleroot/`: Full module templates deployed on `pdk new module`, `pdk convert`, and `pdk update`. Enforces boilerplate for central files. - `moduleroot_init/`: Skeleton templates deployed only when the target module does not yet exist (required by `pdk convert`; do not remove). - `object_templates/`: Templates for generated objects (classes, defined types, tasks, plans, functions, transports, providers). -- `rubocop/`: RuboCop profiles (`cleanup_cops.yml`, `defaults-1.50.0.yml`) and the `profile_builder.rb` tool for regenerating them. - `config_defaults.yml`: The canonical source of default template configuration consumed by PDK. - `.ci/`: CI scripts (`install_pdk.sh`, `test_script.sh`) and fixtures. @@ -39,13 +38,6 @@ pdk test unit popd ``` -Regenerate RuboCop defaults after a RuboCop version bump (run from `rubocop/`): - -```bash -cd rubocop -bundle exec ruby profile_builder.rb -``` - ## Architecture: How Templates Are Rendered PDK merges two YAML files to produce a configuration hash before rendering any template: @@ -72,11 +64,14 @@ The `unmanaged: true` key tells PDK to leave a file untouched; `delete: true` te ## RuboCop Profile System -`rubocop/` contains the tooling for the `.rubocop.yml` template that PDK deploys into modules: +`moduleroot/.rubocop.yml.erb` uses `deep_merge` to layer configuration in the order `defaults -> profile['configs'] -> cop_overrides` before rendering the final `.rubocop.yml`: + +- `default_configs`: a YAML anchor in `config_defaults.yml` holding the base EnforcedStyle tunings that the `'on'` profile reuses as its `configs` (resolved when `config_defaults.yml` is assembled, not read directly at render time). The anchor also tunes several PDK / rspec-puppet-convention cops (e.g. trailing-comma style, the rspec-puppet describe/context/double idioms) so that freshly-scaffolded modules validate clean under `NewCops: enable`. Each such tuning carries an inline `Description:` rationale explaining why it exists; do NOT remove those `Description:` lines, as they prevent future drift and accidental re-enabling. +- `profiles`: defined in `config_defaults.yml` under `.rubocop.yml.profiles`. Two profiles exist: `'on'` (canonical; `NewCops: enable`) and `'off'` (`DisabledByDefault: true`, `NewCops: disable`). The names `cleanups_only`, `strict`, and `hardcore` are backward-compatible aliases that resolve to `'on'`. +- `cop_overrides`: the authoritative per-module override surface, merged last. Use `CopName: { Enabled: false }` to disable a cop; use the knockout prefix `---` to remove an override. The same `---` prefix applies to both PDK's `.sync.yml` overlay (the outer PDK merge) and this template's internal `defaults -> profile -> cop_overrides` deep-merge, so there is one knockout prefix everywhere. +- `selected_profile`: chooses which profile is active (ships as `strict`, a backward-compatible alias that resolves to `'on'`). Set to `'off'` to disable all cops. -- `defaults-1.50.0.yml`: Auto-generated list of all enabled/disabled cops for RuboCop 1.50.0. Regenerate with `profile_builder.rb` after a version update. -- `cleanup_cops.yml`: Curated set of cleanup cops included in the `strict` and `hardcore` profiles. -- Profiles (`cleanups_only`, `strict`, `hardcore`, `off`) are defined in `config_defaults.yml` under `.rubocop.yml.profiles` and selected via `selected_profile`. +**Future improvements:** The convention tunings above cover the object types that `.ci/test_script.sh` actually scaffolds and validates. Object types NOT currently exercised by CI -- notably `plan` and the legacy V1 `function` -- were intentionally left untouched: there is no scaffold coverage to validate a change against, so fixing them speculatively would be unverifiable. They are candidates for future template-validation coverage once CI scaffolds them. ## Packaging and Release Context diff --git a/README.md b/README.md index 2a2e28a1..1ee55e6c 100644 --- a/README.md +++ b/README.md @@ -145,15 +145,32 @@ Gemfile: ### Manage Rubocop rules -To disable or enable certain Rubocop rules, use the following structure: +Use `cop_overrides` in `.sync.yml` to override individual cops. Entries in `cop_overrides` are merged last (after the built-in defaults and the selected profile's configs), making it the authoritative per-module override surface. + +To disable a cop: ```yaml .rubocop.yml: - default_configs: + cop_overrides: Style/Documentation: Enabled: false ``` +To remove a cop override entirely (knockout): + +```yaml +.rubocop.yml: + cop_overrides: + Style/Documentation: '---' +``` + +To select a profile: + +```yaml +.rubocop.yml: + selected_profile: 'off' +``` + ## PDK default config values The following is a description and explanation of each of the keys within `.config_defaults.yml`. This will help clarify the default settings that are applied by PDK. @@ -246,14 +263,15 @@ In this example the automated release prep workflow is triggered every Saturday | Key | Description | | :------------- |:--------------| |include\_todos|Allows you to use rubocop's "TODOs" to temporarily skip checks by setting this to `true`. See rubocop's `--auto-gen-config` option for details. Defaults to `false`.| -|selected\_profile|Allows you to define which profile is used by default, which is set to `strict`, which is fully defined within the `profiles` section.| -|default\_configs |Allows you to define the default configuration of which cops will run. Includes the full name of the cop followed by a description of it and an enforced style. Can also make use of the key `excludes` to exclude any files from that specific cop.| -|cleanup\_cops |Defines a set of cleanup cops to then be included within a rubocop profile. Cops are defined by their full name, and further configuration can be done by specifying secondary keys. By default we specify a large amount of cleanup cops using their default configuration.| -|profiles |Defines the profiles that can be enabled and used within rubocop through the `selected_profile` option. By default we have set up three profiles: cleanups\_only, strict, hardcore and off.| +|selected\_profile|Selects the active RuboCop profile. The canonical value is `'on'`, which enables all cops via `NewCops: enable`. The names `cleanups_only`, `strict`, and `hardcore` are backward-compatible aliases that resolve to `'on'`. Set to `'off'` to disable all cops (`DisabledByDefault: true`).| +|default\_configs|A YAML anchor in `config_defaults.yml` holding the base EnforcedStyle tunings that the `'on'` profile reuses as its `configs`. It is resolved when `config_defaults.yml` is assembled, not read directly at render time, so setting it in `.sync.yml` has no effect on the generated `.rubocop.yml`. To adjust cop settings per module, use `cop_overrides`.| +|cop\_overrides|Authoritative per-module override surface. Merged last (precedence: `defaults -> profile configs -> cop_overrides`). Use `CopName: { Enabled: false }` to disable a cop; use the knockout prefix `---` (e.g. `CopName: '---'`) to remove an override entirely.| +|profiles|Defines the profile configurations. Two profiles are provided: `'on'` (canonical; sets `NewCops: enable`, with its `configs` sourced from the `default_configs` anchor) and `'off'` (`DisabledByDefault: true`, `NewCops: disable`). The named aliases `cleanups_only`, `strict`, and `hardcore` resolve to `'on'`.| +|TargetRubyVersion|Overrides the `AllCops.TargetRubyVersion` in the rendered `.rubocop.yml`. Defaults to `3.1`.| #### Puppet 9 subprocess-creation detection -The `strict` profile enables two security cops that flag the pipe-based subprocess creation removed in Ruby 4.0 (which ships with Puppet 9). See [Ruby #19630](https://bugs.ruby-lang.org/issues/19630). +These `Security/*` cops are enabled implicitly via `AllCops.NewCops: enable` for any non-`'off'` profile (i.e. `'on'` and all its aliases: `cleanups_only`, `strict`, `hardcore`) and are disabled when `selected_profile: 'off'`. They can be pinned or overridden per module via `cop_overrides` regardless of profile. See [Ruby #19630](https://bugs.ruby-lang.org/issues/19630). | Cop | Flags | Recommended replacement | | :-- | :---- | :---------------------- | diff --git a/config_defaults.yml b/config_defaults.yml index bbdc314e..7d1136a9 100644 --- a/config_defaults.yml +++ b/config_defaults.yml @@ -154,363 +154,88 @@ Rakefile: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets - cleanup_cops: &cleanup_cops - Bundler/OrderedGems: - Layout/AccessModifierIndentation: - Layout/ArrayAlignment: - Layout/ParameterAlignment: - Layout/BlockEndNewline: - Layout/CaseIndentation: - Layout/ClosingParenthesisIndentation: - Layout/CommentIndentation: - Layout/DotPosition: - Layout/ElseAlignment: - Layout/EmptyLineAfterMagicComment: - Layout/EmptyLineBetweenDefs: - Layout/EmptyLines: - Layout/EmptyLinesAroundAccessModifier: - Layout/EmptyLinesAroundBlockBody: - Layout/EmptyLinesAroundClassBody: - Layout/EmptyLinesAroundExceptionHandlingKeywords: - Layout/EmptyLinesAroundMethodBody: - Layout/EmptyLinesAroundModuleBody: - Layout/ExtraSpacing: - Layout/FirstParameterIndentation: - Layout/FirstArrayElementIndentation: - Layout/AssignmentIndentation: - Layout/FirstHashElementIndentation: - Layout/IndentationConsistency: - Layout/IndentationWidth: - Layout/InitialIndentation: - Layout/LeadingCommentSpace: - Layout/MultilineArrayBraceLayout: - Layout/MultilineBlockLayout: - Layout/MultilineHashBraceLayout: - Layout/MultilineMethodCallBraceLayout: - Layout/MultilineMethodCallIndentation: - Layout/MultilineMethodDefinitionBraceLayout: - Layout/MultilineOperationIndentation: - Layout/RescueEnsureAlignment: - Layout/SpaceAfterColon: - Layout/SpaceAfterComma: - Layout/SpaceAfterMethodName: - Layout/SpaceAfterNot: - Layout/SpaceAfterSemicolon: - Layout/SpaceAroundBlockParameters: - Layout/SpaceAroundEqualsInParameterDefault: - Layout/SpaceAroundKeyword: - Layout/SpaceAroundOperators: - Layout/SpaceBeforeBlockBraces: - Layout/SpaceBeforeComma: - Layout/SpaceBeforeComment: - Layout/SpaceBeforeFirstArg: - Layout/SpaceBeforeSemicolon: - Layout/SpaceInLambdaLiteral: - Layout/SpaceInsideArrayPercentLiteral: - Layout/SpaceInsideBlockBraces: - Layout/SpaceInsideHashLiteralBraces: - Layout/SpaceInsideParens: - Layout/SpaceInsidePercentLiteralDelimiters: - Layout/SpaceInsideRangeLiteral: - Layout/SpaceInsideStringInterpolation: - Layout/IndentationStyle: - Layout/TrailingEmptyLines: - Layout/TrailingWhitespace: - Layout/BlockAlignment: - Layout/DefEndAlignment: - Lint/DeprecatedClassMethods: - Lint/EmptyInterpolation: - Lint/LiteralInInterpolation: - Lint/MultipleComparison: - Lint/PercentStringArray: - Lint/PercentSymbolArray: - Lint/RescueType: - Lint/SafeNavigationChain: - Lint/RedundantStringCoercion: - Lint/UnifiedInteger: - Lint/RedundantSplatExpansion: - Lint/UnusedBlockArgument: - Lint/UnusedMethodArgument: - Performance/CaseWhenSplat: - Performance/Casecmp: - Performance/CompareWithBlock: - Performance/Count: - Performance/Detect: - Performance/DoubleStartEndWith: - Performance/FlatMap: - Performance/RangeInclude: - Performance/RedundantBlockCall: - Performance/RedundantMatch: - Performance/RedundantMerge: - Style/RedundantSortBy: - Performance/RegexpMatch: - Performance/ReverseEach: - Style/Sample: - Performance/Size: - Performance/StartWith: - Performance/StringReplacement: - Performance/TimesMap: - RSpec/BeEql: - RSpec/DescribedClass: - RSpec/EmptyLineAfterFinalLet: - RSpec/EmptyLineAfterSubject: - RSpec/ExampleWording: - RSpec/HookArgument: - RSpec/ImplicitExpect: - RSpec/InstanceSpy: - RSpec/ItBehavesLike: - RSpec/LeadingSubject: - RSpec/NotToNot: - RSpec/SharedContext: - RSpec/SingleArgumentMessageChain: - Security/JSONLoad: - Security/YAMLLoad: - Style/Alias: - Style/AndOr: - Style/ArrayJoin: - Style/Attr: - Style/BarePercentLiterals: - Style/BlockComments: - Style/BlockDelimiters: - Style/CharacterLiteral: - Style/ClassCheck: - Style/ClassMethods: - Style/CollectionMethods: - Style/ColonMethodCall: - Style/CommandLiteral: - Style/CommentAnnotation: - Style/ConditionalAssignment: - Style/DefWithParentheses: - Style/EachForSimpleLoop: - Style/EachWithObject: - Style/EmptyCaseCondition: - Style/EmptyElse: - Style/EmptyLiteral: - Style/EmptyMethod: - Style/EvenOdd: - Style/FormatString: - Style/HashSyntax: - Style/InfiniteLoop: - Style/InverseMethods: - Style/Lambda: - Style/LambdaCall: - Style/LineEndConcatenation: - Style/MethodCallWithoutArgsParentheses: - Style/MethodDefParentheses: - Style/MixinGrouping: - Style/MultilineIfThen: - Style/MultilineMemoization: - Style/MutableConstant: - Style/NegatedIf: - Style/NegatedWhile: - Style/NestedModifier: - Style/NestedParenthesizedCalls: - Style/Next: - Style/NilComparison: - Style/NonNilCheck: - Style/Not: - Style/NumericLiteralPrefix: - Style/NumericLiterals: - Style/OneLineConditional: - Style/ParallelAssignment: - Style/ParenthesesAroundCondition: - Style/PercentLiteralDelimiters: - Style/PercentQLiterals: - Style/PerlBackrefs: - Style/PreferredHashMethods: - Style/Proc: - Style/RaiseArgs: - Style/RedundantBegin: - Style/RedundantException: - Style/RedundantFreeze: - Style/RedundantParentheses: - Style/RedundantReturn: - Style/RedundantSelf: - Style/RegexpLiteral: - Style/RescueModifier: - Style/SafeNavigation: - Style/Semicolon: - Style/SignalException: - Style/SingleLineMethods: - Style/SpecialGlobalVars: - Style/StabbyLambdaParentheses: - Style/StringLiterals: - Style/StringLiteralsInInterpolation: - Style/StringMethods: - Style/SymbolArray: - Style/SymbolLiteral: - Style/TernaryParentheses: - Style/TrailingCommaInArguments: - Style/TrailingCommaInArrayLiteral: - Style/TrailingUnderscoreVariable: - Style/TrivialAccessors: - Style/UnlessElse: - Style/RedundantCapitalW: - Style/RedundantInterpolation: - Style/RedundantPercentQ: - Style/VariableInterpolation: - Style/WhenThen: - Style/WhileUntilDo: - Style/WhileUntilModifier: - Style/WordArray: - EnforcedStyle: brackets - Style/YodaCondition: - Style/ZeroLengthPredicate: + Style/TrailingCommaInHashLiteral: + Description: PDK generates multiline hashes with trailing commas. Align with Style/TrailingCommaInArguments and Style/TrailingCommaInArrayLiteral (both comma) so hash literals follow the same project style. + EnforcedStyleForMultiline: comma - profiles: - # no rubocops enabled, caveat emptor! - off: - enabled_cops: {} + # PDK/rspec-puppet convention cops -- tuned here (not in cop_overrides) because these + # are structural conventions of rspec-puppet and rspec-puppet-facts that every module + # scaffolded by PDK encounters, not module-specific style preferences (D-19). - # a sanitized list of cops that'll cleanup a code base without much effort - # they all support autocorrect, and should be fairly uncontroversial across - # wide segments of the Community. - cleanups_only: - configs: *default_configs - enabled_cops: *cleanup_cops + RSpec/DescribeClass: + Description: rspec-puppet describes its subject by string class/define name (no Ruby constant exists to reference), so this cop is never satisfiable for puppet specs. This is structurally inapplicable, not a style preference -- distinct from D-08 which governs style cops. + Enabled: false - # a good mix of cops with community recommended settings - strict: - configs: *default_configs - enabled_cops: - <<: *cleanup_cops - Bundler/DuplicatedGem: - Layout/EmptyLinesAroundBeginBody: - Lint/AmbiguousBlockAssociation: - Lint/AmbiguousOperator: - Lint/AmbiguousRegexpLiteral: - Lint/AssignmentInCondition: - Lint/CircularArgumentReference: - Layout/ConditionPosition: - Lint/Debugger: - Lint/DuplicateCaseCondition: - Lint/DuplicateMethods: - Lint/DuplicateHashKey: - Lint/EachWithObjectArgument: - Lint/ElseLayout: - Lint/EmptyEnsure: - Lint/EmptyExpression: - Lint/EmptyWhen: - Layout/EndAlignment: - Style/EndBlock: - Lint/EnsureReturn: - Lint/FloatOutOfRange: - Lint/FormatParameterMismatch: - Lint/SuppressedException: - Lint/ImplicitStringConcatenation: - Lint/IneffectiveAccessModifier: - Lint/InheritException: - Lint/LiteralAsCondition: - Lint/Loop: - Lint/NestedMethodDefinition: - Lint/NextWithoutAccumulator: - Lint/NonLocalExitFromIterator: - Lint/ParenthesesAsGroupedExpression: - Lint/RandOne: - Lint/RequireParentheses: - Lint/RescueException: - Lint/ScriptPermission: - Lint/ShadowedException: - Lint/ShadowingOuterLocalVariable: - Lint/UnderscorePrefixedVariableName: - Lint/RedundantCopDisableDirective: - Lint/UnreachableCode: - Lint/UselessAccessModifier: - Lint/UselessAssignment: - Lint/BinaryOperatorWithIdenticalOperands: - Lint/UselessElseWithoutRescue: - Lint/UselessSetterCall: - Lint/Void: - Layout/LineLength: - Performance/Caller: - Performance/EndWith: - Performance/FixedSize: - Style/HashEachMethods: - RSpec/AnyInstance: - RSpec/AroundBlock: - RSpec/BeforeAfterAll: - RSpec/DescribeMethod: - RSpec/DescribeSymbol: - RSpec/EmptyExampleGroup: - RSpec/ExpectActual: - RSpec/ExpectOutput: - RSpec/FilePath: - RSpec/Focus: - RSpec/InstanceVariable: - RSpec/IteratedExpectation: - RSpec/LetSetup: - RSpec/MessageChain: - RSpec/MessageSpies: - EnforcedStyle: receive - RSpec/MultipleDescribes: - RSpec/NamedSubject: - RSpec/OverwritingSetup: - RSpec/RepeatedDescription: - RSpec/RepeatedExample: - RSpec/ScatteredLet: - RSpec/ScatteredSetup: - RSpec/SubjectStub: - RSpec/VerifiedDoubles: - Security/Eval: - Security/IoMethods: - Security/MarshalLoad: - Security/Open: - Naming/AsciiIdentifiers: - Style/BeginBlock: - Style/CaseEquality: - Naming/ClassAndModuleCamelCase: - Style/ClassAndModuleChildren: - Style/ClassVars: - Naming/ConstantName: - Style/Documentation: - Exclude: - - 'lib/puppet/parser/functions/**/*' - - 'spec/**/*' - Style/DoubleNegation: - Naming/FileName: - Lint/FlipFlop: - Style/For: - Style/FormatStringToken: - Style/GlobalVars: - Style/GuardClause: - Style/IdenticalConditionalBranches: - Style/IfInsideElse: - Style/IfUnlessModifierOfIfUnless: - Style/IfWithSemicolon: - Style/MethodCalledOnDoEndBlock: - Lint/MissingSuper: - Style/MissingRespondToMissing: - Naming/MethodName: - Style/ModuleFunction: - Style/MultilineBlockChain: - Style/MultilineIfModifier: - Style/MultilineTernaryOperator: - Style/MultipleComparison: - Style/NestedTernaryOperator: - Naming/BinaryOperatorParameterName: - Style/OptionalArguments: - Naming/PredicateName: - Style/SelfAssignment: - Style/StructInheritance: - Naming/VariableName: - RSpec/VariableName: - Performance/AncestorsInclude: - Performance/BigDecimalWithNumericArgument: - Performance/BlockGivenWithExplicitBlock: - Performance/ConstantRegexp: - Performance/MethodObjectAsBlock: - Performance/RedundantSortBlock: - Performance/RedundantStringChars: - Performance/ReverseFirst: - Performance/SortReverse: - Performance/Squeeze: - Performance/StringInclude: - Performance/Sum: + RSpec/MessageSpies: + Description: The resource-API provider specs PDK generates legitimately use message spies (expect().to receive) in their scaffolded examples. Scoped to PDK-generated provider and transport spec paths only (D-08). + Exclude: + - 'spec/unit/puppet/provider/**/*_spec.rb' + - 'spec/unit/puppet/transport/**/*_spec.rb' - # Uses rubocop default cops - hardcore: + RSpec/ExampleLength: + Description: The resource-API provider specs PDK generates contain multi-line examples covering multiple CRUD operations. Scoped to PDK-generated provider and transport spec paths only (D-08). + Exclude: + - 'spec/unit/puppet/provider/**/*_spec.rb' + - 'spec/unit/puppet/transport/**/*_spec.rb' + + RSpec/MultipleExpectations: + Description: The resource-API provider specs PDK generates use multiple expectations per example to cover resource attribute checks. Scoped to PDK-generated provider and transport spec paths only (D-08). + Exclude: + - 'spec/unit/puppet/provider/**/*_spec.rb' + - 'spec/unit/puppet/transport/**/*_spec.rb' + + RSpec/VerifiedDoubleReference: + Description: The resource-API provider and transport specs PDK generates use string-referenced instance doubles (the Puppet provider constant is not loaded in the spec context). Scoped to PDK-generated provider and transport spec paths only (D-08). + Exclude: + - 'spec/unit/puppet/provider/**/*_spec.rb' + - 'spec/unit/puppet/transport/**/*_spec.rb' + + RSpec/ContextWording: + Description: rspec-puppet-facts uses the `context "on #{os}"` idiom in generated facts, class, and defined-type specs. The `on` prefix is added to the allowed list so this well-known idiom does not trigger the cop. + Prefixes: + - when + - with + - without + - 'on' + + Style/MixinUsage: + Description: rspec-puppet-facts requires the top-level `include RspecPuppetFacts` idiom in spec_helper, which cannot be cleanly restructured without breaking the facts test harness. Scoped to spec_helper only (D-07). + Exclude: + - 'spec/spec_helper.rb' + + Lint/EmptyClass: + Description: The generated transport device file uses the idiomatic Ruby namespace forward-declaration `class Puppet::Util::NetworkDevice; end`. An empty class is the standard namespace-shim idiom here and is not non-idiomatic code. Scoped to the network_device path only (D-08). + Exclude: + - 'lib/puppet/util/network_device/**/*.rb' + + profiles: + # Runs all cops using RuboCop's native NewCops: enable governance. + # EnforcedStyle settings from default_configs are applied. + 'on': &on_profile configs: *default_configs - enabled_cops: all + + # No cops enabled. Uses RuboCop's native DisabledByDefault switch + # instead of enumerating per-cop Enabled: false. + 'off': + configs: + AllCops: + DisabledByDefault: true + NewCops: disable + + # Backward-compatible aliases: cleanups_only, strict, and hardcore all + # resolve to the same output as on. Existing .sync.yml files that set + # any of these names continue to work with zero migration required. + cleanups_only: *on_profile + strict: *on_profile + hardcore: *on_profile + + # Authoritative maintainer override surface. Merged last (after defaults and + # profile configs), so entries here take precedence: + # defaults -> profile configs -> cop_overrides + # Add, configure, or disable individual cops here (e.g. CopName: { Enabled: false } + # or CopName: { EnforcedStyle: example }). In a module's .sync.yml, entries under + # this key deep-merge via PDK's @configs; the knockout prefix --- removes a value. + cop_overrides: {} Gemfile: required: ':development': diff --git a/moduleroot/.rubocop.yml.erb b/moduleroot/.rubocop.yml.erb index d68788d8..d92d068d 100644 --- a/moduleroot/.rubocop.yml.erb +++ b/moduleroot/.rubocop.yml.erb @@ -31,66 +31,20 @@ defaults = { }, } - defaults['inherit_from'] = '.rubocop_todo.yml' if @configs['include_todos'] defaults['AllCops']['TargetRubyVersion'] = @configs['TargetRubyVersion'] if @configs['TargetRubyVersion'] require 'deep_merge/core' -profile = @configs['profiles'][@configs['selected_profile']] +selected = @configs['selected_profile'] +# YAML 1.1 may coerce an unquoted on/off profile name to true/false; map it back. +selected = { true => 'on', false => 'off' }.fetch(selected, selected) +profile = @configs['profiles'] && @configs['profiles'][selected] +raise "Unknown rubocop selected_profile #{selected.inspect}; valid: #{(@configs['profiles'] || {}).keys.join(', ')}" unless profile.is_a?(Hash) && profile['configs'] configs = defaults.dup -DeepMerge::deep_merge!(profile['configs'], configs, knockout_prefix: "--", preserve_unmergeables: false) - -default_version = '1.50.0' - -# rubocop's dependencies have native extensions and are not available on windows currently -# to preserve the dynamic behaviour, and still work in its current state, this workaround -# will keep the lights on -version = begin - require 'rubocop/version' - RuboCop::Version.version -rescue LoadError - default_version -end - -# If people have a different rubocop installed, and supported in their template -# this allows them to use that configuration. -# If the rubocop version is not installed, fall back to the default -base_path = File.join(__FILE__, '..', '..', 'rubocop') -dynamic_path = File.absolute_path(File.join(base_path, "defaults-#{version}.yml")) -default_path = File.absolute_path(File.join(base_path, "defaults-#{default_version}.yml")) -path = File.exist?(dynamic_path) ? dynamic_path : default_path - -# The following block builds default_enabled_cops and default_pending_cops based on the existing values at defaults-.yml, which usually lives at ∼/rubocop/ -require 'yaml' -config_defaults = YAML.load(File.read(path)) -default_enabled_cops = config_defaults[:default_enabled_cops] || [] -default_pending_cops = config_defaults[:default_pending_cops] || [] +DeepMerge::deep_merge!(profile['configs'], configs, knockout_prefix: "---", preserve_unmergeables: false) -# This line builds cop_configs based on the values existing at profile, which was previously configured to retrieve the values of a specific profile in config_defaults.yml -cop_configs = (profile['enabled_cops'] || {}) - -if cop_configs == 'all' - enabled_cops = default_enabled_cops + default_pending_cops -elsif cop_configs.respond_to?(:keys) - enabled_cops = cop_configs.keys -else - enabled_cops = [] +if @configs['cop_overrides'] && !@configs['cop_overrides'].empty? + DeepMerge::deep_merge!(@configs['cop_overrides'], configs, knockout_prefix: "---", preserve_unmergeables: false) end - -# Create a filtered list of enabled cops that should be disabled. -disabled_cops = enabled_cops.select { |c| configs[c] && configs[c]['Enabled'] == false } - -# The following block builds the final configuration based on the values of enabled_cops, default_enabled_cops, default_pending_cops, and cop_configs -(enabled_cops & default_enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] if cop_configs[c] } -(enabled_cops - default_enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] || {}; configs[c]['Enabled'] = true } -(default_enabled_cops - enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] || {}; configs[c]['Enabled'] = false } - -# force set pending cops to something to avoid the messages -(default_pending_cops & enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] if cop_configs[c]; configs[c]['Enabled'] = true } -(default_pending_cops - enabled_cops).sort.each { |c| configs[c] = { 'Enabled' => false } } - -# Set overriden cops to false if 'Enabled: false'. This can be the case when users override default behaviour via .sync.yml -(disabled_cops).sort.each { |c| configs[c] = { 'Enabled' => false } } - -%> <%= YAML.dump(configs) -%> diff --git a/object_templates/functions/v4_function.erb b/object_templates/functions/v4_function.erb index 6b253af6..68fe65fe 100644 --- a/object_templates/functions/v4_function.erb +++ b/object_templates/functions/v4_function.erb @@ -2,7 +2,7 @@ <% dispatch_name = name.split(':').last -%> # https://github.com/puppetlabs/puppet-specifications/blob/master/language/func-api.md#the-4x-api -Puppet::Functions.create_function(<%= name.to_sym.inspect %>) do +Puppet::Functions.create_function(:'<%= name %>') do dispatch <%= dispatch_name.to_sym.inspect %> do param 'Numeric', :a return_type 'Numeric' @@ -10,10 +10,10 @@ Puppet::Functions.create_function(<%= name.to_sym.inspect %>) do # the function below is called by puppet and and must match # the name of the puppet function above. You can set your # required parameters below and puppet will enforce these - # so change x to suit your needs although only one parameter is required + # so change value to suit your needs although only one parameter is required # as defined in the dispatch method. - def <%= dispatch_name %>(x) - x * 2 + def <%= dispatch_name %>(value) + value * 2 end # you can define other helper methods in this code block as well diff --git a/object_templates/provider.erb b/object_templates/provider.erb index 1914a6f9..d2066779 100644 --- a/object_templates/provider.erb +++ b/object_templates/provider.erb @@ -11,10 +11,6 @@ class Puppet::Provider::<%= provider_class %>::<%= provider_class %> < Puppet::R name: 'foo', ensure: 'present', }, - { - name: 'bar', - ensure: 'present', - }, ] end diff --git a/object_templates/provider_spec.erb b/object_templates/provider_spec.erb index db65f3a8..8ab9d996 100644 --- a/object_templates/provider_spec.erb +++ b/object_templates/provider_spec.erb @@ -18,10 +18,6 @@ RSpec.describe Puppet::Provider::<%= provider_class %>::<%= provider_class %> do name: 'foo', ensure: 'present', }, - { - name: 'bar', - ensure: 'present', - }, ] end end diff --git a/object_templates/provider_type.erb b/object_templates/provider_type.erb index ba32cfe6..fe82ec8d 100644 --- a/object_templates/provider_type.erb +++ b/object_templates/provider_type.erb @@ -4,20 +4,20 @@ require 'puppet/resource_api' Puppet::ResourceApi.register_type( name: '<%= name %>', - docs: <<-EOS, -@summary a <%= name %> type -@example -<%= name %> { 'foo': - ensure => 'present', -} + docs: <<~DOCS, + @summary a <%= name %> type + @example + <%= name %> { 'foo': + ensure => 'present', + } -This type provides Puppet with the capabilities to manage ... + This type provides Puppet with the capabilities to manage ... -If your type uses autorequires, please document as shown below, else delete -these lines. -**Autorequires**: -* `Package[foo]` -EOS + If your type uses autorequires, please document as shown below, else delete + these lines. + **Autorequires**: + * `Package[foo]` + DOCS features: [], attributes: { ensure: { diff --git a/object_templates/transport_device.erb b/object_templates/transport_device.erb index ac9f0665..95065af8 100644 --- a/object_templates/transport_device.erb +++ b/object_templates/transport_device.erb @@ -7,7 +7,7 @@ class Puppet::Util::NetworkDevice; end # The <%= name.capitalize %> module only contains the Device class to bridge from puppet's internals to the Transport. # All the heavy lifting is done bye the Puppet::ResourceApi::Transport::Wrapper -module Puppet::Util::NetworkDevice::<%= name.capitalize %> # rubocop:disable<% if name.include?('_') %> Style/ClassAndModuleCamelCase,<% end %> Style/ClassAndModuleChildren +module Puppet::Util::NetworkDevice::<%= name.capitalize %> # rubocop:disable<% if name.include?('_') %> Naming/ClassAndModuleCamelCase,<% end %> Style/ClassAndModuleChildren # Bridging from puppet to the <%= name %> transport class Device < Puppet::ResourceApi::Transport::Wrapper def initialize(url_or_config, _options = {}) diff --git a/object_templates/transport_type.erb b/object_templates/transport_type.erb index fcb4edd1..afce1ed8 100644 --- a/object_templates/transport_type.erb +++ b/object_templates/transport_type.erb @@ -4,9 +4,9 @@ require 'puppet/resource_api' Puppet::ResourceApi.register_transport( name: '<%= name %>', - desc: <<-EOS, - This transport provides Puppet with the capability to connect to <%= name %> targets. - EOS + desc: <<~DESC, + This transport provides Puppet with the capability to connect to <%= name %> targets. + DESC features: [], connection_info: { host: { @@ -22,8 +22,8 @@ Puppet::ResourceApi.register_transport( desc: 'The name of the user to authenticate as.', }, password: { - type: 'String', - desc: 'The password for the user.', + type: 'String', + desc: 'The password for the user.', sensitive: true, }, }, diff --git a/rubocop/README.md b/rubocop/README.md deleted file mode 100644 index c6226846..00000000 --- a/rubocop/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Building Rubocop default profile - -To build the default profile for your version of rubocop, run: - -``` -bundle exec profile_builder.rb -``` - -This will build the enabled cops for this version of rubocop. - -Do NOT manually update default profile! diff --git a/rubocop/cleanup_cops.yml b/rubocop/cleanup_cops.yml deleted file mode 100644 index ec082b95..00000000 --- a/rubocop/cleanup_cops.yml +++ /dev/null @@ -1,202 +0,0 @@ ---- -- Bundler/OrderedGems -- Layout/AccessModifierIndentation -- Layout/ArrayAlignment -- Layout/ParameterAlignment -- Layout/BlockEndNewline -- Layout/CaseIndentation -- Layout/ClosingParenthesisIndentation -- Layout/CommentIndentation -- Layout/DotPosition -- Layout/ElseAlignment -- Layout/EmptyLineAfterMagicComment -- Layout/EmptyLineBetweenDefs -- Layout/EmptyLines -- Layout/EmptyLinesAroundAccessModifier -- Layout/EmptyLinesAroundBlockBody -- Layout/EmptyLinesAroundClassBody -- Layout/EmptyLinesAroundExceptionHandlingKeywords -- Layout/EmptyLinesAroundMethodBody -- Layout/EmptyLinesAroundModuleBody -- Layout/ExtraSpacing -- Layout/FirstParameterIndentation -- Layout/FirstArrayElementIndentation -- Layout/AssignmentIndentation -- Layout/FirstHashElementIndentation -- Layout/IndentationConsistency -- Layout/IndentationWidth -- Layout/InitialIndentation -- Layout/LeadingCommentSpace -- Layout/MultilineArrayBraceLayout -- Layout/MultilineBlockLayout -- Layout/MultilineHashBraceLayout -- Layout/MultilineMethodCallBraceLayout -- Layout/MultilineMethodCallIndentation -- Layout/MultilineMethodDefinitionBraceLayout -- Layout/MultilineOperationIndentation -- Layout/RescueEnsureAlignment -- Layout/SpaceAfterColon -- Layout/SpaceAfterComma -- Layout/SpaceAfterMethodName -- Layout/SpaceAfterNot -- Layout/SpaceAfterSemicolon -- Layout/SpaceAroundBlockParameters -- Layout/SpaceAroundEqualsInParameterDefault -- Layout/SpaceAroundKeyword -- Layout/SpaceAroundOperators -- Layout/SpaceBeforeBlockBraces -- Layout/SpaceBeforeComma -- Layout/SpaceBeforeComment -- Layout/SpaceBeforeFirstArg -- Layout/SpaceBeforeSemicolon -- Layout/SpaceInLambdaLiteral -- Layout/SpaceInsideArrayPercentLiteral -- Layout/SpaceInsideBlockBraces -- Layout/SpaceInsideHashLiteralBraces -- Layout/SpaceInsideParens -- Layout/SpaceInsidePercentLiteralDelimiters -- Layout/SpaceInsideRangeLiteral -- Layout/SpaceInsideStringInterpolation -- Layout/IndentationStyle -- Layout/TrailingEmptyLines -- Layout/TrailingWhitespace -- Layout/BlockAlignment -- Layout/DefEndAlignment -- Lint/DeprecatedClassMethods -- Lint/EmptyInterpolation -- Lint/LiteralInInterpolation -- Lint/MultipleComparison -- Lint/PercentStringArray -- Lint/PercentSymbolArray -- Lint/RescueType -- Lint/SafeNavigationChain -- Lint/RedundantStringCoercion -- Lint/UnifiedInteger -- Lint/RedundantSplatExpansion -- Lint/UnusedBlockArgument -- Lint/UnusedMethodArgument -- Performance/CaseWhenSplat -- Performance/Casecmp -- Performance/CompareWithBlock -- Performance/Count -- Performance/Detect -- Performance/DoubleStartEndWith -- Performance/FlatMap -- Performance/RangeInclude -- Performance/RedundantBlockCall -- Performance/RedundantMatch -- Performance/RedundantMerge -- Style/RedundantSortBy -- Performance/RegexpMatch -- Performance/ReverseEach -- Style/Sample -- Performance/Size -- Performance/StartWith -- Performance/StringReplacement -- Performance/TimesMap -- RSpec/BeEql -- RSpec/DescribedClass -- RSpec/EmptyLineAfterFinalLet -- RSpec/EmptyLineAfterSubject -- RSpec/ExampleWording -- RSpec/HookArgument -- RSpec/ImplicitExpect -- RSpec/InstanceSpy -- RSpec/ItBehavesLike -- RSpec/LeadingSubject -- RSpec/NotToNot -- RSpec/SharedContext -- RSpec/SingleArgumentMessageChain -- Security/JSONLoad -- Security/YAMLLoad -- Style/Alias -- Style/AndOr -- Style/ArrayJoin -- Style/Attr -- Style/BarePercentLiterals -- Style/BlockComments -- Style/BlockDelimiters -- Style/CharacterLiteral -- Style/ClassCheck -- Style/ClassMethods -- Style/CollectionMethods -- Style/ColonMethodCall -- Style/CommandLiteral -- Style/CommentAnnotation -- Style/ConditionalAssignment -- Style/DefWithParentheses -- Style/EachForSimpleLoop -- Style/EachWithObject -- Style/EmptyCaseCondition -- Style/EmptyElse -- Style/EmptyLiteral -- Style/EmptyMethod -- Style/EvenOdd -- Style/FormatString -- Style/FrozenStringLiteralComment -- Style/HashSyntax -- Style/InfiniteLoop -- Style/InverseMethods -- Style/Lambda -- Style/LambdaCall -- Style/LineEndConcatenation -- Style/MethodCallWithoutArgsParentheses -- Style/MethodDefParentheses -- Style/MixinGrouping -- Style/MultilineIfThen -- Style/MultilineMemoization -- Style/MutableConstant -- Style/NegatedIf -- Style/NegatedWhile -- Style/NestedModifier -- Style/NestedParenthesizedCalls -- Style/Next -- Style/NilComparison -- Style/NonNilCheck -- Style/Not -- Style/NumericLiteralPrefix -- Style/NumericLiterals -- Style/OneLineConditional -- Style/ParallelAssignment -- Style/ParenthesesAroundCondition -- Style/PercentLiteralDelimiters -- Style/PercentQLiterals -- Style/PerlBackrefs -- Style/PreferredHashMethods -- Style/Proc -- Style/RaiseArgs -- Style/RedundantBegin -- Style/RedundantException -- Style/RedundantFreeze -- Style/RedundantParentheses -- Style/RedundantReturn -- Style/RedundantSelf -- Style/RegexpLiteral -- Style/RescueModifier -- Style/SafeNavigation -- Style/Semicolon -- Style/SignalException -- Style/SingleLineMethods -- Style/SpecialGlobalVars -- Style/StabbyLambdaParentheses -- Style/StringLiterals -- Style/StringLiteralsInInterpolation -- Style/StringMethods -- Style/SymbolArray -- Style/SymbolLiteral -- Style/TernaryParentheses -- Style/TrailingCommaInArguments -- Style/TrailingCommaInArrayLiteral -- Style/TrailingUnderscoreVariable -- Style/TrivialAccessors -- Style/UnlessElse -- Style/RedundantCapitalW -- Style/RedundantInterpolation -- Style/RedundantPercentQ -- Style/VariableInterpolation -- Style/WhenThen -- Style/WhileUntilDo -- Style/WhileUntilModifier -- Style/WordArray -- Style/YodaCondition -- Style/ZeroLengthPredicate diff --git a/rubocop/defaults-1.50.0.yml b/rubocop/defaults-1.50.0.yml deleted file mode 100644 index 859f5c1b..00000000 --- a/rubocop/defaults-1.50.0.yml +++ /dev/null @@ -1,633 +0,0 @@ ---- -:default_enabled_cops: -- Bundler/DuplicatedGem -- Bundler/GemFilename -- Bundler/InsecureProtocolSource -- Bundler/OrderedGems -- Capybara/CurrentPathExpectation -- Capybara/VisibilityMatcher -- Gemspec/DuplicatedAssignment -- Gemspec/OrderedDependencies -- Gemspec/RequiredRubyVersion -- Gemspec/RubyVersionGlobalsUsage -- Layout/AccessModifierIndentation -- Layout/ArgumentAlignment -- Layout/ArrayAlignment -- Layout/AssignmentIndentation -- Layout/BeginEndAlignment -- Layout/BlockAlignment -- Layout/BlockEndNewline -- Layout/CaseIndentation -- Layout/ClosingHeredocIndentation -- Layout/ClosingParenthesisIndentation -- Layout/CommentIndentation -- Layout/ConditionPosition -- Layout/DefEndAlignment -- Layout/DotPosition -- Layout/ElseAlignment -- Layout/EmptyComment -- Layout/EmptyLineAfterGuardClause -- Layout/EmptyLineAfterMagicComment -- Layout/EmptyLineBetweenDefs -- Layout/EmptyLines -- Layout/EmptyLinesAroundAccessModifier -- Layout/EmptyLinesAroundArguments -- Layout/EmptyLinesAroundAttributeAccessor -- Layout/EmptyLinesAroundBeginBody -- Layout/EmptyLinesAroundBlockBody -- Layout/EmptyLinesAroundClassBody -- Layout/EmptyLinesAroundExceptionHandlingKeywords -- Layout/EmptyLinesAroundMethodBody -- Layout/EmptyLinesAroundModuleBody -- Layout/EndAlignment -- Layout/EndOfLine -- Layout/ExtraSpacing -- Layout/FirstArgumentIndentation -- Layout/FirstArrayElementIndentation -- Layout/FirstHashElementIndentation -- Layout/FirstParameterIndentation -- Layout/HashAlignment -- Layout/HeredocIndentation -- Layout/IndentationConsistency -- Layout/IndentationStyle -- Layout/IndentationWidth -- Layout/InitialIndentation -- Layout/LeadingCommentSpace -- Layout/LeadingEmptyLines -- Layout/LineLength -- Layout/MultilineArrayBraceLayout -- Layout/MultilineBlockLayout -- Layout/MultilineHashBraceLayout -- Layout/MultilineMethodCallBraceLayout -- Layout/MultilineMethodCallIndentation -- Layout/MultilineMethodDefinitionBraceLayout -- Layout/MultilineOperationIndentation -- Layout/ParameterAlignment -- Layout/RescueEnsureAlignment -- Layout/SpaceAfterColon -- Layout/SpaceAfterComma -- Layout/SpaceAfterMethodName -- Layout/SpaceAfterNot -- Layout/SpaceAfterSemicolon -- Layout/SpaceAroundBlockParameters -- Layout/SpaceAroundEqualsInParameterDefault -- Layout/SpaceAroundKeyword -- Layout/SpaceAroundMethodCallOperator -- Layout/SpaceAroundOperators -- Layout/SpaceBeforeBlockBraces -- Layout/SpaceBeforeComma -- Layout/SpaceBeforeComment -- Layout/SpaceBeforeFirstArg -- Layout/SpaceBeforeSemicolon -- Layout/SpaceInLambdaLiteral -- Layout/SpaceInsideArrayLiteralBrackets -- Layout/SpaceInsideArrayPercentLiteral -- Layout/SpaceInsideBlockBraces -- Layout/SpaceInsideHashLiteralBraces -- Layout/SpaceInsideParens -- Layout/SpaceInsidePercentLiteralDelimiters -- Layout/SpaceInsideRangeLiteral -- Layout/SpaceInsideReferenceBrackets -- Layout/SpaceInsideStringInterpolation -- Layout/TrailingEmptyLines -- Layout/TrailingWhitespace -- Lint/AmbiguousBlockAssociation -- Lint/AmbiguousOperator -- Lint/AmbiguousRegexpLiteral -- Lint/AssignmentInCondition -- Lint/BigDecimalNew -- Lint/BinaryOperatorWithIdenticalOperands -- Lint/BooleanSymbol -- Lint/CircularArgumentReference -- Lint/ConstantDefinitionInBlock -- Lint/Debugger -- Lint/DeprecatedClassMethods -- Lint/DeprecatedOpenSSLConstant -- Lint/DisjunctiveAssignmentInConstructor -- Lint/DuplicateCaseCondition -- Lint/DuplicateElsifCondition -- Lint/DuplicateHashKey -- Lint/DuplicateMethods -- Lint/DuplicateRequire -- Lint/DuplicateRescueException -- Lint/EachWithObjectArgument -- Lint/ElseLayout -- Lint/EmptyConditionalBody -- Lint/EmptyEnsure -- Lint/EmptyExpression -- Lint/EmptyFile -- Lint/EmptyInterpolation -- Lint/EmptyWhen -- Lint/EnsureReturn -- Lint/ErbNewArguments -- Lint/FlipFlop -- Lint/FloatComparison -- Lint/FloatOutOfRange -- Lint/FormatParameterMismatch -- Lint/HashCompareByIdentity -- Lint/IdentityComparison -- Lint/ImplicitStringConcatenation -- Lint/IneffectiveAccessModifier -- Lint/InheritException -- Lint/InterpolationCheck -- Lint/LiteralAsCondition -- Lint/LiteralInInterpolation -- Lint/Loop -- Lint/MissingCopEnableDirective -- Lint/MissingSuper -- Lint/MixedRegexpCaptureTypes -- Lint/MultipleComparison -- Lint/NestedMethodDefinition -- Lint/NestedPercentLiteral -- Lint/NextWithoutAccumulator -- Lint/NonDeterministicRequireOrder -- Lint/NonLocalExitFromIterator -- Lint/OrderedMagicComments -- Lint/OutOfRangeRegexpRef -- Lint/ParenthesesAsGroupedExpression -- Lint/PercentStringArray -- Lint/PercentSymbolArray -- Lint/RaiseException -- Lint/RandOne -- Lint/RedundantCopDisableDirective -- Lint/RedundantCopEnableDirective -- Lint/RedundantRequireStatement -- Lint/RedundantSafeNavigation -- Lint/RedundantSplatExpansion -- Lint/RedundantStringCoercion -- Lint/RedundantWithIndex -- Lint/RedundantWithObject -- Lint/RegexpAsCondition -- Lint/RequireParentheses -- Lint/RescueException -- Lint/RescueType -- Lint/ReturnInVoidContext -- Lint/SafeNavigationChain -- Lint/SafeNavigationConsistency -- Lint/SafeNavigationWithEmpty -- Lint/ScriptPermission -- Lint/SelfAssignment -- Lint/SendWithMixinArgument -- Lint/ShadowedArgument -- Lint/ShadowedException -- Lint/ShadowingOuterLocalVariable -- Lint/StructNewOverride -- Lint/SuppressedException -- Lint/ToJSON -- Lint/TopLevelReturnWithArgument -- Lint/TrailingCommaInAttributeDeclaration -- Lint/UnderscorePrefixedVariableName -- Lint/UnifiedInteger -- Lint/UnreachableCode -- Lint/UnreachableLoop -- Lint/UnusedBlockArgument -- Lint/UnusedMethodArgument -- Lint/UriEscapeUnescape -- Lint/UriRegexp -- Lint/UselessAccessModifier -- Lint/UselessAssignment -- Lint/UselessElseWithoutRescue -- Lint/UselessMethodDefinition -- Lint/UselessSetterCall -- Lint/UselessTimes -- Lint/Void -- Metrics/AbcSize -- Metrics/BlockLength -- Metrics/BlockNesting -- Metrics/ClassLength -- Metrics/CyclomaticComplexity -- Metrics/MethodLength -- Metrics/ModuleLength -- Metrics/ParameterLists -- Metrics/PerceivedComplexity -- Migration/DepartmentName -- Naming/AccessorMethodName -- Naming/AsciiIdentifiers -- Naming/BinaryOperatorParameterName -- Naming/BlockParameterName -- Naming/ClassAndModuleCamelCase -- Naming/ConstantName -- Naming/FileName -- Naming/HeredocDelimiterCase -- Naming/HeredocDelimiterNaming -- Naming/MemoizedInstanceVariableName -- Naming/MethodName -- Naming/MethodParameterName -- Naming/PredicateName -- Naming/RescuedExceptionsVariableName -- Naming/VariableName -- Naming/VariableNumber -- Performance/BindCall -- Performance/Caller -- Performance/Casecmp -- Performance/CompareWithBlock -- Performance/Count -- Performance/DeletePrefix -- Performance/DeleteSuffix -- Performance/Detect -- Performance/DoubleStartEndWith -- Performance/EndWith -- Performance/FixedSize -- Performance/FlatMap -- Performance/InefficientHashSearch -- Performance/RangeInclude -- Performance/RedundantBlockCall -- Performance/RedundantMatch -- Performance/RedundantMerge -- Performance/RegexpMatch -- Performance/ReverseEach -- Performance/Size -- Performance/StartWith -- Performance/StringReplacement -- Performance/TimesMap -- Performance/UnfreezeString -- Performance/UriDefaultParser -- RSpec/AnyInstance -- RSpec/AroundBlock -- RSpec/Be -- RSpec/BeEql -- RSpec/BeforeAfterAll -- RSpec/ContainExactly -- RSpec/ContextMethod -- RSpec/ContextWording -- RSpec/DescribeClass -- RSpec/DescribeMethod -- RSpec/DescribeSymbol -- RSpec/DescribedClass -- RSpec/Dialect -- RSpec/EmptyExampleGroup -- RSpec/EmptyHook -- RSpec/EmptyLineAfterExample -- RSpec/EmptyLineAfterExampleGroup -- RSpec/EmptyLineAfterFinalLet -- RSpec/EmptyLineAfterHook -- RSpec/EmptyLineAfterSubject -- RSpec/ExampleLength -- RSpec/ExampleWithoutDescription -- RSpec/ExampleWording -- RSpec/ExpectActual -- RSpec/ExpectChange -- RSpec/ExpectInHook -- RSpec/ExpectOutput -- FactoryBot/AttributeDefinedStatically -- FactoryBot/CreateList -- FactoryBot/FactoryClassName -- RSpec/FilePath -- RSpec/Focus -- RSpec/HookArgument -- RSpec/HooksBeforeExamples -- RSpec/ImplicitBlockExpectation -- RSpec/ImplicitExpect -- RSpec/ImplicitSubject -- RSpec/InstanceSpy -- RSpec/InstanceVariable -- RSpec/ItBehavesLike -- RSpec/IteratedExpectation -- RSpec/LeadingSubject -- RSpec/LeakyConstantDeclaration -- RSpec/LetBeforeExamples -- RSpec/LetSetup -- RSpec/MatchArray -- RSpec/MessageChain -- RSpec/MessageSpies -- RSpec/MissingExampleGroupArgument -- RSpec/MultipleDescribes -- RSpec/MultipleExpectations -- RSpec/MultipleMemoizedHelpers -- RSpec/MultipleSubjects -- RSpec/NamedSubject -- RSpec/NestedGroups -- RSpec/NotToNot -- RSpec/OverwritingSetup -- RSpec/PredicateMatcher -- RSpec/ReceiveCounts -- RSpec/ReceiveNever -- RSpec/RepeatedDescription -- RSpec/RepeatedExample -- RSpec/RepeatedExampleGroupBody -- RSpec/RepeatedExampleGroupDescription -- RSpec/RepeatedIncludeExample -- RSpec/ReturnFromStub -- RSpec/ScatteredLet -- RSpec/ScatteredSetup -- RSpec/SharedContext -- RSpec/SharedExamples -- RSpec/SingleArgumentMessageChain -- RSpec/StubbedMock -- RSpec/SubjectStub -- RSpec/UnspecifiedException -- RSpec/VariableDefinition -- RSpec/VariableName -- RSpec/VerifiedDoubles -- RSpec/VoidExpect -- RSpec/Yield -- Security/Eval -- Security/JSONLoad -- Security/MarshalLoad -- Security/Open -- Security/YAMLLoad -- Style/AccessModifierDeclarations -- Style/AccessorGrouping -- Style/Alias -- Style/AndOr -- Style/ArrayJoin -- Style/Attr -- Style/BarePercentLiterals -- Style/BeginBlock -- Style/BisectedAttrAccessor -- Style/BlockComments -- Style/BlockDelimiters -- Style/CaseEquality -- Style/CaseLikeIf -- Style/CharacterLiteral -- Style/ClassAndModuleChildren -- Style/ClassCheck -- Style/ClassEqualityComparison -- Style/ClassMethods -- Style/ClassVars -- Style/ColonMethodCall -- Style/ColonMethodDefinition -- Style/CombinableLoops -- Style/CommandLiteral -- Style/CommentAnnotation -- Style/CommentedKeyword -- Style/ConditionalAssignment -- Style/DefWithParentheses -- Style/Dir -- Style/Documentation -- Style/DoubleCopDisableDirective -- Style/DoubleNegation -- Style/EachForSimpleLoop -- Style/EachWithObject -- Style/EmptyBlockParameter -- Style/EmptyCaseCondition -- Style/EmptyElse -- Style/EmptyLambdaParameter -- Style/EmptyLiteral -- Style/EmptyMethod -- Style/Encoding -- Style/EndBlock -- Style/EvalWithLocation -- Style/EvenOdd -- Style/ExpandPathArguments -- Style/ExplicitBlockArgument -- Style/ExponentialNotation -- Style/FloatDivision -- Style/For -- Style/FormatString -- Style/FormatStringToken -- Style/FrozenStringLiteralComment -- Style/GlobalStdStream -- Style/GlobalVars -- Style/GuardClause -- Style/HashAsLastArrayItem -- Style/HashEachMethods -- Style/HashLikeCase -- Style/HashSyntax -- Style/HashTransformKeys -- Style/HashTransformValues -- Style/IdenticalConditionalBranches -- Style/IfInsideElse -- Style/IfUnlessModifier -- Style/IfUnlessModifierOfIfUnless -- Style/IfWithSemicolon -- Style/InfiniteLoop -- Style/InverseMethods -- Style/KeywordParametersOrder -- Style/Lambda -- Style/LambdaCall -- Style/LineEndConcatenation -- Style/MethodCallWithoutArgsParentheses -- Style/MethodDefParentheses -- Style/MinMax -- Style/MissingRespondToMissing -- Style/MixinGrouping -- Style/MixinUsage -- Style/ModuleFunction -- Style/MultilineBlockChain -- Style/MultilineIfModifier -- Style/MultilineIfThen -- Style/MultilineMemoization -- Style/MultilineTernaryOperator -- Style/MultilineWhenThen -- Style/MultipleComparison -- Style/MutableConstant -- Style/NegatedIf -- Style/NegatedUnless -- Style/NegatedWhile -- Style/NestedModifier -- Style/NestedParenthesizedCalls -- Style/NestedTernaryOperator -- Style/Next -- Style/NilComparison -- Style/NonNilCheck -- Style/Not -- Style/NumericLiteralPrefix -- Style/NumericLiterals -- Style/NumericPredicate -- Style/OneLineConditional -- Style/OptionalArguments -- Style/OptionalBooleanParameter -- Style/OrAssignment -- Style/ParallelAssignment -- Style/ParenthesesAroundCondition -- Style/PercentLiteralDelimiters -- Style/PercentQLiterals -- Style/PerlBackrefs -- Style/PreferredHashMethods -- Style/Proc -- Style/RaiseArgs -- Style/RandomWithOffset -- Style/RedundantAssignment -- Style/RedundantBegin -- Style/RedundantCapitalW -- Style/RedundantCondition -- Style/RedundantConditional -- Style/RedundantException -- Style/RedundantFetchBlock -- Style/RedundantFileExtensionInRequire -- Style/RedundantFreeze -- Style/RedundantInterpolation -- Style/RedundantParentheses -- Style/RedundantPercentQ -- Style/RedundantRegexpCharacterClass -- Style/RedundantRegexpEscape -- Style/RedundantReturn -- Style/RedundantSelf -- Style/RedundantSelfAssignment -- Style/RedundantSort -- Style/RedundantSortBy -- Style/RegexpLiteral -- Style/RescueModifier -- Style/RescueStandardError -- Style/SafeNavigation -- Style/Sample -- Style/SelfAssignment -- Style/Semicolon -- Style/SignalException -- Style/SingleArgumentDig -- Style/SingleLineMethods -- Style/SlicingWithRange -- Style/SoleNestedConditional -- Style/SpecialGlobalVars -- Style/StabbyLambdaParentheses -- Style/StderrPuts -- Style/StringConcatenation -- Style/StringLiterals -- Style/StringLiteralsInInterpolation -- Style/Strip -- Style/StructInheritance -- Style/SymbolArray -- Style/SymbolLiteral -- Style/SymbolProc -- Style/TernaryParentheses -- Style/TrailingBodyOnClass -- Style/TrailingBodyOnMethodDefinition -- Style/TrailingBodyOnModule -- Style/TrailingCommaInArguments -- Style/TrailingCommaInArrayLiteral -- Style/TrailingCommaInHashLiteral -- Style/TrailingMethodEndStatement -- Style/TrailingUnderscoreVariable -- Style/TrivialAccessors -- Style/UnlessElse -- Style/UnpackFirst -- Style/VariableInterpolation -- Style/WhenThen -- Style/WhileUntilDo -- Style/WhileUntilModifier -- Style/WordArray -- Style/YodaCondition -- Style/ZeroLengthPredicate -:default_pending_cops: -- Capybara/MatchStyle -- Capybara/NegationMatcher -- Capybara/SpecificActions -- Capybara/SpecificFinders -- Capybara/SpecificMatcher -- Gemspec/DeprecatedAttributeAssignment -- Gemspec/DevelopmentDependencies -- Gemspec/RequireMFA -- Layout/LineContinuationLeadingSpace -- Layout/LineContinuationSpacing -- Layout/LineEndStringConcatenationIndentation -- Layout/SpaceBeforeBrackets -- Lint/AmbiguousAssignment -- Lint/AmbiguousOperatorPrecedence -- Lint/AmbiguousRange -- Lint/ConstantOverwrittenInRescue -- Lint/DeprecatedConstants -- Lint/DuplicateBranch -- Lint/DuplicateMagicComment -- Lint/DuplicateMatchPattern -- Lint/DuplicateRegexpCharacterClassElement -- Lint/EmptyBlock -- Lint/EmptyClass -- Lint/EmptyInPattern -- Lint/IncompatibleIoSelectWithFiberScheduler -- Lint/LambdaWithoutLiteralBlock -- Lint/NoReturnInBeginEndBlocks -- Lint/NonAtomicFileOperation -- Lint/NumberedParameterAssignment -- Lint/OrAssignmentToConstant -- Lint/RedundantDirGlobSort -- Lint/RefinementImportMethods -- Lint/RequireRangeParentheses -- Lint/RequireRelativeSelfPath -- Lint/SymbolConversion -- Lint/ToEnumArguments -- Lint/TripleQuotes -- Lint/UnexpectedBlockArity -- Lint/UnmodifiedReduceAccumulator -- Lint/UselessRescue -- Lint/UselessRuby2Keywords -- Metrics/CollectionLiteralLength -- Naming/BlockForwarding -- Performance/AncestorsInclude -- Performance/BigDecimalWithNumericArgument -- Performance/BlockGivenWithExplicitBlock -- Performance/CollectionLiteralInLoop -- Performance/ConcurrentMonotonicTime -- Performance/ConstantRegexp -- Performance/MapCompact -- Performance/MethodObjectAsBlock -- Performance/RedundantEqualityComparisonBlock -- Performance/RedundantSortBlock -- Performance/RedundantSplitRegexpArgument -- Performance/RedundantStringChars -- Performance/ReverseFirst -- Performance/SortReverse -- Performance/Squeeze -- Performance/StringIdentifierArgument -- Performance/StringInclude -- Performance/Sum -- RSpec/BeEq -- RSpec/BeNil -- RSpec/ChangeByZero -- RSpec/ClassCheck -- RSpec/DuplicatedMetadata -- RSpec/ExcessiveDocstringSpacing -- FactoryBot/ConsistentParenthesesStyle -- FactoryBot/FactoryNameStyle -- FactoryBot/SyntaxMethods -- RSpec/IdenticalEqualityAssertion -- RSpec/NoExpectationExample -- RSpec/PendingWithoutReason -- RSpecRails/AvoidSetupHook -- RSpecRails/HaveHttpStatus -- RSpecRails/InferredSpecType -- RSpecRails/MinitestAssertions -- RSpecRails/TravelAround -- RSpec/RedundantAround -- RSpec/SkipBlockInsideExample -- RSpec/SortMetadata -- RSpec/SubjectDeclaration -- RSpec/VerifiedDoubleReference -- Security/CompoundHash -- Security/IoMethods -- Style/ArgumentsForwarding -- Style/ArrayIntersect -- Style/CollectionCompact -- Style/ComparableClamp -- Style/ConcatArrayLiterals -- Style/DataInheritance -- Style/DirEmpty -- Style/DocumentDynamicEvalDefinition -- Style/EmptyHeredoc -- Style/EndlessMethod -- Style/EnvHome -- Style/FetchEnvVar -- Style/FileEmpty -- Style/FileRead -- Style/FileWrite -- Style/HashConversion -- Style/HashExcept -- Style/IfWithBooleanLiteralBranches -- Style/InPatternThen -- Style/MagicCommentFormat -- Style/MapCompactWithConditionalBlock -- Style/MapToHash -- Style/MapToSet -- Style/MinMaxComparison -- Style/MultilineInPatternThen -- Style/NegatedIfElseCondition -- Style/NestedFileDirname -- Style/NilLambda -- Style/NumberedParameters -- Style/NumberedParametersLimit -- Style/ObjectThen -- Style/OpenStructUse -- Style/OperatorMethodCall -- Style/QuotedSymbols -- Style/RedundantArgument -- Style/RedundantConstantBase -- Style/RedundantDoubleSplatHashBraces -- Style/RedundantEach -- Style/RedundantHeredocDelimiterQuotes -- Style/RedundantInitialize -- Style/RedundantLineContinuation -- Style/RedundantSelfAssignmentBranch -- Style/RedundantStringEscape -- Style/SelectByRegexp -- Style/StringChars -- Style/SwapValues diff --git a/rubocop/profile_builder.rb b/rubocop/profile_builder.rb deleted file mode 100755 index 10543732..00000000 --- a/rubocop/profile_builder.rb +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -this_dir = __dir__ -raise "This script must be run from the #{this_dir} directory" if this_dir != Dir.pwd - -require 'fileutils' -require 'yaml' -require 'rubocop/version' - -def report_cops(cops, msg) - warn "Found these cops in #{msg}:" - total = 0 - cops.each do |enabled, c| - warn "#{enabled.inspect}: #{c.length}" - total += c.length - end - warn "total: #{total}" -end - -def load_config - YAML.safe_load( - `rubocop --show-cops --require rubocop-rspec --require rubocop-performance`, - permitted_classes: [Regexp, Symbol] - ) -end - -File.delete('.rubocop.yml') if File.exist?('.rubocop.yml') - -default_configs = load_config -all_cops = default_configs.keys - ['AllCops', 'require', 'Lint/Syntax'] - -default_cops = all_cops.group_by { |c| default_configs[c]['Enabled'] } -report_cops(default_cops, 'the rubocop config') - -File.open("defaults-#{RuboCop::Version.version}.yml", 'wb') do |f| - f.puts YAML.dump( - default_enabled_cops: default_cops[true].sort, - default_pending_cops: default_cops['pending'].sort - ) -end - -# # fetch config from current PDK. Assume it's in the same directory as this repo. -# FileUtils.cp(File.join('..', '..', 'pdk', '.rubocop.yml'), '.') -# # stub out the included config to avoid rubocop complaints -# File.open('.rubocop_todo.yml', 'w') do |f| -# # nothing -# end -# # config = YAML.load(File.read('.rubocop.yml')) - -# all_cops_configured = load_config - -# configured_cops = all_cops.group_by { |c| all_cops_configured[c]['Enabled'] } -# report_cops(configured_cops, "the pdk config") - -# # The cleanups_only profile only has the uncontroversial cops enabled, and configured, everything else is disabled - -# configured_cleanup_cops = YAML.load(File.read('cleanup_cops.yml')) - -# cleanup_cops = { -# true: all_cops - configured_cops[false] - configured_cops['pending'], -# false: all_cops - configured_cops[true], -# } - -# report_cops(cleanup_cops, "the cleanup section") - -# # force_disabled_cops = config_disabled_cops - default_disabled_cops - -# # puts YAML.dump(config_enabled_cops - cleanup_enabled_cops)