From c6859569f4136662743b8d64468287ed29c551a3 Mon Sep 17 00:00:00 2001 From: Stefan Vacareanu Date: Mon, 4 Sep 2023 15:06:43 +0300 Subject: [PATCH] Bump the version TS-552 --- .circleci/config.yml | 2 +- Dockerfile | 4 +- Gemfile | 2 +- Gemfile.lock | 32 ++-- docs/description/Bundler_DuplicatedGroup.md | 57 +++++++ docs/description/Bundler_OrderedGems.md | 8 +- .../Gemspec_OrderedDependencies.md | 8 +- .../GraphQL_NotAuthorizedNodeType.md | 23 +++ .../Layout_SpaceAroundMethodCallOperator.md | 4 +- docs/description/Lint_DuplicateHashKey.md | 1 + docs/description/Lint_MissingSuper.md | 19 +++ docs/description/Lint_MixedCaseRange.md | 20 +++ .../Lint_RedundantRegexpQuantifiers.md | 34 ++++ .../description/Performance_MapMethodChain.md | 38 +++++ .../Sorbet_AllowIncompatibleOverride.md | 4 +- .../Sorbet_BindingConstantWithoutTypeAlias.md | 2 +- .../Sorbet_CallbackConditionalsBinding.md | 2 +- .../Sorbet_CheckedTrueInSignature.md | 2 +- .../Sorbet_ConstantsFromStrings.md | 2 +- docs/description/Sorbet_EmptyLineAfterSig.md | 2 +- docs/description/Sorbet_EnforceSigilOrder.md | 2 +- docs/description/Sorbet_EnforceSignatures.md | 2 +- docs/description/Sorbet_EnforceSingleSigil.md | 2 +- docs/description/Sorbet_FalseSigil.md | 2 +- .../Sorbet_ForbidExtendTSigHelpersInShims.md | 2 +- .../Sorbet_ForbidIncludeConstLiteral.md | 19 +++ .../Sorbet_ForbidRBIOutsideOfAllowedPaths.md | 2 +- .../Sorbet_ForbidSuperclassConstLiteral.md | 17 ++ docs/description/Sorbet_ForbidTUnsafe.md | 2 +- docs/description/Sorbet_ForbidTUntyped.md | 2 +- .../Sorbet_ForbidUntypedStructProps.md | 2 +- docs/description/Sorbet_HasSigil.md | 2 +- docs/description/Sorbet_IgnoreSigil.md | 2 +- .../Sorbet_ImplicitConversionMethod.md | 26 +++ .../Sorbet_KeywordArgumentOrdering.md | 2 +- .../Sorbet_ObsoleteStrictMemoization.md | 34 ++++ docs/description/Sorbet_OneAncestorPerLine.md | 2 +- ...bet_SingleLineRbiClassModuleDefinitions.md | 2 +- docs/description/Sorbet_StrictSigil.md | 2 +- docs/description/Sorbet_StrongSigil.md | 2 +- docs/description/Sorbet_TrueSigil.md | 2 +- docs/description/Sorbet_TypeAliasName.md | 2 +- docs/description/Sorbet_ValidSigil.md | 6 +- docs/description/Style_ArgumentsForwarding.md | 20 +++ docs/description/Style_RedundantArgument.md | 4 + .../Style_RedundantCurrentDirectoryInPath.md | 15 ++ .../Style_RedundantRegexpArgument.md | 35 ++++ docs/description/Style_RedundantReturn.md | 7 +- ...le_ReturnNilInPredicateMethodDefinition.md | 39 +++++ .../Style_StringLiteralsInInterpolation.md | 30 +++- docs/description/Style_SymbolArray.md | 11 +- docs/description/Style_YAMLFileRead.md | 26 +++ docs/description/description.json | 138 +++++++++++++++- docs/patterns.json | 156 +++++++++++++++++- 54 files changed, 820 insertions(+), 65 deletions(-) create mode 100644 docs/description/Bundler_DuplicatedGroup.md create mode 100644 docs/description/Lint_MixedCaseRange.md create mode 100644 docs/description/Lint_RedundantRegexpQuantifiers.md create mode 100644 docs/description/Performance_MapMethodChain.md create mode 100644 docs/description/Sorbet_ImplicitConversionMethod.md create mode 100644 docs/description/Sorbet_ObsoleteStrictMemoization.md create mode 100644 docs/description/Style_RedundantCurrentDirectoryInPath.md create mode 100644 docs/description/Style_RedundantRegexpArgument.md create mode 100644 docs/description/Style_ReturnNilInPredicateMethodDefinition.md create mode 100644 docs/description/Style_YAMLFileRead.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 64656866..9f275878 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@10.7.0 + codacy: codacy/base@10.8.0 codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: diff --git a/Dockerfile b/Dockerfile index 66b2a643..30e45fa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG GEM_FOLDER="/usr/local/bundle" -ARG BASE_IMAGE=alpine:3.17 +ARG BASE_IMAGE=alpine:3.18 FROM $BASE_IMAGE as doc-generator @@ -17,7 +17,7 @@ COPY Gemfile . COPY Gemfile.lock . RUN echo 'gem: --no-document' > /etc/gemrc \ - && gem install bundler -v 2.4.14 \ + && gem install bundler -v 2.4.19 \ && bundle install \ && gem cleanup \ && rm -rf /tmp/* /var/cache/apk/* diff --git a/Gemfile b/Gemfile index aa4e94a1..498b302b 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem "pry" gem "safe_yaml" gem "dark_finger" gem "rubocop-migrations" -gem "rubocop", "1.52.1" +gem "rubocop", "1.56.1" #Needed to be referenced on some user configs gem "graphql" #Rubocop official modules diff --git a/Gemfile.lock b/Gemfile.lock index 5201125b..934731c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,24 @@ GEM remote: https://rubygems.org/ specs: - activesupport (7.0.5) + activesupport (7.0.7.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) ast (2.4.2) + base64 (0.1.1) coderay (1.1.3) concurrent-ruby (1.2.2) dark_finger (0.6.1) rubocop (>= 0.51.0) - graphql (2.0.23) + graphql (2.1.0) i18n (1.14.1) concurrent-ruby (~> 1.0) json (2.6.3) + language_server-protocol (3.17.0.3) method_source (1.0.0) - minitest (5.18.1) + minitest (5.19.0) parallel (1.23.0) parser (3.2.2.3) ast (~> 2.4.1) @@ -33,15 +35,17 @@ GEM rdoc (6.5.0) psych (>= 4.0.0) regexp_parser (2.8.1) - rexml (3.2.5) - rubocop (1.52.1) + rexml (3.2.6) + rubocop (1.56.1) + base64 (~> 0.1.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) @@ -50,11 +54,11 @@ GEM rubocop (~> 1.41) rubocop-factory_bot (2.23.1) rubocop (~> 1.33) - rubocop-graphql (1.3.0) - rubocop (>= 0.87, < 2) + rubocop-graphql (1.4.0) + rubocop (>= 0.90, < 2) rubocop-migrations (0.1.0) rubocop (>= 0.42.0) - rubocop-performance (1.18.0) + rubocop-performance (1.19.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.20.2) @@ -63,19 +67,19 @@ GEM rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.22.0) + rubocop-rspec (2.23.2) rubocop (~> 1.33) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) rubocop-shopify (2.14.0) rubocop (~> 1.51) - rubocop-sorbet (0.7.0) + rubocop-sorbet (0.7.3) rubocop (>= 0.90.0) rubocop-thread_safety (0.5.1) rubocop (>= 0.90.0) ruby-progressbar (1.13.0) safe_yaml (1.0.5) - stringio (3.0.7) + stringio (3.0.8) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) @@ -92,7 +96,7 @@ DEPENDENCIES pry rake rdoc - rubocop (= 1.52.1) + rubocop (= 1.56.1) rubocop-graphql rubocop-migrations rubocop-performance @@ -106,4 +110,4 @@ DEPENDENCIES yard BUNDLED WITH - 2.4.2 + 2.4.19 diff --git a/docs/description/Bundler_DuplicatedGroup.md b/docs/description/Bundler_DuplicatedGroup.md new file mode 100644 index 00000000..ce14c800 --- /dev/null +++ b/docs/description/Bundler_DuplicatedGroup.md @@ -0,0 +1,57 @@ + +A Gem group, or a set of groups, should be listed only once in a Gemfile. + +For example, if the values of `source`, `git`, `platforms`, or `path` +surrounding `group` are different, no offense will be registered: + +[source,ruby] +----- +platforms :ruby do + group :default do + gem 'openssl' + end +end + +platforms :jruby do + group :default do + gem 'jruby-openssl' + end +end +----- + +# Examples + +```ruby +# bad +group :development do + gem 'rubocop' +end + +group :development do + gem 'rubocop-rails' +end + +# bad (same set of groups declared twice) +group :development, :test do + gem 'rubocop' +end + +group :test, :development do + gem 'rspec' +end + +# good +group :development do + gem 'rubocop' +end + +group :development, :test do + gem 'rspec' +end + +# good +gem 'rubocop', groups: [:development, :test] +gem 'rspec', groups: [:development, :test] +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Bundler/DuplicatedGroup) \ No newline at end of file diff --git a/docs/description/Bundler_OrderedGems.md b/docs/description/Bundler_OrderedGems.md index 59f36ae8..0a50dfdd 100644 --- a/docs/description/Bundler_OrderedGems.md +++ b/docs/description/Bundler_OrderedGems.md @@ -15,9 +15,11 @@ gem 'rubocop' # good gem 'rubocop' -gem 'rspec' - -# good only if TreatCommentsAsGroupSeparators is true +gem 'rspec'# good +# For code quality +gem 'rubocop' +# For tests +gem 'rspec'# bad # For code quality gem 'rubocop' # For tests diff --git a/docs/description/Gemspec_OrderedDependencies.md b/docs/description/Gemspec_OrderedDependencies.md index f84d9395..00083b37 100644 --- a/docs/description/Gemspec_OrderedDependencies.md +++ b/docs/description/Gemspec_OrderedDependencies.md @@ -41,9 +41,11 @@ spec.add_runtime_dependency 'rubocop' # good spec.add_runtime_dependency 'rubocop' -spec.add_runtime_dependency 'rspec' - -# good only if TreatCommentsAsGroupSeparators is true +spec.add_runtime_dependency 'rspec'# good +# For code quality +spec.add_dependency 'rubocop' +# For tests +spec.add_dependency 'rspec'# bad # For code quality spec.add_dependency 'rubocop' # For tests diff --git a/docs/description/GraphQL_NotAuthorizedNodeType.md b/docs/description/GraphQL_NotAuthorizedNodeType.md index 2b363cba..a4e13b51 100644 --- a/docs/description/GraphQL_NotAuthorizedNodeType.md +++ b/docs/description/GraphQL_NotAuthorizedNodeType.md @@ -6,6 +6,9 @@ avoid accidental information exposure. If `.authorized?` is defined in a parent class, you can add parent to the "SafeBaseClasses" to avoid offenses in children. +This cop also checks the `can_can_action` or `pundit_role` methods that +can be used as part of the Ruby GraphQL Pro. + # Examples ```ruby @@ -35,6 +38,26 @@ class UserType < BaseType end end +# good + +class UserType < BaseType + implements GraphQL::Types::Relay::Node + + pundit_role :staff + + field :uuid, ID, null: false +end + +# good + +class UserType < BaseType + implements GraphQL::Types::Relay::Node + + can_can_action :staff + + field :uuid, ID, null: false +end + # bad class UserType < BaseType diff --git a/docs/description/Layout_SpaceAroundMethodCallOperator.md b/docs/description/Layout_SpaceAroundMethodCallOperator.md index 8914e126..604e2c1d 100644 --- a/docs/description/Layout_SpaceAroundMethodCallOperator.md +++ b/docs/description/Layout_SpaceAroundMethodCallOperator.md @@ -17,7 +17,7 @@ foo &.bar foo &. bar foo &. bar&. buzz RuboCop:: Cop -RuboCop:: Cop:: Cop +RuboCop:: Cop:: Base :: RuboCop::Cop # good @@ -29,7 +29,7 @@ foo foo&.bar foo&.bar&.buzz RuboCop::Cop -RuboCop::Cop::Cop +RuboCop::Cop::Base ::RuboCop::Cop ``` diff --git a/docs/description/Lint_DuplicateHashKey.md b/docs/description/Lint_DuplicateHashKey.md index a778ea76..c2afb2be 100644 --- a/docs/description/Lint_DuplicateHashKey.md +++ b/docs/description/Lint_DuplicateHashKey.md @@ -1,5 +1,6 @@ Checks for duplicated keys in hash literals. +This cop considers both primitive types and constants for the hash keys. This cop mirrors a warning in Ruby 2.2. diff --git a/docs/description/Lint_MissingSuper.md b/docs/description/Lint_MissingSuper.md index e556f399..c4db9a94 100644 --- a/docs/description/Lint_MissingSuper.md +++ b/docs/description/Lint_MissingSuper.md @@ -10,6 +10,13 @@ challenging or verbose for no actual gain. Autocorrection is not supported because the position of `super` cannot be determined automatically. +`Object` and `BasicObject` are allowed by this cop because of their +stateless nature. However, sometimes you might want to allow other parent +classes from this cop, for example in the case of an abstract class that is +not meant to be called with `super`. In those cases, you can use the +`AllowedParentClasses` option to specify which classes should be allowed +*in addition to* `Object` and `BasicObject`. + # Examples ```ruby @@ -57,6 +64,18 @@ class Parent do_something end end + +# good +class ClassWithNoParent + def initialize + do_something + end +end# good +class MyConcreteClass < MyAbstractClass + def initialize + do_something + end +end ``` [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint/MissingSuper) \ No newline at end of file diff --git a/docs/description/Lint_MixedCaseRange.md b/docs/description/Lint_MixedCaseRange.md new file mode 100644 index 00000000..d85b3ab9 --- /dev/null +++ b/docs/description/Lint_MixedCaseRange.md @@ -0,0 +1,20 @@ + +Checks for mixed-case character ranges since they include likely unintended characters. + +Offenses are registered for regexp character classes like `/[A-z]/` +as well as range objects like `('A'..'z')`. + +NOTE: Range objects cannot be autocorrected. + +# Examples + +```ruby + +# bad +r = /[A-z]/ + +# good +r = /[A-Za-z]/ +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint/MixedCaseRange) \ No newline at end of file diff --git a/docs/description/Lint_RedundantRegexpQuantifiers.md b/docs/description/Lint_RedundantRegexpQuantifiers.md new file mode 100644 index 00000000..f6c6d9b9 --- /dev/null +++ b/docs/description/Lint_RedundantRegexpQuantifiers.md @@ -0,0 +1,34 @@ + +Checks for redundant quantifiers inside Regexp literals. + +It is always allowed when interpolation is used in a regexp literal, +because it's unknown what kind of string will be expanded as a result: + +[source,ruby] +---- +/(?:a*#{interpolation})?/x +---- + +# Examples + +```ruby +# bad +/(?:x+)+/ + +# good +/(?:x)+/ + +# good +/(?:x+)/ + +# bad +/(?:x+)?/ + +# good +/(?:x)*/ + +# good +/(?:x*)/ +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint/RedundantRegexpQuantifiers) \ No newline at end of file diff --git a/docs/description/Performance_MapMethodChain.md b/docs/description/Performance_MapMethodChain.md new file mode 100644 index 00000000..59315f61 --- /dev/null +++ b/docs/description/Performance_MapMethodChain.md @@ -0,0 +1,38 @@ + +Checks if the map method is used in a chain. + +Autocorrection is not supported because an appropriate block variable name cannot be determined automatically. + +[source,ruby] +---- +class X + def initialize + @@num = 0 + end + + def foo + @@num += 1 + self + end + + def bar + @@num * 2 + end +end + +[X.new, X.new].map(&:foo).map(&:bar) # => [4, 4] +[X.new, X.new].map { |x| x.foo.bar } # => [2, 4] +---- + +# Examples + +```ruby + +# bad +array.map(&:foo).map(&:bar) + +# good +array.map { |item| item.foo.bar } +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Performance/MapMethodChain) \ No newline at end of file diff --git a/docs/description/Sorbet_AllowIncompatibleOverride.md b/docs/description/Sorbet_AllowIncompatibleOverride.md index d676fed9..1ba929d8 100644 --- a/docs/description/Sorbet_AllowIncompatibleOverride.md +++ b/docs/description/Sorbet_AllowIncompatibleOverride.md @@ -1,8 +1,8 @@ -This cop disallows using `.override(allow_incompatible: true)`. +Disallows using `.override(allow_incompatible: true)`. Using `allow_incompatible` suggests a violation of the Liskov Substitution Principle, meaning that a subclass is not a valid -subtype of it's superclass. This Cop prevents these design smells +subtype of its superclass. This Cop prevents these design smells from occurring. # Examples diff --git a/docs/description/Sorbet_BindingConstantWithoutTypeAlias.md b/docs/description/Sorbet_BindingConstantWithoutTypeAlias.md index 485edda8..4a4cc0e0 100644 --- a/docs/description/Sorbet_BindingConstantWithoutTypeAlias.md +++ b/docs/description/Sorbet_BindingConstantWithoutTypeAlias.md @@ -1,5 +1,5 @@ -This cop disallows binding the return value of `T.any`, `T.all`, `T.enum` +Disallows binding the return value of `T.any`, `T.all`, `T.enum` to a constant directly. To bind the value, one must use `T.type_alias`. # Examples diff --git a/docs/description/Sorbet_CallbackConditionalsBinding.md b/docs/description/Sorbet_CallbackConditionalsBinding.md index ff6f4ca9..df43b69e 100644 --- a/docs/description/Sorbet_CallbackConditionalsBinding.md +++ b/docs/description/Sorbet_CallbackConditionalsBinding.md @@ -1,5 +1,5 @@ -This cop ensures that callback conditionals are bound to the right type +Ensures that callback conditionals are bound to the right type so that they are type checked properly. Auto-correction is unsafe because other libraries define similar style callbacks as Rails, but don't always need diff --git a/docs/description/Sorbet_CheckedTrueInSignature.md b/docs/description/Sorbet_CheckedTrueInSignature.md index af209bd6..adb211ce 100644 --- a/docs/description/Sorbet_CheckedTrueInSignature.md +++ b/docs/description/Sorbet_CheckedTrueInSignature.md @@ -1,5 +1,5 @@ -This cop disallows the usage of `checked(true)`. This usage could cause +Disallows the usage of `checked(true)`. This usage could cause confusion; it could lead some people to believe that a method would be checked even if runtime checks have not been enabled on the class or globally. Additionally, in the event where checks are enabled, `checked(true)` would diff --git a/docs/description/Sorbet_ConstantsFromStrings.md b/docs/description/Sorbet_ConstantsFromStrings.md index a94805c6..1206dee8 100644 --- a/docs/description/Sorbet_ConstantsFromStrings.md +++ b/docs/description/Sorbet_ConstantsFromStrings.md @@ -1,5 +1,5 @@ -This cop disallows the calls that are used to get constants fom Strings +Disallows the calls that are used to get constants fom Strings such as +constantize+, +const_get+, and +constants+. The goal of this cop is to make the code easier to statically analyze, diff --git a/docs/description/Sorbet_EmptyLineAfterSig.md b/docs/description/Sorbet_EmptyLineAfterSig.md index 848278a3..aaae104d 100644 --- a/docs/description/Sorbet_EmptyLineAfterSig.md +++ b/docs/description/Sorbet_EmptyLineAfterSig.md @@ -1,5 +1,5 @@ -This cop checks for blank lines after signatures. +Checks for blank lines after signatures. It also suggests an autocorrect diff --git a/docs/description/Sorbet_EnforceSigilOrder.md b/docs/description/Sorbet_EnforceSigilOrder.md index c2384c38..ee860873 100644 --- a/docs/description/Sorbet_EnforceSigilOrder.md +++ b/docs/description/Sorbet_EnforceSigilOrder.md @@ -1,5 +1,5 @@ -This cop checks that the Sorbet sigil comes as the first magic comment in the file. +Checks that the Sorbet sigil comes as the first magic comment in the file. The expected order for magic comments is: (en)?coding, typed, warn_indent then frozen_string_literal. diff --git a/docs/description/Sorbet_EnforceSignatures.md b/docs/description/Sorbet_EnforceSignatures.md index 3db3ea1e..2104d959 100644 --- a/docs/description/Sorbet_EnforceSignatures.md +++ b/docs/description/Sorbet_EnforceSignatures.md @@ -1,5 +1,5 @@ -This cop checks that every method definition and attribute accessor has a Sorbet signature. +Checks that every method definition and attribute accessor has a Sorbet signature. It also suggest an autocorrect with placeholders so the following code: diff --git a/docs/description/Sorbet_EnforceSingleSigil.md b/docs/description/Sorbet_EnforceSingleSigil.md index ad8c660c..a2f9c4b7 100644 --- a/docs/description/Sorbet_EnforceSingleSigil.md +++ b/docs/description/Sorbet_EnforceSingleSigil.md @@ -1,5 +1,5 @@ -This cop checks that there is only one Sorbet sigil in a given file +Checks that there is only one Sorbet sigil in a given file For example, the following class with two sigils diff --git a/docs/description/Sorbet_FalseSigil.md b/docs/description/Sorbet_FalseSigil.md index 7fc49743..9f993775 100644 --- a/docs/description/Sorbet_FalseSigil.md +++ b/docs/description/Sorbet_FalseSigil.md @@ -1,4 +1,4 @@ -This cop makes the Sorbet `false` sigil mandatory in all files. +Makes the Sorbet `false` sigil mandatory in all files. [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/FalseSigil) \ No newline at end of file diff --git a/docs/description/Sorbet_ForbidExtendTSigHelpersInShims.md b/docs/description/Sorbet_ForbidExtendTSigHelpersInShims.md index 855e22d7..80144289 100644 --- a/docs/description/Sorbet_ForbidExtendTSigHelpersInShims.md +++ b/docs/description/Sorbet_ForbidExtendTSigHelpersInShims.md @@ -1,5 +1,5 @@ -This cop ensures RBI shims do not include a call to extend T::Sig +Ensures RBI shims do not include a call to extend T::Sig or to extend T::Helpers # Examples diff --git a/docs/description/Sorbet_ForbidIncludeConstLiteral.md b/docs/description/Sorbet_ForbidIncludeConstLiteral.md index 3a43dd5d..cdb7d336 100644 --- a/docs/description/Sorbet_ForbidIncludeConstLiteral.md +++ b/docs/description/Sorbet_ForbidIncludeConstLiteral.md @@ -1,4 +1,23 @@ +Correct `send` expressions in include statements by constant literals. +Sorbet, the static checker, is not (yet) able to support constructs on the +following form: + +```ruby +class MyClass + include send_expr +end +``` + +Multiple occurences of this can be found in Shopify's code base like: + +```ruby +include Rails.application.routes.url_helpers +``` +or +```ruby +include Polaris::Engine.helpers +``` [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/ForbidIncludeConstLiteral) \ No newline at end of file diff --git a/docs/description/Sorbet_ForbidRBIOutsideOfAllowedPaths.md b/docs/description/Sorbet_ForbidRBIOutsideOfAllowedPaths.md index 1b931d21..cea1913e 100644 --- a/docs/description/Sorbet_ForbidRBIOutsideOfAllowedPaths.md +++ b/docs/description/Sorbet_ForbidRBIOutsideOfAllowedPaths.md @@ -1,5 +1,5 @@ -This cop makes sure that RBI files are always located under the defined allowed paths. +Makes sure that RBI files are always located under the defined allowed paths. Options: diff --git a/docs/description/Sorbet_ForbidSuperclassConstLiteral.md b/docs/description/Sorbet_ForbidSuperclassConstLiteral.md index e772e8e8..d9daee79 100644 --- a/docs/description/Sorbet_ForbidSuperclassConstLiteral.md +++ b/docs/description/Sorbet_ForbidSuperclassConstLiteral.md @@ -1,4 +1,21 @@ +Correct superclass `send` expressions by constant literals. +Sorbet, the static checker, is not (yet) able to support constructs on the +following form: + +```ruby +class Foo < send_expr; end +``` + +Multiple occurences of this can be found in Shopify's code base like: + +```ruby +class ShopScope < Component::TrustedIdScope[ShopIdentity::ShopId] +``` +or +```ruby +class ApiClientEligibility < Struct.new(:api_client, :match_results, :shop) +``` [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/ForbidSuperclassConstLiteral) \ No newline at end of file diff --git a/docs/description/Sorbet_ForbidTUnsafe.md b/docs/description/Sorbet_ForbidTUnsafe.md index aaa809c3..13537d8b 100644 --- a/docs/description/Sorbet_ForbidTUnsafe.md +++ b/docs/description/Sorbet_ForbidTUnsafe.md @@ -1,5 +1,5 @@ -This cop disallows using `T.unsafe` anywhere. +Disallows using `T.unsafe` anywhere. # Examples diff --git a/docs/description/Sorbet_ForbidTUntyped.md b/docs/description/Sorbet_ForbidTUntyped.md index 5e84daed..40200760 100644 --- a/docs/description/Sorbet_ForbidTUntyped.md +++ b/docs/description/Sorbet_ForbidTUntyped.md @@ -1,5 +1,5 @@ -This cop disallows using `T.untyped` anywhere. +Disallows using `T.untyped` anywhere. # Examples diff --git a/docs/description/Sorbet_ForbidUntypedStructProps.md b/docs/description/Sorbet_ForbidUntypedStructProps.md index f583dad2..1c1b2d74 100644 --- a/docs/description/Sorbet_ForbidUntypedStructProps.md +++ b/docs/description/Sorbet_ForbidUntypedStructProps.md @@ -1,5 +1,5 @@ -This cop disallows use of `T.untyped` or `T.nilable(T.untyped)` +Disallows use of `T.untyped` or `T.nilable(T.untyped)` as a prop type for `T::Struct` or `T::ImmutableStruct`. # Examples diff --git a/docs/description/Sorbet_HasSigil.md b/docs/description/Sorbet_HasSigil.md index 01ff358c..80a33f80 100644 --- a/docs/description/Sorbet_HasSigil.md +++ b/docs/description/Sorbet_HasSigil.md @@ -1,5 +1,5 @@ -This cop makes the Sorbet typed sigil mandatory in all files. +Makes the Sorbet typed sigil mandatory in all files. Options: diff --git a/docs/description/Sorbet_IgnoreSigil.md b/docs/description/Sorbet_IgnoreSigil.md index 1fb2cecd..4e2ac9e5 100644 --- a/docs/description/Sorbet_IgnoreSigil.md +++ b/docs/description/Sorbet_IgnoreSigil.md @@ -1,4 +1,4 @@ -This cop makes the Sorbet `ignore` sigil mandatory in all files. +Makes the Sorbet `ignore` sigil mandatory in all files. [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/IgnoreSigil) \ No newline at end of file diff --git a/docs/description/Sorbet_ImplicitConversionMethod.md b/docs/description/Sorbet_ImplicitConversionMethod.md new file mode 100644 index 00000000..cf672c60 --- /dev/null +++ b/docs/description/Sorbet_ImplicitConversionMethod.md @@ -0,0 +1,26 @@ + +Disallows declaring implicit conversion methods. +Since Sorbet is a nominal (not structural) type system, +implicit conversion is currently unsupported. + +# Examples + +```ruby + +# bad +def to_str; end + +# good +def to_str(x); end + +# bad +def self.to_str; end + +# good +def self.to_str(x); end + +# bad +alias to_str to_s +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/ImplicitConversionMethod) \ No newline at end of file diff --git a/docs/description/Sorbet_KeywordArgumentOrdering.md b/docs/description/Sorbet_KeywordArgumentOrdering.md index 958bc284..7a770d49 100644 --- a/docs/description/Sorbet_KeywordArgumentOrdering.md +++ b/docs/description/Sorbet_KeywordArgumentOrdering.md @@ -1,5 +1,5 @@ -This cop checks for the ordering of keyword arguments required by +Checks for the ordering of keyword arguments required by sorbet-runtime. The ordering requires that all keyword arguments are at the end of the parameters list, and all keyword arguments with a default value must be after those without default values. diff --git a/docs/description/Sorbet_ObsoleteStrictMemoization.md b/docs/description/Sorbet_ObsoleteStrictMemoization.md new file mode 100644 index 00000000..e537ba6a --- /dev/null +++ b/docs/description/Sorbet_ObsoleteStrictMemoization.md @@ -0,0 +1,34 @@ + +Checks for the obsolete pattern for initializing instance variables that was required for older Sorbet +versions in `#typed: strict` files. + +It's no longer required, as of Sorbet 0.5.10210 +See https://sorbet.org/docs/type-assertions#put-type-assertions-behind-memoization + +# Examples + +```ruby + +# bad +sig { returns(Foo) } +def foo + @foo = T.let(@foo, T.nilable(Foo)) + @foo ||= Foo.new +end + +# bad +sig { returns(Foo) } +def foo + # This would have been a mistake, causing the memoized value to be discarded and recomputed on every call. + @foo = T.let(nil, T.nilable(Foo)) + @foo ||= Foo.new +end + +# good +sig { returns(Foo) } +def foo + @foo ||= T.let(Foo.new, T.nilable(Foo)) +end +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/ObsoleteStrictMemoization) \ No newline at end of file diff --git a/docs/description/Sorbet_OneAncestorPerLine.md b/docs/description/Sorbet_OneAncestorPerLine.md index 6cff9035..6050fde2 100644 --- a/docs/description/Sorbet_OneAncestorPerLine.md +++ b/docs/description/Sorbet_OneAncestorPerLine.md @@ -1,5 +1,5 @@ -This cop ensures one ancestor per requires_ancestor line +Ensures one ancestor per requires_ancestor line rather than chaining them as a comma-separated list. # Examples diff --git a/docs/description/Sorbet_SingleLineRbiClassModuleDefinitions.md b/docs/description/Sorbet_SingleLineRbiClassModuleDefinitions.md index 3787af32..c00cfb43 100644 --- a/docs/description/Sorbet_SingleLineRbiClassModuleDefinitions.md +++ b/docs/description/Sorbet_SingleLineRbiClassModuleDefinitions.md @@ -1,5 +1,5 @@ -This cop ensures empty class/module definitions in RBI files are +Ensures empty class/module definitions in RBI files are done on a single line rather than being split across multiple lines. # Examples diff --git a/docs/description/Sorbet_StrictSigil.md b/docs/description/Sorbet_StrictSigil.md index 07628afb..ec752cb3 100644 --- a/docs/description/Sorbet_StrictSigil.md +++ b/docs/description/Sorbet_StrictSigil.md @@ -1,4 +1,4 @@ -This cop makes the Sorbet `strict` sigil mandatory in all files. +Makes the Sorbet `strict` sigil mandatory in all files. [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/StrictSigil) \ No newline at end of file diff --git a/docs/description/Sorbet_StrongSigil.md b/docs/description/Sorbet_StrongSigil.md index 7daa68df..43ce9ecd 100644 --- a/docs/description/Sorbet_StrongSigil.md +++ b/docs/description/Sorbet_StrongSigil.md @@ -1,4 +1,4 @@ -This cop makes the Sorbet `strong` sigil mandatory in all files. +Makes the Sorbet `strong` sigil mandatory in all files. [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/StrongSigil) \ No newline at end of file diff --git a/docs/description/Sorbet_TrueSigil.md b/docs/description/Sorbet_TrueSigil.md index 3f3772bf..39c0d360 100644 --- a/docs/description/Sorbet_TrueSigil.md +++ b/docs/description/Sorbet_TrueSigil.md @@ -1,4 +1,4 @@ -This cop makes the Sorbet `true` sigil mandatory in all files. +Makes the Sorbet `true` sigil mandatory in all files. [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/TrueSigil) \ No newline at end of file diff --git a/docs/description/Sorbet_TypeAliasName.md b/docs/description/Sorbet_TypeAliasName.md index de6b48ad..0f7f1b0c 100644 --- a/docs/description/Sorbet_TypeAliasName.md +++ b/docs/description/Sorbet_TypeAliasName.md @@ -1,5 +1,5 @@ -This cop ensures all constants used as `T.type_alias` are using CamelCase. +Ensures all constants used as `T.type_alias` are using CamelCase. # Examples diff --git a/docs/description/Sorbet_ValidSigil.md b/docs/description/Sorbet_ValidSigil.md index 60c9ea09..715b6395 100644 --- a/docs/description/Sorbet_ValidSigil.md +++ b/docs/description/Sorbet_ValidSigil.md @@ -1,5 +1,5 @@ -This cop checks that every Ruby file contains a valid Sorbet sigil. +Checks that every Ruby file contains a valid Sorbet sigil. Adapted from: https://gist.github.com/clarkdave/85aca4e16f33fd52aceb6a0a29936e52 Options: @@ -7,7 +7,9 @@ Options: * `RequireSigilOnAllFiles`: make offense if the Sorbet typed is not found in the file (default: false) * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false') * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one +* `ExactStrictness`: If set, make offense if the strictness level in the file is different than this one -If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect. +If an `ExactStrictness` level is specified, it will be used in offense messages and autocorrect. +Otherwise, if a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect. [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Sorbet/ValidSigil) \ No newline at end of file diff --git a/docs/description/Style_ArgumentsForwarding.md b/docs/description/Style_ArgumentsForwarding.md index cc8fb853..2e7b1535 100644 --- a/docs/description/Style_ArgumentsForwarding.md +++ b/docs/description/Style_ArgumentsForwarding.md @@ -4,6 +4,12 @@ In Ruby 2.7, arguments forwarding has been added. This cop identifies places where `do_something(*args, &block)` can be replaced by `do_something(...)`. +In Ruby 3.2, anonymous args/kwargs forwarding has been added. + +This cop also identifies places where `use_args(*args)`/`use_kwargs(**kwargs)` can be +replaced by `use_args(*)`/`use_kwargs(**)`; if desired, this functionality can be disabled +by setting UseAnonymousForwarding: false. + # Examples ```ruby @@ -20,6 +26,20 @@ end # good def foo(...) bar(...) +end# bad +def foo(*args, **kwargs) + args_only(*args) + kwargs_only(**kwargs) +end + +# good +def foo(*, **) + args_only(*) + kwargs_only(**) +end# good +def foo(*args, **kwargs) + args_only(*args) + kwargs_only(**kwargs) end# good def foo(*args) bar(*args) diff --git a/docs/description/Style_RedundantArgument.md b/docs/description/Style_RedundantArgument.md index b93382e7..96a69dd1 100644 --- a/docs/description/Style_RedundantArgument.md +++ b/docs/description/Style_RedundantArgument.md @@ -23,6 +23,8 @@ Methods: array.join('') [1, 2, 3].join("") array.sum(0) +exit(true) +exit!(false) string.split(" ") "first\nsecond".split(" ") string.chomp("\n") @@ -33,6 +35,8 @@ A.foo(2) array.join [1, 2, 3].join array.sum +exit +exit! string.split "first second".split string.chomp diff --git a/docs/description/Style_RedundantCurrentDirectoryInPath.md b/docs/description/Style_RedundantCurrentDirectoryInPath.md new file mode 100644 index 00000000..ac74129d --- /dev/null +++ b/docs/description/Style_RedundantCurrentDirectoryInPath.md @@ -0,0 +1,15 @@ + +Checks for uses a redundant current directory in path. + +# Examples + +```ruby + +# bad +require_relative './path/to/feature' + +# good +require_relative 'path/to/feature' +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/RedundantCurrentDirectoryInPath) \ No newline at end of file diff --git a/docs/description/Style_RedundantRegexpArgument.md b/docs/description/Style_RedundantRegexpArgument.md new file mode 100644 index 00000000..0f3cffa0 --- /dev/null +++ b/docs/description/Style_RedundantRegexpArgument.md @@ -0,0 +1,35 @@ + +Identifies places where argument can be replaced from +a deterministic regexp to a string. + +# Examples + +```ruby +# bad +'foo'.byteindex(/f/) +'foo'.byterindex(/f/) +'foo'.gsub(/f/, 'x') +'foo'.gsub!(/f/, 'x') +'foo'.partition(/f/) +'foo'.rpartition(/f/) +'foo'.scan(/f/) +'foo'.split(/f/) +'foo'.start_with?(/f/) +'foo'.sub(/f/, 'x') +'foo'.sub!(/f/, 'x') + +# good +'foo'.byteindex('f') +'foo'.byterindex('f') +'foo'.gsub('f', 'x') +'foo'.gsub!('f', 'x') +'foo'.partition('f') +'foo'.rpartition('f') +'foo'.scan('f') +'foo'.split('f') +'foo'.start_with?('f') +'foo'.sub('f', 'x') +'foo'.sub!('f', 'x') +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/RedundantRegexpArgument) \ No newline at end of file diff --git a/docs/description/Style_RedundantReturn.md b/docs/description/Style_RedundantReturn.md index 97e8374c..a50fe242 100644 --- a/docs/description/Style_RedundantReturn.md +++ b/docs/description/Style_RedundantReturn.md @@ -20,11 +20,16 @@ def test return something end -# good +# bad def test return something if something_else end +# good +def test + something if something_else +end + # good def test if x diff --git a/docs/description/Style_ReturnNilInPredicateMethodDefinition.md b/docs/description/Style_ReturnNilInPredicateMethodDefinition.md new file mode 100644 index 00000000..702ad133 --- /dev/null +++ b/docs/description/Style_ReturnNilInPredicateMethodDefinition.md @@ -0,0 +1,39 @@ + +Checks if `return` or `return nil` is used in predicate method definitions. + +# Examples + +```ruby +# bad +def foo? + return if condition + + do_something? +end + +# bad +def foo? + return nil if condition + + do_something? +end + +# good +def foo? + return false if condition + + do_something? +end# good +def foo? + return if condition + + do_something? +end# good +def foo? + return if condition + + do_something? +end +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/ReturnNilInPredicateMethodDefinition) \ No newline at end of file diff --git a/docs/description/Style_StringLiteralsInInterpolation.md b/docs/description/Style_StringLiteralsInInterpolation.md index 6a1ddd0a..801b4707 100644 --- a/docs/description/Style_StringLiteralsInInterpolation.md +++ b/docs/description/Style_StringLiteralsInInterpolation.md @@ -1,19 +1,39 @@ -Checks that quotes inside the string interpolation +Checks that quotes inside string, symbol, and regexp interpolations match the configured preference. # Examples ```ruby # bad -result = "Tests #{success ? "PASS" : "FAIL"}" +string = "Tests #{success ? "PASS" : "FAIL"}" +symbol = :"Tests #{success ? "PASS" : "FAIL"}" +heredoc = <<~TEXT + Tests #{success ? "PASS" : "FAIL"} +TEXT +regexp = /Tests #{success ? "PASS" : "FAIL"}/ # good -result = "Tests #{success ? 'PASS' : 'FAIL'}"# bad -result = "Tests #{success ? 'PASS' : 'FAIL'}" +string = "Tests #{success ? 'PASS' : 'FAIL'}" +symbol = :"Tests #{success ? 'PASS' : 'FAIL'}" +heredoc = <<~TEXT + Tests #{success ? 'PASS' : 'FAIL'} +TEXT +regexp = /Tests #{success ? 'PASS' : 'FAIL'}/# bad +string = "Tests #{success ? 'PASS' : 'FAIL'}" +symbol = :"Tests #{success ? 'PASS' : 'FAIL'}" +heredoc = <<~TEXT + Tests #{success ? 'PASS' : 'FAIL'} +TEXT +regexp = /Tests #{success ? 'PASS' : 'FAIL'}/ # good -result = "Tests #{success ? "PASS" : "FAIL"}" +string = "Tests #{success ? "PASS" : "FAIL"}" +symbol = :"Tests #{success ? "PASS" : "FAIL"}" +heredoc = <<~TEXT + Tests #{success ? "PASS" : "FAIL"} +TEXT +regexp = /Tests #{success ? "PASS" : "FAIL"}/ ``` [Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/StringLiteralsInInterpolation) \ No newline at end of file diff --git a/docs/description/Style_SymbolArray.md b/docs/description/Style_SymbolArray.md index f027d3f6..f52b45a3 100644 --- a/docs/description/Style_SymbolArray.md +++ b/docs/description/Style_SymbolArray.md @@ -18,7 +18,16 @@ array of 2 or fewer elements. %i[foo bar baz] # bad -[:foo, :bar, :baz]# good +[:foo, :bar, :baz] + +# bad (contains spaces) +%i[foo\ bar baz\ quux] + +# bad (contains [] with spaces) +%i[foo \[ \]] + +# bad (contains () with spaces) +%i(foo \( \))# good [:foo, :bar, :baz] # bad diff --git a/docs/description/Style_YAMLFileRead.md b/docs/description/Style_YAMLFileRead.md new file mode 100644 index 00000000..a512bd6a --- /dev/null +++ b/docs/description/Style_YAMLFileRead.md @@ -0,0 +1,26 @@ + +Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with +`File.read` argument. + +NOTE: `YAML.safe_load_file` was introduced in Ruby 3.0. + +# Examples + +```ruby + +# bad +YAML.load(File.read(path)) +YAML.parse(File.read(path)) + +# good +YAML.load_file(path) +YAML.parse_file(path) + +# bad +YAML.safe_load(File.read(path)) # Ruby 3.0 and newer + +# good +YAML.safe_load_file(path) # Ruby 3.0 and newer +``` + +[Source](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/YAMLFileRead) \ No newline at end of file diff --git a/docs/description/description.json b/docs/description/description.json index b258d3c4..4f2e1413 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -21,6 +21,22 @@ } ] }, + { + "patternId": "Bundler_DuplicatedGroup", + "title": "Checks for duplicate group entries in Gemfile.", + "description": "Checks for duplicate group entries in Gemfile.", + "timeToFix": 5, + "parameters": [ + { + "name": "Severity", + "description": "Severity" + }, + { + "name": "Include", + "description": "Include" + } + ] + }, { "patternId": "Bundler_GemComment", "title": "Add a comment describing each gem.", @@ -417,6 +433,10 @@ "description": "Enforces a configured order of definitions within a class body.", "timeToFix": 5, "parameters": [ + { + "name": "SafeAutoCorrect", + "description": "SafeAutoCorrect" + }, { "name": "Categories", "description": "Categories" @@ -551,6 +571,10 @@ "name": "EmptyLineBetweenModuleDefs", "description": "EmptyLineBetweenModuleDefs" }, + { + "name": "DefLikeMacros", + "description": "DefLikeMacros" + }, { "name": "AllowAdjacentOneLineDefs", "description": "AllowAdjacentOneLineDefs" @@ -2175,7 +2199,25 @@ "patternId": "Lint_MissingSuper", "title": "Checks for the presence of constructors and lifecycle callbacks without calls to `super`.", "description": "Checks for the presence of constructors and lifecycle callbacks without calls to `super`.", - "timeToFix": 5 + "timeToFix": 5, + "parameters": [ + { + "name": "AllowedParentClasses", + "description": "AllowedParentClasses" + } + ] + }, + { + "patternId": "Lint_MixedCaseRange", + "title": "Checks for mixed-case character ranges since they include likely unintended characters.", + "description": "Checks for mixed-case character ranges since they include likely unintended characters.", + "timeToFix": 5, + "parameters": [ + { + "name": "SafeAutoCorrect", + "description": "SafeAutoCorrect" + } + ] }, { "patternId": "Lint_MixedRegexpCaptureTypes", @@ -2383,6 +2425,12 @@ } ] }, + { + "patternId": "Lint_RedundantRegexpQuantifiers", + "title": "Checks for redundant quantifiers in Regexps.", + "description": "Checks for redundant quantifiers in Regexps.", + "timeToFix": 5 + }, { "patternId": "Lint_RedundantRequireStatement", "title": "Checks for unnecessary `require` statement.", @@ -3488,6 +3536,10 @@ { "name": "AllowOnlyRestArgument", "description": "AllowOnlyRestArgument" + }, + { + "name": "UseAnonymousForwarding", + "description": "UseAnonymousForwarding" } ] }, @@ -4403,6 +4455,10 @@ "description": "Avoid Hash[] in favor of ary.to_h or literal hashes.", "timeToFix": 5, "parameters": [ + { + "name": "SafeAutoCorrect", + "description": "SafeAutoCorrect" + }, { "name": "AllowSplatArgument", "description": "AllowSplatArgument" @@ -4881,6 +4937,12 @@ "description": "Avoid redundant `::` prefix on constant.", "timeToFix": 5 }, + { + "patternId": "Style_RedundantCurrentDirectoryInPath", + "title": "Checks for uses a redundant current directory in path.", + "description": "Checks for uses a redundant current directory in path.", + "timeToFix": 5 + }, { "patternId": "Style_RedundantDoubleSplatHashBraces", "title": "Checks for redundant uses of double splat hash braces.", @@ -4955,6 +5017,12 @@ "description": "Check for redundant line continuation.", "timeToFix": 5 }, + { + "patternId": "Style_RedundantRegexpArgument", + "title": "Identifies places where argument can be replaced from a deterministic regexp to a string.", + "description": "Identifies places where argument can be replaced from a deterministic regexp to a string.", + "timeToFix": 5 + }, { "patternId": "Style_RedundantRegexpConstructor", "title": "Checks for the instantiation of regexp using redundant `Regexp.new` or `Regexp.compile`.", @@ -5813,6 +5881,26 @@ } ] }, + { + "patternId": "Style_ReturnNilInPredicateMethodDefinition", + "title": "Checks if uses of `return` or `return nil` in predicate method definition.", + "description": "Checks if uses of `return` or `return nil` in predicate method definition.", + "timeToFix": 5, + "parameters": [ + { + "name": "SafeAutoCorrect", + "description": "SafeAutoCorrect" + }, + { + "name": "AllowedMethods", + "description": "AllowedMethods" + }, + { + "name": "AllowedPatterns", + "description": "AllowedPatterns" + } + ] + }, { "patternId": "Style_SafeNavigation", "title": "Transforms usages of a method call safeguarded by a check for the existence of the object to safe navigation (`&.`). Autocorrection is unsafe as it assumes the object will be `nil` or truthy, but never `false`.", @@ -6387,6 +6475,12 @@ } ] }, + { + "patternId": "Style_YAMLFileRead", + "title": "Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.", + "description": "Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.", + "timeToFix": 5 + }, { "patternId": "Style_YodaCondition", "title": "Forbid or enforce yoda conditions.", @@ -6735,6 +6829,18 @@ } ] }, + { + "patternId": "Performance_MapMethodChain", + "title": "Checks if the `map` method is used in a chain.", + "description": "Checks if the `map` method is used in a chain.", + "timeToFix": 5, + "parameters": [ + { + "name": "Safe", + "description": "Safe" + } + ] + }, { "patternId": "Performance_MethodObjectAsBlock", "title": "Use block explicitly instead of block-passing a method object.", @@ -8525,6 +8631,12 @@ "description": "Disallows use of `T.untyped` or `T.nilable(T.untyped)` as a prop type for `T::Struct` subclasses.", "timeToFix": 5 }, + { + "patternId": "Sorbet_ImplicitConversionMethod", + "title": "This cop disallows declaring implicit conversion methods, as sorbet does not support implicit conversion.", + "description": "This cop disallows declaring implicit conversion methods, as sorbet does not support implicit conversion.", + "timeToFix": 5 + }, { "patternId": "Sorbet_OneAncestorPerLine", "title": "Enforces one ancestor per call to requires_ancestor", @@ -8583,6 +8695,22 @@ } ] }, + { + "patternId": "Sorbet_ObsoleteStrictMemoization", + "title": "This cop checks for the obsolete pattern for initializing instance variables that was required for older Sorbet versions in `#typed: strict` files.\nIt's no longer required, as of Sorbet 0.5.10210 See https://sorbet.", + "description": "This cop checks for the obsolete pattern for initializing instance variables that was required for older Sorbet versions in `#typed: strict` files.\nIt's no longer required, as of Sorbet 0.5.10210 See https://sorbet.org/docs/type-assertions#put-type-assertions-behind-memoization", + "timeToFix": 5, + "parameters": [ + { + "name": "Safe", + "description": "Safe" + }, + { + "name": "SafeAutoCorrect", + "description": "SafeAutoCorrect" + } + ] + }, { "patternId": "Sorbet_ForbidExtendTSigHelpersInShims", "title": "Forbid the use of `extend T::Sig` and `extend T::Helpers` in RBI shims", @@ -8677,6 +8805,10 @@ "name": "MinimumStrictness", "description": "MinimumStrictness" }, + { + "name": "ExactStrictness", + "description": "ExactStrictness" + }, { "name": "Include", "description": "Include" @@ -8701,6 +8833,10 @@ "name": "MinimumStrictness", "description": "MinimumStrictness" }, + { + "name": "ExactStrictness", + "description": "ExactStrictness" + }, { "name": "Include", "description": "Include" diff --git a/docs/patterns.json b/docs/patterns.json index 7ed7db94..09757fbc 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,6 +1,6 @@ { "name": "rubocop", - "version": "1.52.1", + "version": "1.56.1", "patterns": [ { "patternId": "Migration_DepartmentName", @@ -28,6 +28,26 @@ ], "enabled": false }, + { + "patternId": "Bundler_DuplicatedGroup", + "level": "Info", + "category": "CodeStyle", + "parameters": [ + { + "name": "Severity", + "default": "warning" + }, + { + "name": "Include", + "default": [ + "**/*.gemfile", + "**/Gemfile", + "**/gems.rb" + ] + } + ], + "enabled": false + }, { "patternId": "Bundler_GemComment", "level": "Info", @@ -504,6 +524,10 @@ "level": "Info", "category": "CodeStyle", "parameters": [ + { + "name": "SafeAutoCorrect", + "default": "false" + }, { "name": "Categories", "default": "{\"module_inclusion\"=>[\"include\", \"prepend\", \"extend\"]}" @@ -652,6 +676,12 @@ "name": "EmptyLineBetweenModuleDefs", "default": "true" }, + { + "name": "DefLikeMacros", + "default": [ + + ] + }, { "name": "AllowAdjacentOneLineDefs", "default": "true" @@ -2462,6 +2492,26 @@ "patternId": "Lint_MissingSuper", "level": "Warning", "category": "ErrorProne", + "parameters": [ + { + "name": "AllowedParentClasses", + "default": [ + + ] + } + ], + "enabled": false + }, + { + "patternId": "Lint_MixedCaseRange", + "level": "Warning", + "category": "ErrorProne", + "parameters": [ + { + "name": "SafeAutoCorrect", + "default": "false" + } + ], "enabled": false }, { @@ -2697,6 +2747,12 @@ ], "enabled": false }, + { + "patternId": "Lint_RedundantRegexpQuantifiers", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, { "patternId": "Lint_RedundantRequireStatement", "level": "Warning", @@ -4001,6 +4057,10 @@ { "name": "AllowOnlyRestArgument", "default": "true" + }, + { + "name": "UseAnonymousForwarding", + "default": "true" } ], "enabled": false @@ -5043,6 +5103,10 @@ "level": "Info", "category": "CodeStyle", "parameters": [ + { + "name": "SafeAutoCorrect", + "default": "false" + }, { "name": "AllowSplatArgument", "default": "true" @@ -5572,6 +5636,12 @@ "category": "CodeStyle", "enabled": false }, + { + "patternId": "Style_RedundantCurrentDirectoryInPath", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, { "patternId": "Style_RedundantDoubleSplatHashBraces", "level": "Info", @@ -5646,6 +5716,12 @@ "category": "CodeStyle", "enabled": false }, + { + "patternId": "Style_RedundantRegexpArgument", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, { "patternId": "Style_RedundantRegexpConstructor", "level": "Info", @@ -6424,7 +6500,7 @@ }, { "name": "Methods", - "default": "{\"join\"=>\"\", \"sum\"=>0, \"split\"=>\" \", \"chomp\"=>\"\\n\", \"chomp!\"=>\"\\n\"}" + "default": "{\"join\"=>\"\", \"sum\"=>0, \"exit\"=>true, \"exit!\"=>false, \"split\"=>\" \", \"chomp\"=>\"\\n\", \"chomp!\"=>\"\\n\"}" } ], "enabled": false @@ -6611,6 +6687,30 @@ ], "enabled": false }, + { + "patternId": "Style_ReturnNilInPredicateMethodDefinition", + "level": "Info", + "category": "CodeStyle", + "parameters": [ + { + "name": "SafeAutoCorrect", + "default": "false" + }, + { + "name": "AllowedMethods", + "default": [ + + ] + }, + { + "name": "AllowedPatterns", + "default": [ + + ] + } + ], + "enabled": false + }, { "patternId": "Style_SafeNavigation", "level": "Info", @@ -7270,6 +7370,12 @@ ], "enabled": false }, + { + "patternId": "Style_YAMLFileRead", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, { "patternId": "Style_YodaCondition", "level": "Info", @@ -7634,6 +7740,18 @@ ], "enabled": false }, + { + "patternId": "Performance_MapMethodChain", + "level": "Warning", + "category": "Performance", + "parameters": [ + { + "name": "Safe", + "default": "false" + } + ], + "enabled": false + }, { "patternId": "Performance_MethodObjectAsBlock", "level": "Warning", @@ -9638,6 +9756,12 @@ "category": "CodeStyle", "enabled": false }, + { + "patternId": "Sorbet_ImplicitConversionMethod", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, { "patternId": "Sorbet_OneAncestorPerLine", "level": "Info", @@ -9702,6 +9826,22 @@ ], "enabled": false }, + { + "patternId": "Sorbet_ObsoleteStrictMemoization", + "level": "Info", + "category": "CodeStyle", + "parameters": [ + { + "name": "Safe", + "default": "true" + }, + { + "name": "SafeAutoCorrect", + "default": "true" + } + ], + "enabled": false + }, { "patternId": "Sorbet_ForbidExtendTSigHelpersInShims", "level": "Info", @@ -9802,7 +9942,11 @@ }, { "name": "MinimumStrictness", - "default": "false" + "default": "nil" + }, + { + "name": "ExactStrictness", + "default": "nil" }, { "name": "Include", @@ -9832,7 +9976,11 @@ }, { "name": "MinimumStrictness", - "default": "false" + "default": "nil" + }, + { + "name": "ExactStrictness", + "default": "nil" }, { "name": "Include",