Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`RuboCop::Cop::Airbnb::ModuleMethodInWrongFile` returns incorrect error message when defining a method inside singleton class

Đang mở
#190 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ruby
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với rubocop-airbnb/lib/rubocop/cop/airbnb/module_method_in_wrong_file.rb quanh dòng 88 và spec tại rubocop-airbnb/spec/rubocop/cop/airbnb/module_method_in_wrong_file_spec.rb quanh dòng 96. Chạy spec đó và kiểm tra normalize_module_name(node.parent_module_name). Được xem là hoàn tất khi trường hợp singleton-class báo cáo “Method baz should be defined in foo.rb” và spec kiểm tra nội dung của offense.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

When developing PR #189, tests were changed to use new rspec-rubocop syntax which also checks that the message generated is correct. After doing this, the spec that checks that an error is returned when using "<<" static methods and a non-matching name failed with an incorrect message:

Method baz should be defined in foo/foo.rb

When the expected message was:

Method baz should be defined in foo.rb

After digging a little about it to understand what was happening, we realized that this incorrect message is also present on master – but there are no assertions respecting the offense's text, thus the test succeeds.
The issue seems to be caused by the method normalize_module_name(node.parent_module_name) (on module_method_in_wrong_file.rb#L88) which returns Foo::Foo instead of just Foo.

Ngôn ngữ chính
Ruby
Star
3.9k
Fork
757
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của airbnb/ruby

Tất cả issue của airbnb/ruby

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.