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

1.0.1 warnings - recommended code uses inconsistent capitalized constants

Đang mở
#128 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ruby
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với các định nghĩa cảnh báo trong lib/uri/common.rb và lib/uri/rfc3986_parser.rb, sử dụng kết quả git grep của issue để xem xét từng khuyến nghị. Kiểm tra cách các hằng số hiện có được định nghĩa và xác định các dạng viết hoa nhất quán cần được expose. Hoàn tất khi các cảnh báo khuyến nghị các hằng số có cách viết hoa nhất quán mà không nhầm lẫn tên parser và parser-class.

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

Mô tả

@hsbt First of all, thank you again for your work on ruby.

Following up on #125. The "suggested" or recommended code in the warnings can be confusing:

% ruby -W2 -e "puts RUBY_VERSION; require 'uri'; puts URI::VERSION; puts URI::PATTERN; URI::DEFAULT_PARSER.escape(''); URI::DEFAULT_PARSER.unescape(''); puts URI::Regexp; puts URI::REGEXP"
3.1.6
1.0.1
-e:1: warning: URI::PATTERN is obsolete. Use RFC2396_Parser::PATTERN explicitly.
URI::RFC2396_REGEXP::PATTERN
-e:1: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.
-e:1: warning: URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly.
-e:1: warning: URI::Regexp is obsolete. Use RFC2396_Parser::Regexp explicitly.
Regexp
-e:1: warning: URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.
URI::RFC2396_REGEXP

The problem is this:
RFC2396_Parser vs. RFC2396_PARSER or RFC2396_Parser::Regexp vs. URI::RFC2396_REGEXP

It's easy to make a mistake and use the wrong case. They're very similar names with different capitalization but they're not the same thing. I'm sure there are others:

% git grep "explicitly" lib/uri*
lib/uri/common.rb:      warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
lib/uri/common.rb:      warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
lib/uri/common.rb:      warn "URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
lib/uri/rfc3986_parser.rb:      warn "URI::RFC3986_PARSER.extract is obsoleted. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
lib/uri/rfc3986_parser.rb:      warn "URI::RFC3986_PARSER.make_regexp is obsoleted. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
lib/uri/rfc3986_parser.rb:      warn "URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
lib/uri/rfc3986_parser.rb:      warn "URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE

Can we add capitalized versions of constants so we can consistently suggest capitalized versions of constants in these warnings?

Thank you!

Ngôn ngữ chính
Ruby
Star
125
Fork
65
Merge trung bình
6 giờ 4 phút
Pull request đã merge (30 ngày)
2

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 ruby/uri

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

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.