Skip to content

feat: ControllerRecommendRestfulMethodsを改善#2

Merged
AT274 merged 1 commit intomainfrom
improve-controller-recommend-restful-methods
Apr 18, 2025
Merged

feat: ControllerRecommendRestfulMethodsを改善#2
AT274 merged 1 commit intomainfrom
improve-controller-recommend-restful-methods

Conversation

@ippachi
Copy link
Copy Markdown
Contributor

@ippachi ippachi commented Mar 23, 2025

  • 違反メソッドの複数検知に対応
  • publicメソッド以外を検知対象から除外
  • 推奨メソッドの設定機能を追加

- 違反メソッドの複数検知に対応
- publicメソッド以外を検知対象から除外
- 推奨メソッドの設定機能を追加

close: #1
@ippachi ippachi self-assigned this Mar 23, 2025
Copilot AI review requested due to automatic review settings March 23, 2025 13:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the ControllerRecommendRestfulMethods cop by supporting the detection of multiple non-RESTful methods, limiting its checks to public methods only, and introducing configurable recommended methods via the configuration file.

  • Updated .rubocop.yml to add inherit_mode for merging and exclude Metrics/BlockLength for specs.
  • Extended tests in the spec file to verify detection of multiple offenses and ensure non-public methods are excluded.
  • Modified the cop implementation to iterate over all action declarations and support configuration-driven recommended methods, with corresponding updates to the default configuration in config/default.yml.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
.rubocop.yml Added inherit_mode merge setting and Metrics/BlockLength exclusion for specs.
spec/rubocop/cop/dobado_architecture/controller_recommend_restful_methods_spec.rb Introduced new test cases to validate multiple offense detection, public-only filtering, and custom configuration.
lib/rubocop/cop/dobado_architecture/controller_recommend_restful_methods.rb Refactored the cop to support multiple detections and configurable recommended methods; removed VisibilityHelp inclusion.
config/default.yml Added default RecommendedMethods configuration used by the cop.
Comments suppressed due to low confidence (1)

lib/rubocop/cop/dobado_architecture/controller_recommend_restful_methods.rb:40

  • The call to non_public?(action) may fail because the VisibilityHelp module, which likely provided this method, has been removed. Consider reintroducing the method or implementing the public check logic directly.
next if non_public?(action)

@ippachi ippachi requested review from AT274 and perugo March 23, 2025 13:52
Copy link
Copy Markdown

@perugo perugo left a comment

Choose a reason for hiding this comment

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

実際に手元でテストを作ってみて良い感じでした。
モジュール下のクラスに対してもテストが適用されてました 🙆‍♂️

module XXX
  class class UsersController < ApplicationController

@perugo
Copy link
Copy Markdown

perugo commented Mar 25, 2025

本PRとは関係ないですが、 gitignoreに /vendor/ の追加もお願いします!

@ippachi
Copy link
Copy Markdown
Contributor Author

ippachi commented Mar 25, 2025

@perugo
レビューありがとうございます!
/vendor の追加に関しては @perugo が必要に応じてやってくれると!

Copy link
Copy Markdown

@AT274 AT274 left a comment

Choose a reason for hiding this comment

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

ほー、元からあるんだ
ありがとうございます

@AT274
Copy link
Copy Markdown

AT274 commented Mar 25, 2025

元からなかった
拡張のところをPRにしたわけね

@ippachi
Copy link
Copy Markdown
Contributor Author

ippachi commented Mar 25, 2025

@AT274
です!
全体はmainのコミット見てもらえると!
3個くらいなのでそこまで重くないです!

@AT274 AT274 merged commit 6a0f4a3 into main Apr 18, 2025
6 checks passed
@AT274 AT274 deleted the improve-controller-recommend-restful-methods branch April 18, 2025 07:13
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.

4 participants