IPAddr#mask method accepts arguments other than integers.
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- ruby
- Domain
- networking
Research direction
Start at the IPAddr#mask method and reproduce the float and array examples from the issue. The change is done when non-integer arguments raise IPAddr::InvalidPrefixError while integer masks continue to work as expected.
Written by the indexing model from the issue text.
Description
IPAddr#mask method expects an integer argument, but it accepts non-integer values (such as floats or arrays) if passed.
ip = IPAddr.new('1.2.3.4')
p ip.mask(0.1)
# => #<IPAddr: IPv4:0.0.0.0/128.0.0.0>
p ip.mask(1.2)
# => #<IPAddr: IPv4:0.0.0.0/192.0.0.0>
p ip.mask(11.3)
# => #<IPAddr: IPv4:1.0.0.0/255.240.0.0>
p ip.mask([])
# => `mask!': undefined method `<' for []:Array (NoMethodError)
So, I think it is better to restrict the arguments of this method to integers and throw an exception if they are not integers.
Like this.
ip = IPAddr.new('1.2.3.4')
p ip.mask(0.1)
# => `mask!': invalid mask 0.1 (IPAddr::InvalidPrefixError)
I'm currently implementing this improvement and want to submit a pull request as a contribute to this repo.
Would this be acceptable?
- Dominant language
- Ruby
- Stars
- 82
- Forks
- 42
- Avg merge
- 2h 24m
- Merged PRs (30d)
- 3
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.
More from ruby/ipaddr
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 46/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100