Skip to content

Fix writing generics type of rbs-inline annotation for nested class in Style/CommentedKeyword#13915

Merged
koic merged 1 commit intorubocop:masterfrom
dak2:rbs-inline/generics-type-in-commented-keyword-for-nested-class
Feb 27, 2025
Merged

Fix writing generics type of rbs-inline annotation for nested class in Style/CommentedKeyword#13915
koic merged 1 commit intorubocop:masterfrom
dak2:rbs-inline/generics-type-in-commented-keyword-for-nested-class

Conversation

@dak2
Copy link
Contributor

@dak2 dak2 commented Feb 26, 2025

RBS::Inline is a utility to embed RBS type declarations into Ruby code as comments.

I made rules for generics type below pull request, but nested classes were not supported.

Follow #13476


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@dak2 dak2 force-pushed the rbs-inline/generics-type-in-commented-keyword-for-nested-class branch from 44dad0b to 8690d7d Compare February 26, 2025 14:37
@dak2 dak2 marked this pull request as ready for review February 26, 2025 14:46
REGEXP = /(?<keyword>\S+).*#/.freeze

SUBCLASS_DEFINITION = /\A\s*class\s+\w+\s*<\s*\w+/.freeze
SUBCLASS_DEFINITION = /\A\s*class\s+[\w:]+\s*<\s*[\w:]+/.freeze
Copy link
Member

Choose a reason for hiding this comment

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

I think using :: makes it clearer as an identifier. What do you think?

Suggested change
SUBCLASS_DEFINITION = /\A\s*class\s+[\w:]+\s*<\s*[\w:]+/.freeze
SUBCLASS_DEFINITION = /\A\s*class\s+(\w|::)+\s*<\s*(\w|::)+/.freeze

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@koic
Thanks for the suggestion!!
I adopted it because it's clearer than my implement.

…n `Style/CommentedKeyword`

[RBS::Inline](https://github.com/soutaro/rbs-inline) is a utility to
embed RBS type declarations into Ruby code as comments.

I made rules for generics type below pull request, but nested classes were not supported.

Follow rubocop#13476
@dak2 dak2 force-pushed the rbs-inline/generics-type-in-commented-keyword-for-nested-class branch from 8690d7d to 0e33424 Compare February 27, 2025 00:38
@dak2 dak2 requested a review from koic February 27, 2025 00:46
@koic koic merged commit bdcad3b into rubocop:master Feb 27, 2025
24 checks passed
@koic
Copy link
Member

koic commented Feb 27, 2025

Thanks!

@dak2 dak2 deleted the rbs-inline/generics-type-in-commented-keyword-for-nested-class branch February 27, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants