mapbox / mapbox/mapbox-java

TurfMeasurement#length method cannot handle empty lists

オープン
#1,484 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

jira-sync-complete
主要言語
Java
スター
438
フォーク
117
PR マージ指標
30日以内にマージされた PR はありません

説明

The other day, I encountered what I regard as an issue in the following Code snippet: https://github.com/mapbox/mapbox-java/blob/4ae8b78746fb37b2673364bdd4c8702057f3e7f3/services-turf/src/main/java/com/mapbox/turf/TurfMeasurement.java#L227
The scenario is the following: We have a list of GPS points of which some or all are invalid which is denoted by the coordinates being (0 , 0) - which IS bad Design, but our Team cannot change this... 🙄. Thus, we filter out those points before passing it to the length method. We just encountered an IndexOutOfBoundsException when the list is empty because there is no length check on the list. I guess the fix here is relatively easy, but the question ist - what should be returned in this case. We built in a check before hand returning 0 in this particular case. Maybe even a checked exception might be a feasible idea.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

services-turf/src/main/java/com/mapbox/turf/TurfMeasurement.java のリンク先の length メソッド付近から始め、空のリストで発生する失敗を再現します。メソッドが通常のポイントリストをどのように処理するかを確認し、空の入力に対して意図されている契約を明らかにするため、近くの使用箇所を確認します。動作について合意され、空のリストの場合に予期せず例外がスローされなくなり、回帰テストによるカバレッジでそれが検証されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
backend-api-design
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。