IPAddr#mask method accepts arguments other than integers.
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- ruby
- 领域
- networking
调研方向
从 IPAddr#mask 方法开始,复现 issue 中的 float 和 array 示例。当非整数参数引发 IPAddr::InvalidPrefixError,同时整数掩码继续按预期工作时,此更改即完成。
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- Ruby
- 星标
- 82
- 派生
- 42
- 平均合并
- 2 小时 24 分钟
- 30 天内合并 PR
- 3
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/ipaddr 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 64/100
-
难度 4/5 3-5 天 新手友好度 48/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 46/100
相似的 Issue
-
user-reported
难度 2/5 1-3 小时 新手友好度 85/100
Kong/developer.konghq.com#7316 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
TheOdinProject/curriculum#31408 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
bensheldon/good_job#1816 · 5 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
notch8/utk_knapsack#148 ·
-
难度 1/5 1 小时以内 新手友好度 78/100
Homebrew/homebrew-cask#288729 · 1 条评论 ·