adoptium / adoptium/aqa-test-tools
Simplify the logic in PerfCompare.js
- Dominant language
- Jupyter Notebook
- Stars
- 33
- Forks
- 97
- Avg merge
- 7h 9m
- Merged PRs (30d)
- 5
Description
In [PerfCompare.js](https://github.com/AdoptOpenJDK/openjdk-test-tools/blob/master/test-result-summary-client/src/PerfCompare/PerfCompare.jsx), we are using `undefined`, `null`, `""` to represent different meanings. I think we should simplify the logic.
- [ ] `higherbetter ` should have only two state. i.e., true or false. There is no need to have a third state `undefined`. The default value for `higherbetter` in [BenchmarkMetric.js](https://github.com/AdoptOpenJDK/openjdk-test-tools/blob/master/TestResultSummaryService/parsers/BenchmarkMetric.js) should be true. It only needs to set explicitly if it is false.
- [ ] Remove sepcific checks for `undefined`, `null`, `""`. Update code as the following:
```
if (resBenchmarkRunsJson === undefined || (Object.keys(resBenchmarkRunsJson).length === 0 && resBenchmarkRunsJson.constructor === Object) ||
resBenchmarkRunsJson.baselineCSV === undefined || resBenchmarkRunsJson.testCSV === undefined) {
```
to
```
if (!resBenchmarkRunsJson || !resBenchmarkRunsJson.baselineCSV || !resBenchmarkRunsJson.testCSV)
```
Please check the code and update similar checks.
Contributor guide
Research direction
Start by reading test-result-summary-client/src/PerfCompare/PerfCompare.jsx and TestResultSummaryService/parsers/BenchmarkMetric.js, then search these areas for the undefined, null, and empty-string checks. Done means higherbetter defaults to true and uses only true or false, while equivalent checks are simplified consistently without changing the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100