Skip to content

Enable cops in the Lint Department #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 1, 2025
Merged

Enable cops in the Lint Department #694

merged 9 commits into from
Apr 1, 2025

Conversation

rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Feb 20, 2025

@rafaelfranca rafaelfranca requested a review from a team as a code owner February 20, 2025 21:00
@github-actions github-actions bot added the config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops label Feb 20, 2025
Copy link
Member

@burke burke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all look super reasonable to me, I think you've made good decisions here.

The following Lint cops were enabled:

* [Lint/AmbiguousAssignment](https://docs.rubocop.org/rubocop/cops_lint.html#lintambiguousassignment)
* [Lint/AmbiguousOperator](https://docs.rubocop.org/rubocop/cops_lint.html#lintambiguousoperator)
* [Lint/BigDecimalNew](https://docs.rubocop.org/rubocop/cops_lint.html#lintbigdecimalnew)
* [Lint/BinaryOperatorWithIdenticalOperands](https://docs.rubocop.org/rubocop/cops_lint.html#lintbinaryoperatorwithidenticaloperands)
* [Lint/CircularArgumentReference](https://docs.rubocop.org/rubocop/cops_lint.html#lintcircularargumentreference)
* [Lint/ConstantOverwrittenInRescue](https://docs.rubocop.org/rubocop/cops_lint.html#lintconstantoverwritteninrescue)
* [Lint/ConstantReassignment](https://docs.rubocop.org/rubocop/cops_lint.html#lintconstantreassignment)
* [Lint/CopDirectiveSyntax](https://docs.rubocop.org/rubocop/cops_lint.html#lintcopdirectivesyntax)
* [Lint/Debugger](https://docs.rubocop.org/rubocop/cops_lint.html#lintdebugger)
* [Lint/DeprecatedClassMethods](https://docs.rubocop.org/rubocop/cops_lint.html#lintdeprecatedclassmethods)
* [Lint/DeprecatedOpenSSLConstant](https://docs.rubocop.org/rubocop/cops_lint.html#lintdeprecatedopensslconstant)
* [Lint/DisjunctiveAssignmentInConstructor](https://docs.rubocop.org/rubocop/cops_lint.html#lintdisjunctiveassignmentinconstructor)
* [Lint/DuplicateCaseCondition](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicatecasecondition)
* [Lint/DuplicateElsifCondition](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicateelsifcondition)
* [Lint/DuplicateHashKey](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicatehashkey)
* [Lint/DuplicateMagicComment](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicatemagiccomment)
* [Lint/DuplicateMatchPattern](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicatematchpattern)
* [Lint/DuplicateMethods](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicatemethods)
* [Lint/DuplicateRegexpCharacterClassElement](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicateregexpcharacterclasselement)
* [Lint/DuplicateRequire](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicaterequire)
* [Lint/DuplicateRescueException](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicaterescueexception)
* [Lint/DuplicateSetElement](https://docs.rubocop.org/rubocop/cops_lint.html#lintduplicatesetelement)
* [Lint/EachWithObjectArgument](https://docs.rubocop.org/rubocop/cops_lint.html#linteachwithobjectargument)
* [Lint/ElseLayout](https://docs.rubocop.org/rubocop/cops_lint.html#lintelselayout)
* [Lint/EmptyEnsure](https://docs.rubocop.org/rubocop/cops_lint.html#lintemptyensure)
* [Lint/EmptyExpression](https://docs.rubocop.org/rubocop/cops_lint.html#lintemptyexpression)
* [Lint/EmptyInterpolation](https://docs.rubocop.org/rubocop/cops_lint.html#lintemptyinterpolation)
* [Lint/EnsureReturn](https://docs.rubocop.org/rubocop/cops_lint.html#lintensurereturn)
* [Lint/ImplicitStringConcatenation](https://docs.rubocop.org/rubocop/cops_lint.html#lintimplicitstringconcatenation)
* [Lint/IneffectiveAccessModifier](https://docs.rubocop.org/rubocop/cops_lint.html#lintineffectiveaccessmodifier)
* [Lint/InterpolationCheck](https://docs.rubocop.org/rubocop/cops_lint.html#lintinterpolationcheck)
* [Lint/LiteralAsCondition](https://docs.rubocop.org/rubocop/cops_lint.html#lintliteralascondition)
* [Lint/LiteralInInterpolation](https://docs.rubocop.org/rubocop/cops_lint.html#lintliteralininterpolation)
* [Lint/MissingCopEnableDirective](https://docs.rubocop.org/rubocop/cops_lint.html#lintmissingcopenabledirective)
* [Lint/MixedCaseRange](https://docs.rubocop.org/rubocop/cops_lint.html#lintmixedcaserange)
* [Lint/MultipleComparison](https://docs.rubocop.org/rubocop/cops_lint.html#lintmultiplecomparison)
* [Lint/NestedMethodDefinition](https://docs.rubocop.org/rubocop/cops_lint.html#lintnestedmethoddefinition)
* [Lint/NestedPercentLiteral](https://docs.rubocop.org/rubocop/cops_lint.html#lintnestedpercentliteral)
* [Lint/NextWithoutAccumulator](https://docs.rubocop.org/rubocop/cops_lint.html#lintnextwithoutaccumulator)
* [Lint/NoReturnInBeginEndBlocks](https://docs.rubocop.org/rubocop/cops_lint.html#lintnoreturnInbeginendblocks)
* [Lint/NumericOperationWithConstantResult](https://docs.rubocop.org/rubocop/cops_lint.html#lintnumericoperationwithconstantresult)
* [Lint/OrAssignmentToConstant](https://docs.rubocop.org/rubocop/cops_lint.html#lintoreassignmenttoconstant)
* [Lint/ParenthesesAsGroupedExpression](https://docs.rubocop.org/rubocop/cops_lint.html#lintparenthesesasgroupedexpression)
* [Lint/RedundantCopDisableDirective](https://docs.rubocop.org/rubocop/cops_lint.html#lintredundantcopdisabledirective)
* [Lint/RedundantCopEnableDirective](https://docs.rubocop.org/rubocop/cops_lint.html#lintredundantcopenabledirective)
* [Lint/RedundantStringCoercion](https://docs.rubocop.org/rubocop/cops_lint.html#lintredundantstringcoercion)
* [Lint/RedundantWithIndex](https://docs.rubocop.org/rubocop/cops_lint.html#lintredundantwithindex)
* [Lint/RedundantWithObject](https://docs.rubocop.org/rubocop/cops_lint.html#lintredundantwithobject)
* [Lint/RegexpAsCondition](https://docs.rubocop.org/rubocop/cops_lint.html#lintregexpascondition)
* [Lint/ReturnInVoidContext](https://docs.rubocop.org/rubocop/cops_lint.html#lintreturninvoidcontext)
* [Lint/SelfAssignment](https://docs.rubocop.org/rubocop/cops_lint.html#lintselfassignment)
* [Lint/SendWithMixinArgument](https://docs.rubocop.org/rubocop/cops_lint.html#lintsendwithmixinargument)
* [Lint/TripleQuotes](https://docs.rubocop.org/rubocop/cops_lint.html#linttriplequotes)
This cop checks for the use of `return` with a value in `begin..end` blocks
in the context of instance variable assignment such as memoization. Using
`return` with a value in these blocks can lead to unexpected behavior as
the `return` will exit the method and not set the value of the instance
variable.
We only support Rubocop 1.72.
Now we have Lint/NoReturnInMemoization cop that should replace this one.
Make explicit that this is going to be a major version bump.
Add Lint/NoReturnInMemoization cop
@cbothner
Copy link
Member

cbothner commented Mar 14, 2025

Should we also re-enable Lint/SafeNavigationChain? It would have caught a bug that just slipped to prod (luckily behind a flag that could be immediately rolled back.) Ruby's safe-navigation behavior is inconsistent with Typescript's optional chaining, which can be a footgun for a lot of devs.

// in typescript
foo?.bar.baz()
// is equivalent to 
foo === null || foo === undefined
  ? undefined
  : foo.bar.baz()
# in ruby
foo&.bar.baz
# is equivalent to
(foo == nil ? nil : foo.bar).baz # NoMethodError: undefined method `baz' for nil:NilClass

@rafaelfranca
Copy link
Member Author

Yes. I'm wondering how did I forgot about it.

@rafaelfranca rafaelfranca merged commit ee04a60 into main Apr 1, 2025
21 checks passed
@rafaelfranca rafaelfranca deleted the rm-lint-department branch April 1, 2025 15:00
@rafaelfranca rafaelfranca restored the rm-lint-department branch April 1, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants