diff --git a/Rakefile b/Rakefile index 82c1eb0..b2681f6 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ task :vendor do require "rubocop" require "yaml" unless defined?(YAML) cfg = RuboCop::Cop::Cop.all.each_with_object({}) { |cop, acc| acc[cop.cop_name] = { "Enabled" => false } unless cop.cop_name.start_with?("Chef") } - File.open(dst.join("disable_all.yml"), "w") { |fh| fh.write cfg.to_yaml } + File.open(dst.join("disable_all.yml"), "w") { |fh| fh.write YAML.dump(cfg) } sh %{git add #{dst}/{upstream,disable_all}.yml} sh %{git commit -m "Vendor rubocop-#{upstream.version} upstream configuration."} @@ -48,8 +48,8 @@ task :validate_config do RuboCop::Cop::Chef.constants.each do |dep| RuboCop::Cop::Chef.const_get(dep).constants.each do |cop| - unless config["#{dep}/#{cop}"] - puts "Error: #{dep}/#{cop} not found in config/chefstyle.yml" + unless config["Chef/#{dep}/#{cop}"] + puts "Error: Chef/#{dep}/#{cop} not found in config/chefstyle.yml" status = 1 end end diff --git a/config/chefstyle.yml b/config/chefstyle.yml index 4320d67..d78c0bc 100644 --- a/config/chefstyle.yml +++ b/config/chefstyle.yml @@ -669,26 +669,26 @@ Style/ExpandPathArguments: Lint/RedundantSafeNavigation: Enabled: true -ChefRuby/Ruby27KeywordArgumentWarnings: +Chef/Ruby/Ruby27KeywordArgumentWarnings: Description: Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings. Enabled: true VersionAdded: '1.3.0' -ChefRuby/UnlessDefinedRequire: +Chef/Ruby/UnlessDefinedRequire: Description: Workaround RubyGems' slow requires by only running require if the constant isn't already defined Enabled: true VersionAdded: '1.3.0' Include: - 'lib/**/*' -ChefRuby/GemspecRequireRubygems: +Chef/Ruby/GemspecRequireRubygems: Description: Rubygems does not need to be required in a Gemspec Enabled: true VersionAdded: '1.3.0' Include: - '**/*.gemspec' -ChefRuby/RequireNetHttps: +Chef/Ruby/RequireNetHttps: Description: net/https is deprecated and just includes net/http and openssl. We should include those directly instead Enabled: true VersionAdded: '1.3.0' \ No newline at end of file diff --git a/config/disable_all.yml b/config/disable_all.yml index 5bd861a..dd4e59f 100644 --- a/config/disable_all.yml +++ b/config/disable_all.yml @@ -237,6 +237,8 @@ Lint/DuplicateHashKey: Enabled: false Lint/DuplicateMethods: Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false Lint/DuplicateRequire: Enabled: false Lint/DuplicateRescueException: @@ -245,6 +247,8 @@ Lint/EachWithObjectArgument: Enabled: false Lint/ElseLayout: Enabled: false +Lint/EmptyBlock: + Enabled: false Lint/EmptyConditionalBody: Enabled: false Lint/EmptyEnsure: @@ -303,6 +307,8 @@ Lint/NestedPercentLiteral: Enabled: false Lint/NextWithoutAccumulator: Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false Lint/NonDeterministicRequireOrder: Enabled: false Lint/NonLocalExitFromIterator: @@ -373,6 +379,8 @@ Lint/SuppressedException: Enabled: false Lint/Syntax: Enabled: false +Lint/ToEnumArguments: + Enabled: false Lint/ToJSON: Enabled: false Lint/TopLevelReturnWithArgument: @@ -383,6 +391,8 @@ Lint/UnderscorePrefixedVariableName: Enabled: false Lint/UnifiedInteger: Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false Lint/UnreachableCode: Enabled: false Lint/UnreachableLoop: @@ -467,6 +477,8 @@ Style/Alias: Enabled: false Style/AndOr: Enabled: false +Style/ArgumentsForwarding: + Enabled: false Style/ArrayCoercion: Enabled: false Style/ArrayJoin: @@ -505,6 +517,8 @@ Style/ClassMethodsDefinitions: Enabled: false Style/ClassVars: Enabled: false +Style/CollectionCompact: + Enabled: false Style/CollectionMethods: Enabled: false Style/ColonMethodCall: @@ -537,6 +551,8 @@ Style/DocumentationMethod: Enabled: false Style/Documentation: Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false Style/DoubleCopDisableDirective: Enabled: false Style/DoubleNegation: @@ -677,6 +693,8 @@ Style/MutableConstant: Enabled: false Style/NegatedIf: Enabled: false +Style/NegatedIfElseCondition: + Enabled: false Style/NegatedUnless: Enabled: false Style/NegatedWhile: @@ -807,6 +825,8 @@ Style/Strip: Enabled: false Style/StructInheritance: Enabled: false +Style/SwapValues: + Enabled: false Style/SymbolArray: Enabled: false Style/SymbolLiteral: diff --git a/config/upstream.yml b/config/upstream.yml index f57334f..c539d31 100644 --- a/config/upstream.yml +++ b/config/upstream.yml @@ -313,7 +313,7 @@ Layout/AssignmentIndentation: Layout/BeginEndAlignment: Description: 'Align ends corresponding to begins correctly.' - Enabled: pending + Enabled: true VersionAdded: '0.91' # The value `start_of_line` means that `end` should be aligned the start of the line # where the `begin` keyword is. @@ -496,7 +496,7 @@ Layout/EmptyLinesAroundArguments: Layout/EmptyLinesAroundAttributeAccessor: Description: "Keep blank lines around attribute accessors." StyleGuide: '#empty-lines-around-attribute-accessor' - Enabled: pending + Enabled: true VersionAdded: '0.83' VersionChanged: '0.84' AllowAliasSyntax: true @@ -1145,7 +1145,7 @@ Layout/SpaceAroundKeyword: Layout/SpaceAroundMethodCallOperator: Description: 'Checks method call operators to not have spaces around them.' - Enabled: pending + Enabled: true VersionAdded: '0.82' Layout/SpaceAroundOperators: @@ -1334,8 +1334,8 @@ Layout/TrailingWhitespace: StyleGuide: '#no-trailing-whitespace' Enabled: true VersionAdded: '0.49' - VersionChanged: '0.83' - AllowInHeredoc: true + VersionChanged: '1.0' + AllowInHeredoc: false #################### Lint ################################## ### Warnings @@ -1379,7 +1379,7 @@ Lint/BigDecimalNew: Lint/BinaryOperatorWithIdenticalOperands: Description: 'This cop checks for places where binary operator has identical operands.' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.89' @@ -1398,7 +1398,7 @@ Lint/CircularArgumentReference: Lint/ConstantDefinitionInBlock: Description: 'Do not define constants within a block.' StyleGuide: '#no-constant-definition-in-block' - Enabled: pending + Enabled: true VersionAdded: '0.91' Lint/ConstantResolution: @@ -1423,7 +1423,7 @@ Lint/DeprecatedClassMethods: Lint/DeprecatedOpenSSLConstant: Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`." - Enabled: pending + Enabled: true VersionAdded: '0.84' Lint/DisjunctiveAssignmentInConstructor: @@ -1440,7 +1440,7 @@ Lint/DuplicateCaseCondition: Lint/DuplicateElsifCondition: Description: 'Do not repeat conditions used in if `elsif`.' - Enabled: 'pending' + Enabled: true VersionAdded: '0.88' Lint/DuplicateHashKey: @@ -1454,14 +1454,19 @@ Lint/DuplicateMethods: Enabled: true VersionAdded: '0.29' +Lint/DuplicateRegexpCharacterClassElement: + Description: 'Checks for duplicate elements in Regexp character classes.' + Enabled: pending + VersionAdded: '1.1' + Lint/DuplicateRequire: Description: 'Check for duplicate `require`s and `require_relative`s.' - Enabled: pending + Enabled: true VersionAdded: '0.90' Lint/DuplicateRescueException: Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.' - Enabled: pending + Enabled: true VersionAdded: '0.89' Lint/EachWithObjectArgument: @@ -1473,10 +1478,17 @@ Lint/ElseLayout: Description: 'Check for odd code arrangement in an else block.' Enabled: true VersionAdded: '0.17' + VersionChanged: '1.2' + +Lint/EmptyBlock: + Description: 'This cop checks for blocks without a body.' + Enabled: pending + VersionAdded: '1.1' + AllowComments: true Lint/EmptyConditionalBody: Description: 'This cop checks for the presence of `if`, `elsif` and `unless` branches without a body.' - Enabled: 'pending' + Enabled: true AllowComments: true VersionAdded: '0.89' @@ -1493,7 +1505,7 @@ Lint/EmptyExpression: Lint/EmptyFile: Description: 'Enforces that Ruby source files are not empty.' - Enabled: pending + Enabled: true AllowComments: true VersionAdded: '0.90' @@ -1531,7 +1543,7 @@ Lint/FlipFlop: Lint/FloatComparison: Description: 'Checks for the presence of precise comparison of floating point numbers.' StyleGuide: '#float-comparison' - Enabled: pending + Enabled: true VersionAdded: '0.89' Lint/FloatOutOfRange: @@ -1549,7 +1561,7 @@ Lint/FormatParameterMismatch: Lint/HashCompareByIdentity: Description: 'Prefer using `Hash#compare_by_identity` than using `object_id` for keys.' StyleGuide: '#identity-comparison' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.93' @@ -1563,7 +1575,7 @@ Lint/HeredocMethodCallPosition: Lint/IdentityComparison: Description: 'Prefer `equal?` over `==` when comparing `object_id`.' - Enabled: pending + Enabled: true StyleGuide: '#identity-comparison' VersionAdded: '0.91' @@ -1635,19 +1647,20 @@ Lint/MissingSuper: Description: >- This cop checks for the presence of constructors and lifecycle callbacks without calls to `super`'. - Enabled: pending + Enabled: true VersionAdded: '0.89' Lint/MixedRegexpCaptureTypes: Description: 'Do not mix named captures and numbered captures in a Regexp literal.' - Enabled: pending + Enabled: true VersionAdded: '0.85' Lint/MultipleComparison: Description: "Use `&&` operator to compare multiple values." Enabled: true VersionAdded: '0.47' - VersionChanged: '0.77' + VersionChanged: '1.1' + AllowMethodComparison: true Lint/NestedMethodDefinition: Description: 'Do not use nested method definitions.' @@ -1667,6 +1680,11 @@ Lint/NextWithoutAccumulator: Enabled: true VersionAdded: '0.36' +Lint/NoReturnInBeginEndBlocks: + Description: 'Do not `return` inside `begin..end` blocks in assignment contexts.' + Enabled: pending + VersionAdded: '1.2' + Lint/NonDeterministicRequireOrder: Description: 'Always sort arrays returned by Dir.glob when requiring files.' Enabled: true @@ -1682,8 +1700,12 @@ Lint/NumberConversion: Description: 'Checks unsafe usage of number conversion methods.' Enabled: false VersionAdded: '0.53' - VersionChanged: '0.70' + VersionChanged: '1.1' SafeAutoCorrect: false + IgnoredMethods: [] + IgnoredClasses: + - Time + - DateTime Lint/OrderedMagicComments: Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.' @@ -1692,7 +1714,7 @@ Lint/OrderedMagicComments: Lint/OutOfRangeRegexpRef: Description: 'Checks for out of range reference for Regexp because it always returns nil.' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.89' @@ -1721,7 +1743,7 @@ Lint/PercentSymbolArray: Lint/RaiseException: Description: Checks for `raise` or `fail` statements which are raising `Exception` class. StyleGuide: '#raise-exception' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.81' VersionChanged: '0.86' @@ -1755,7 +1777,7 @@ Lint/RedundantRequireStatement: Lint/RedundantSafeNavigation: Description: 'Checks for redundant safe navigation calls.' - Enabled: pending + Enabled: true VersionAdded: '0.93' AllowedMethods: - instance_of? @@ -1862,7 +1884,7 @@ Lint/ScriptPermission: Lint/SelfAssignment: Description: 'Checks for self-assignments.' - Enabled: pending + Enabled: true VersionAdded: '0.89' Lint/SendWithMixinArgument: @@ -1893,7 +1915,7 @@ Lint/ShadowingOuterLocalVariable: Lint/StructNewOverride: Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.' - Enabled: pending + Enabled: true VersionAdded: '0.81' Lint/SuppressedException: @@ -1910,6 +1932,11 @@ Lint/Syntax: VersionAdded: '0.9' +Lint/ToEnumArguments: + Description: 'This cop ensures that `to_enum`/`enum_for`, called for the current method, has correct arguments.' + Enabled: pending + VersionAdded: '1.1' + Lint/ToJSON: Description: 'Ensure #to_json includes an optional argument.' Enabled: true @@ -1917,12 +1944,12 @@ Lint/ToJSON: Lint/TopLevelReturnWithArgument: Description: 'This cop detects top level return statements with argument.' - Enabled: 'pending' + Enabled: true VersionAdded: '0.89' Lint/TrailingCommaInAttributeDeclaration: Description: 'This cop checks for trailing commas in attribute declarations.' - Enabled: pending + Enabled: true VersionAdded: '0.90' Lint/UnderscorePrefixedVariableName: @@ -1936,6 +1963,11 @@ Lint/UnifiedInteger: Enabled: true VersionAdded: '0.43' +Lint/UnmodifiedReduceAccumulator: + Description: Checks for `reduce` or `inject` blocks that do not update the accumulator each iteration. + Enabled: pending + VersionAdded: '1.1' + Lint/UnreachableCode: Description: 'Unreachable code.' Enabled: true @@ -1943,7 +1975,7 @@ Lint/UnreachableCode: Lint/UnreachableLoop: Description: 'This cop checks for loops that will have at most one iteration.' - Enabled: pending + Enabled: true VersionAdded: '0.89' Lint/UnusedBlockArgument: @@ -2002,7 +2034,7 @@ Lint/UselessElseWithoutRescue: Lint/UselessMethodDefinition: Description: 'Checks for useless method definitions.' - Enabled: pending + Enabled: true VersionAdded: '0.90' Safe: false AllowComments: true @@ -2010,13 +2042,14 @@ Lint/UselessMethodDefinition: Lint/UselessSetterCall: Description: 'Checks for useless setter call to a local variable.' Enabled: true + SafeAutoCorrect: false VersionAdded: '0.13' - VersionChanged: '0.80' + VersionChanged: '1.2' Safe: false Lint/UselessTimes: Description: 'Checks for useless `Integer#times` calls.' - Enabled: pending + Enabled: true VersionAdded: '0.91' Safe: false @@ -2155,6 +2188,7 @@ Naming/BinaryOperatorParameterName: StyleGuide: '#other-arg' Enabled: true VersionAdded: '0.50' + VersionChanged: '1.2' Naming/BlockParameterName: Description: >- @@ -2261,6 +2295,7 @@ Naming/HeredocDelimiterCase: StyleGuide: '#heredoc-delimiters' Enabled: true VersionAdded: '0.50' + VersionChanged: '1.2' EnforcedStyle: uppercase SupportedStyles: - lowercase @@ -2279,7 +2314,7 @@ Naming/MemoizedInstanceVariableName: Memoized method name should match memo instance variable name. Enabled: true VersionAdded: '0.53' - VersionChanged: '0.58' + VersionChanged: '1.2' EnforcedStyleForLeadingUnderscores: disallowed SupportedStylesForLeadingUnderscores: - disallowed @@ -2377,14 +2412,18 @@ Naming/VariableName: - camelCase Naming/VariableNumber: - Description: 'Use the configured style when numbering variables.' + Description: 'Use the configured style when numbering symbols, methods and variables.' + StyleGuide: '#snake-case-symbols-methods-vars-with-numbers' Enabled: true VersionAdded: '0.50' + VersionChanged: '1.2' EnforcedStyle: normalcase SupportedStyles: - snake_case - normalcase - non_integer + CheckMethodNames: true + CheckSymbols: true #################### Security ############################## @@ -2415,9 +2454,10 @@ Security/MarshalLoad: VersionAdded: '0.47' Security/Open: - Description: 'The use of Kernel#open represents a serious security risk.' + Description: 'The use of `Kernel#open` and `URI.open` represent a serious security risk.' Enabled: true VersionAdded: '0.53' + VersionChanged: '1.0' Safe: false Security/YAMLLoad: @@ -2444,7 +2484,7 @@ Style/AccessModifierDeclarations: Style/AccessorGrouping: Description: 'Checks for grouping of accessors in `class` and `module` bodies.' - Enabled: 'pending' + Enabled: true VersionAdded: '0.87' EnforcedStyle: grouped SupportedStyles: @@ -2477,6 +2517,13 @@ Style/AndOr: - always - conditionals +Style/ArgumentsForwarding: + Description: 'Use arguments forwarding.' + StyleGuide: '#arguments-forwarding' + Enabled: pending + AllowOnlyRestArgument: true + VersionAdded: '1.1' + Style/ArrayCoercion: Description: >- Use Array() instead of explicit Array check or [*var], when dealing @@ -2533,7 +2580,7 @@ Style/BisectedAttrAccessor: Description: >- Checks for places where `attr_reader` and `attr_writer` for the same method can be combined into single `attr_accessor`. - Enabled: 'pending' + Enabled: true VersionAdded: '0.87' Style/BlockComments: @@ -2672,7 +2719,7 @@ Style/CaseEquality: Style/CaseLikeIf: Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.' StyleGuide: '#case-vs-if-else' - Enabled: 'pending' + Enabled: true Safe: false VersionAdded: '0.88' @@ -2725,7 +2772,7 @@ Style/ClassCheck: Style/ClassEqualityComparison: Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.' StyleGuide: '#instance-of-vs-class-comparison' - Enabled: pending + Enabled: true VersionAdded: '0.93' IgnoredMethods: - == @@ -2755,6 +2802,11 @@ Style/ClassVars: Enabled: true VersionAdded: '0.13' +Style/CollectionCompact: + Description: 'Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject nils.' + Enabled: pending + VersionAdded: '1.2' + # Align with the style guide. Style/CollectionMethods: Description: 'Preferred collection methods.' @@ -2793,7 +2845,7 @@ Style/CombinableLoops: Description: >- Checks for places where multiple consecutive loops over the same data can be combined into a single loop. - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.90' @@ -2917,6 +2969,14 @@ Style/DisableCopsWithinSourceCodeDirective: Enabled: false VersionAdded: '0.82' +Style/DocumentDynamicEvalDefinition: + Description: >- + When using `class_eval` (or other `eval`) with string interpolation, + add a comment block showing its appearance if interpolated. + StyleGuide: '#eval-comment-docs' + Enabled: pending + VersionAdded: '1.1' + Style/Documentation: Description: 'Document classes and non-namespace modules.' Enabled: true @@ -2944,7 +3004,7 @@ Style/DoubleNegation: StyleGuide: '#no-bang-bang' Enabled: true VersionAdded: '0.19' - VersionChanged: '0.84' + VersionChanged: '1.2' EnforcedStyle: allowed_in_returns SafeAutoCorrect: false SupportedStyles: @@ -3046,7 +3106,7 @@ Style/ExplicitBlockArgument: Consider using explicit block argument to avoid writing block literal that just passes its arguments to another block. StyleGuide: '#block-argument' - Enabled: pending + Enabled: true # May change the yielding arity. Safe: false VersionAdded: '0.89' @@ -3054,7 +3114,7 @@ Style/ExplicitBlockArgument: Style/ExponentialNotation: Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).' StyleGuide: '#exponential-notation' - Enabled: pending + Enabled: true VersionAdded: '0.82' EnforcedStyle: scientific SupportedStyles: @@ -3109,8 +3169,12 @@ Style/FormatStringToken: # Prefer simple looking "template" style tokens like `%{name}`, `%{age}` - template - unannotated + # `MaxUnannotatedPlaceholdersAllowed` defines the number of `unannotated` + # style token in a format string to be allowed when enforced style is not + # `unannotated`. + MaxUnannotatedPlaceholdersAllowed: 1 VersionAdded: '0.49' - VersionChanged: '0.75' + VersionChanged: '1.0' Style/FrozenStringLiteralComment: Description: >- @@ -3137,7 +3201,7 @@ Style/FrozenStringLiteralComment: Style/GlobalStdStream: Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.' StyleGuide: '#global-stdout' - Enabled: pending + Enabled: true VersionAdded: '0.89' SafeAutoCorrect: false @@ -3165,7 +3229,7 @@ Style/HashAsLastArrayItem: Checks for presence or absence of braces around hash literal as a last array item depending on configuration. StyleGuide: '#hash-literal-as-last-array-item' - Enabled: 'pending' + Enabled: true VersionAdded: '0.88' EnforcedStyle: braces SupportedStyles: @@ -3175,7 +3239,7 @@ Style/HashAsLastArrayItem: Style/HashEachMethods: Description: 'Use Hash#each_key and Hash#each_value.' StyleGuide: '#hash-each' - Enabled: pending + Enabled: true VersionAdded: '0.80' Safe: false @@ -3183,7 +3247,7 @@ Style/HashLikeCase: Description: >- Checks for places where `case-when` represents a simple 1:1 mapping and can be replaced with a hash lookup. - Enabled: 'pending' + Enabled: true VersionAdded: '0.88' # `MinBranchesCount` defines the number of branches `case` needs to have # to trigger this cop @@ -3214,14 +3278,14 @@ Style/HashSyntax: Style/HashTransformKeys: Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.' - Enabled: 'pending' + Enabled: true VersionAdded: '0.80' VersionChanged: '0.90' Safe: false Style/HashTransformValues: Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.' - Enabled: 'pending' + Enabled: true VersionAdded: '0.80' VersionChanged: '0.90' Safe: false @@ -3328,7 +3392,7 @@ Style/IpAddresses: Style/KeywordParametersOrder: Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.' StyleGuide: '#keyword-parameters-order' - Enabled: pending + Enabled: true VersionAdded: '0.90' Style/Lambda: @@ -3530,6 +3594,7 @@ Style/MultipleComparison: use Array#include? instead. Enabled: true VersionAdded: '0.49' + VersionChanged: '1.1' Style/MutableConstant: Description: 'Do not assign mutable objects to constants.' @@ -3564,6 +3629,13 @@ Style/NegatedIf: - prefix - postfix +Style/NegatedIfElseCondition: + Description: >- + This cop checks for uses of `if-else` and ternary operators with a negated condition + which can be simplified by inverting condition and swapping branches. + Enabled: pending + VersionAdded: '1.2' + Style/NegatedUnless: Description: 'Favor if over unless for negative conditions.' StyleGuide: '#if-for-negatives' @@ -3753,7 +3825,7 @@ Style/OptionalArguments: Style/OptionalBooleanParameter: Description: 'Use keyword arguments when defining method with boolean argument.' StyleGuide: '#boolean-keyword-arguments' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.89' AllowedMethods: @@ -3841,11 +3913,12 @@ Style/RaiseArgs: StyleGuide: '#exception-class-messages' Enabled: true VersionAdded: '0.14' - VersionChanged: '0.40' + VersionChanged: '1.2' EnforcedStyle: exploded SupportedStyles: - compact # raise Exception.new(msg) - exploded # raise Exception, msg + AllowedCompactTypes: [] Style/RandomWithOffset: Description: >- @@ -3857,7 +3930,7 @@ Style/RandomWithOffset: Style/RedundantAssignment: Description: 'Checks for redundant assignment before returning.' - Enabled: 'pending' + Enabled: true VersionAdded: '0.87' Style/RedundantBegin: @@ -3894,7 +3967,7 @@ Style/RedundantFetchBlock: Use `fetch(key, value)` instead of `fetch(key) { value }` when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant. Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code' - Enabled: 'pending' + Enabled: true Safe: false # If enabled, this cop will autocorrect usages of # `fetch` being called with block returning a constant. @@ -3907,7 +3980,7 @@ Style/RedundantFileExtensionInRequire: Checks for the presence of superfluous `.rb` extension in the filename provided to `require` and `require_relative`. StyleGuide: '#no-explicit-rb-to-require' - Enabled: 'pending' + Enabled: true VersionAdded: '0.88' Style/RedundantFreeze: @@ -3934,12 +4007,12 @@ Style/RedundantPercentQ: Style/RedundantRegexpCharacterClass: Description: 'Checks for unnecessary single-element Regexp character classes.' - Enabled: pending + Enabled: true VersionAdded: '0.85' Style/RedundantRegexpEscape: Description: 'Checks for redundant escapes in Regexps.' - Enabled: pending + Enabled: true VersionAdded: '0.85' Style/RedundantReturn: @@ -3960,7 +4033,7 @@ Style/RedundantSelf: Style/RedundantSelfAssignment: Description: 'Checks for places where redundant assignments are made for in place modification methods.' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.90' @@ -4088,7 +4161,7 @@ Style/SignalException: Style/SingleArgumentDig: Description: 'Avoid using single argument dig method.' - Enabled: pending + Enabled: true VersionAdded: '0.89' Safe: false @@ -4115,7 +4188,7 @@ Style/SingleLineMethods: Style/SlicingWithRange: Description: 'Checks array slicing is done with endless ranges when suitable.' - Enabled: pending + Enabled: true VersionAdded: '0.83' Safe: false @@ -4123,7 +4196,7 @@ Style/SoleNestedConditional: Description: >- Finds sole nested conditional nodes which can be merged into outer conditional node. - Enabled: pending + Enabled: true VersionAdded: '0.89' AllowModifier: false @@ -4158,7 +4231,7 @@ Style/StderrPuts: Style/StringConcatenation: Description: 'Checks for places where string concatenation can be replaced with string interpolation.' StyleGuide: '#string-interpolation' - Enabled: pending + Enabled: true Safe: false VersionAdded: '0.89' @@ -4221,6 +4294,13 @@ Style/StructInheritance: VersionAdded: '0.29' VersionChanged: '0.86' +Style/SwapValues: + Description: 'This cop enforces the use of shorthand-style swapping of 2 variables.' + StyleGuide: '#values-swapping' + Enabled: pending + VersionAdded: '1.1' + SafeAutoCorrect: false + Style/SymbolArray: Description: 'Use %i or %I for arrays of symbols.' StyleGuide: '#percent-i' diff --git a/lib/chefstyle/version.rb b/lib/chefstyle/version.rb index 6b45846..4db96c9 100644 --- a/lib/chefstyle/version.rb +++ b/lib/chefstyle/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Chefstyle VERSION = "1.4.5" - RUBOCOP_VERSION = "0.93.1" + RUBOCOP_VERSION = "1.2.0" end \ No newline at end of file diff --git a/lib/rubocop/cop/chef/ruby/gemspec_require_rubygems.rb b/lib/rubocop/cop/chef/ruby/gemspec_require_rubygems.rb index 636cec1..6925876 100644 --- a/lib/rubocop/cop/chef/ruby/gemspec_require_rubygems.rb +++ b/lib/rubocop/cop/chef/ruby/gemspec_require_rubygems.rb @@ -19,7 +19,7 @@ module RuboCop module Cop module Chef - module ChefRuby + module Ruby # Rubygems does not need to be required in a Gemspec. It's already loaded out of the box in Ruby now. class GemspecRequireRubygems < Base extend RuboCop::Cop::AutoCorrector diff --git a/lib/rubocop/cop/chef/ruby/require_net_https.rb b/lib/rubocop/cop/chef/ruby/require_net_https.rb index ca5dac8..5327c77 100644 --- a/lib/rubocop/cop/chef/ruby/require_net_https.rb +++ b/lib/rubocop/cop/chef/ruby/require_net_https.rb @@ -19,7 +19,7 @@ module RuboCop module Cop module Chef - module ChefRuby + module Ruby # net/https is deprecated and just includes net/http and openssl. We should include those directly instead. # # @example diff --git a/lib/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings.rb b/lib/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings.rb index 7f958fc..51d1d24 100644 --- a/lib/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings.rb +++ b/lib/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings.rb @@ -19,7 +19,7 @@ module RuboCop module Cop module Chef - module ChefRuby + module Ruby # Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings. # # @example diff --git a/lib/rubocop/cop/chef/ruby/unless_defined_require.rb b/lib/rubocop/cop/chef/ruby/unless_defined_require.rb index eecdafd..abd9bdb 100644 --- a/lib/rubocop/cop/chef/ruby/unless_defined_require.rb +++ b/lib/rubocop/cop/chef/ruby/unless_defined_require.rb @@ -19,7 +19,7 @@ module RuboCop module Cop module Chef - module ChefRuby + module Ruby # Rubygems is VERY slow to require gems even if they've already been loaded. To work around this # wrap your require statement with an `if defined?()` check. # diff --git a/spec/rubocop/cop/chef/ruby/gemspec_require_rubygems_spec.rb b/spec/rubocop/cop/chef/ruby/gemspec_require_rubygems_spec.rb index df0929c..20244ab 100644 --- a/spec/rubocop/cop/chef/ruby/gemspec_require_rubygems_spec.rb +++ b/spec/rubocop/cop/chef/ruby/gemspec_require_rubygems_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe RuboCop::Cop::Chef::ChefRuby::GemspecRequireRubygems, :config do +describe RuboCop::Cop::Chef::Ruby::GemspecRequireRubygems, :config do subject(:cop) { described_class.new(config) } it "registers an offense when requiring rubygems" do diff --git a/spec/rubocop/cop/chef/ruby/require_net_https_spec.rb b/spec/rubocop/cop/chef/ruby/require_net_https_spec.rb index 49257cc..e5af019 100644 --- a/spec/rubocop/cop/chef/ruby/require_net_https_spec.rb +++ b/spec/rubocop/cop/chef/ruby/require_net_https_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe RuboCop::Cop::Chef::ChefRuby::RequireNetHttps, :config do +describe RuboCop::Cop::Chef::Ruby::RequireNetHttps, :config do subject(:cop) { described_class.new(config) } it "registers an offense when when requiring net/https" do diff --git a/spec/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings_spec.rb b/spec/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings_spec.rb index 3403fc0..495c3c9 100644 --- a/spec/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings_spec.rb +++ b/spec/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe RuboCop::Cop::Chef::ChefRuby::Ruby27KeywordArgumentWarnings, :config do +describe RuboCop::Cop::Chef::Ruby::Ruby27KeywordArgumentWarnings, :config do subject(:cop) { described_class.new(config) } it "registers an offense when passing a hash with brackets to shell_out" do diff --git a/spec/rubocop/cop/chef/ruby/unless_defined_require_spec.rb b/spec/rubocop/cop/chef/ruby/unless_defined_require_spec.rb index 607a001..200bf6f 100644 --- a/spec/rubocop/cop/chef/ruby/unless_defined_require_spec.rb +++ b/spec/rubocop/cop/chef/ruby/unless_defined_require_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe RuboCop::Cop::Chef::ChefRuby::UnlessDefinedRequire, :config do +describe RuboCop::Cop::Chef::Ruby::UnlessDefinedRequire, :config do subject(:cop) { described_class.new(config) } context "with a require known to the cop" do