1.0.1 warnings - recommended code uses inconsistent capitalized constants
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 125
- Forks
- 65
- Avg merge
- 6h 4m
- Merged PRs (30d)
- 2
Description
@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!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the warning definitions in lib/uri/common.rb and lib/uri/rfc3986_parser.rb, using the issue's git grep results to review each recommendation. Check how the existing constants are defined and determine the consistent capitalized forms to expose. Done means the warnings recommend consistently cased constants without confusing parser and parser-class names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100