diff --git a/.rubocop.yml b/.rubocop.yml index 82770e34..65de9ee5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,7 +6,7 @@ require: - rubocop-rspec - rubocop-performance AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.7 NewCops: enable Style/TrailingCommaInHashLiteral: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b4f27f6a..0bc713da 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,25 +1,65 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-02-17 10:57:31 UTC using RuboCop version 1.12.1. +# on 2023-02-18 18:00:43 UTC using RuboCop version 1.45.1. # 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: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + +# Offense count: 3 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'json-schema.gemspec' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequireMFA: + Exclude: + - 'json-schema.gemspec' + # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineMethodCallBraceLayout: Exclude: - 'test/common_test_suite_test.rb' +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: space + # Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: Exclude: - 'lib/json-schema/errors/validation_error.rb' +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'lib/json-schema/util/uuid.rb' + # Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Exclude: @@ -45,27 +85,27 @@ Lint/MissingSuper: - 'lib/json-schema/attributes/formats/custom.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/NonDeterministicRequireOrder: Exclude: - 'lib/json-schema.rb' - 'test/support/test_helper.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Lint/RedundantRequireStatement: Exclude: - 'lib/json-schema/validator.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Lint/RedundantStringCoercion: Exclude: - 'lib/json-schema/attributes/extends.rb' - 'lib/json-schema/attributes/ref.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Lint/ScriptPermission: Exclude: - 'lib/json-schema/util/uuid.rb' @@ -78,7 +118,7 @@ Lint/SuppressedException: - 'lib/json-schema/validator.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Lint/TripleQuotes: Exclude: - 'test/all_of_ref_schema_test.rb' @@ -86,7 +126,7 @@ Lint/TripleQuotes: - 'test/one_of_test.rb' # Offense count: 10 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: @@ -98,19 +138,19 @@ Lint/UnusedBlockArgument: - 'lib/json-schema/validator.rb' # Offense count: 24 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Enabled: false # Offense count: 52 -# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 60 # Offense count: 2 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# AllowedMethods: refine Metrics/BlockLength: Max: 37 @@ -122,15 +162,15 @@ Metrics/BlockNesting: # Offense count: 9 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 561 + Max: 560 # Offense count: 17 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 21 # Offense count: 145 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 73 @@ -140,7 +180,7 @@ Metrics/ParameterLists: Max: 8 # Offense count: 15 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 20 @@ -157,7 +197,8 @@ Naming/ClassAndModuleCamelCase: - 'test/support/enum_validation.rb' # Offense count: 6 -# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# CheckDefinitionPathHierarchyRoots: lib, spec, test, src # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: @@ -170,7 +211,7 @@ Naming/FileName: # Offense count: 18 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: Exclude: - 'lib/json-schema/attributes/extends.rb' @@ -179,7 +220,7 @@ Naming/MethodParameterName: - 'lib/json-schema/validator.rb' # Offense count: 18 -# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 Naming/VariableNumber: @@ -190,26 +231,26 @@ Naming/VariableNumber: - 'test/one_of_test.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SafeMultiline. Performance/DeletePrefix: Exclude: - 'lib/json-schema/util/uuid.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Performance/RangeInclude: Exclude: - 'lib/json-schema/util/uuid.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). Performance/StringInclude: Exclude: - 'test/min_items_test.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Performance/UnfreezeString: Exclude: - 'test/type_attribute_test.rb' @@ -227,29 +268,21 @@ Security/Open: - 'lib/json-schema/validator.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Security/YAMLLoad: Exclude: - 'json-schema.gemspec' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: prefer_alias, prefer_alias_method Style/Alias: Exclude: - 'lib/json-schema/util/uuid.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: percent_q, bare_percent -Style/BarePercentLiterals: - Exclude: - - 'test/files_test.rb' - # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CaseLikeIf: Exclude: - 'lib/json-schema/validator.rb' @@ -260,14 +293,14 @@ Style/ClassVars: - 'lib/json-schema/validator.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/ColonMethodCall: Exclude: - 'lib/json-schema.rb' - 'lib/json-schema/validator.rb' # Offense count: 5 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: @@ -283,14 +316,14 @@ Style/ConditionalAssignment: Style/Documentation: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). Style/EmptyLiteral: Exclude: - 'test/type_attribute_test.rb' # Offense count: 5 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/Encoding: Exclude: - 'test/custom_format_test.rb' @@ -300,12 +333,18 @@ Style/Encoding: - 'test/uri_parsing_test.rb' # Offense count: 40 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/ExpandPathArguments: Enabled: false # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +Style/FileRead: + Exclude: + - 'json-schema.gemspec' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: @@ -313,25 +352,27 @@ Style/FormatString: - 'lib/json-schema/util/uuid.rb' # Offense count: 21 -# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: EnforcedStyle: unannotated # Offense count: 118 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false -# Offense count: 26 -# Configuration parameters: MinBodyLength. +# Offense count: 24 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Enabled: false # Offense count: 19 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - 'Rakefile' @@ -343,7 +384,7 @@ Style/IfUnlessModifier: - 'lib/json-schema/validator.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods. # AllowedMethods: nonzero? Style/IfWithBooleanLiteralBranches: @@ -351,7 +392,7 @@ Style/IfWithBooleanLiteralBranches: - 'lib/json-schema/validator.rb' # Offense count: 6 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: line_count_dependent, lambda, literal Style/Lambda: @@ -359,8 +400,14 @@ Style/Lambda: - 'lib/json-schema/validator.rb' - 'test/custom_format_test.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapToHash: + Exclude: + - 'lib/json-schema/schema.rb' + # Offense count: 14 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: @@ -374,19 +421,19 @@ Style/MultilineBlockChain: - 'lib/json-schema/attribute.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/MultilineIfThen: Exclude: - 'lib/json-schema/util/uuid.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/MultilineWhenThen: Exclude: - 'lib/json-schema/schema.rb' # Offense count: 11 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict Style/MutableConstant: @@ -403,7 +450,7 @@ Style/MutableConstant: - 'test/support/type_validation.rb' # Offense count: 11 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: both, prefix, postfix Style/NegatedIf: @@ -420,13 +467,13 @@ Style/NegatedIf: - 'lib/json-schema/validator.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/NegatedIfElseCondition: Exclude: - 'lib/json-schema/validator.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: @@ -435,14 +482,14 @@ Style/Next: - 'lib/json-schema/validator.rb' # Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: Strict. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. Style/NumericLiterals: MinDigits: 23 # Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IgnoredMethods. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: @@ -463,31 +510,22 @@ Style/OptionalBooleanParameter: - 'lib/json-schema/validator.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/ParallelAssignment: Exclude: - 'lib/json-schema/attributes/extends.rb' - 'lib/json-schema/attributes/ref.rb' -# Offense count: 4 -# Cop supports --auto-correct. +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: - 'Rakefile' - 'lib/json-schema/util/uri.rb' - - 'lib/json-schema/util/uuid.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: lower_case_q, upper_case_q -Style/PercentQLiterals: - Exclude: - - 'test/files_test.rb' # Offense count: 10 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: short, verbose Style/PreferredHashMethods: @@ -499,26 +537,32 @@ Style/PreferredHashMethods: - 'lib/json-schema/schema/validator.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: - 'lib/json-schema/attributes/formats/custom.rb' - 'lib/json-schema/validator.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantConditional: Exclude: - 'lib/json-schema/validator.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpEscape: Exclude: - 'lib/json-schema/attributes/formats/date_time.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantSelfAssignmentBranch: + Exclude: + - 'lib/json-schema/validator.rb' + # Offense count: 10 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/SelfAssignment: Exclude: - 'lib/json-schema/attributes/additionalproperties.rb' @@ -529,8 +573,15 @@ Style/SelfAssignment: - 'lib/json-schema/attributes/type.rb' - 'lib/json-schema/util/uuid.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'test/common_test_suite_test.rb' + # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. Style/StringConcatenation: Exclude: - 'lib/json-schema/attributes/ref.rb' @@ -538,17 +589,17 @@ Style/StringConcatenation: - 'test/schema_reader_test.rb' # Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. -# IgnoredMethods: respond_to, define_method +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method Style/SymbolProc: Exclude: - 'lib/json-schema/errors/validation_error.rb' - 'lib/json-schema/validator.rb' -# Offense count: 76 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# Offense count: 71 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: Max: 235 diff --git a/Gemfile b/Gemfile index 52fb68a8..fb45bd5d 100644 --- a/Gemfile +++ b/Gemfile @@ -13,9 +13,8 @@ group :coverage, optional: ENV['COVERAGE'] != 'yes' do end group :tests do - gem 'rubocop', '~> 1.12.0' # newer version require Ruby 2.6 - gem 'rubocop-minitest', '~> 0.19.0' # newer version requires Ruby 2.6 - gem 'rubocop-performance', '~> 1.13.0' # newer version requires Ruby 2.6 - gem 'rubocop-rake', '~> 0.6.0' # latest - gem 'rubocop-rspec', '~> 2.4.0' # newer version require Ruby 2.6 or rubocop 1.19 + gem 'rubocop', '~> 1.45.0' + gem 'rubocop-rspec', '~> 2.18.1' + gem 'rubocop-rake', '~> 0.6.0' + gem 'rubocop-performance', '~> 1.16.0' end