Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Yf add unknown so #862
Conversation
yfarjoun
added some commits
Apr 20, 2017
codecov-io
commented
Apr 20, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #862 +/- ##
==============================================
+ Coverage 64.939% 64.98% +0.041%
- Complexity 7210 7283 +73
==============================================
Files 527 527
Lines 31802 32025 +223
Branches 5426 5486 +60
==============================================
+ Hits 20652 20810 +158
- Misses 9017 9082 +65
Partials 2133 2133
|
| @@ -48,13 +49,14 @@ | ||
| public static final String GROUP_ORDER_TAG = "GO"; | ||
| public static final String CURRENT_VERSION = "1.5"; | ||
| public static final Set<String> ACCEPTABLE_VERSIONS = | ||
| - new HashSet<String>(Arrays.asList("1.0", "1.3", "1.4", "1.5")); | ||
| + new HashSet<>(Arrays.asList("1.0", "1.3", "1.4", "1.5")); |
tfenne
Apr 20, 2017
Owner
Well, if you're going to start cleaning up, this could be CollectionUtil.makeSet(....)
| unsorted(null), | ||
| + unknown(null), |
tfenne
Apr 20, 2017
Owner
While it's probably not important, it's good practice to add new enum values at the end, in case anyone relied on the previous ordering/ordinal values.
| private final Map<String, SAMReadGroupRecord> mReadGroupMap = | ||
| - new HashMap<String, SAMReadGroupRecord>(); | ||
| - private final Map<String, SAMProgramRecord> mProgramRecordMap = new HashMap<String, SAMProgramRecord>(); | ||
| + new HashMap<>(); |
| @@ -253,7 +255,12 @@ public SortOrder getSortOrder() { | ||
| if (so == null || so.equals("unknown")) { |
tfenne
Apr 20, 2017
Owner
Should probably get rid of the so.equals("unknown") here since that's now a valid value?
| + try { | ||
| + return SortOrder.valueOf(so); | ||
| + } catch (IllegalArgumentException e) { | ||
| + log.warn("Found non conforming header SO tag: "+ so + ". Treating as 'unknown'."); |
tfenne
Apr 20, 2017
Owner
The existing implementation here is poor - the fact that it translates from the String on every access. I hadn't realized it was doing that. This also means though, that it's going to log your warning on every access. What do you think about either changing the class to cache the SortOrder enum value or adding setAttribute("SO", "unknown") in the catch?
yfarjoun
Apr 21, 2017
Contributor
I don't like changing the header, as that might have side-effects (the header might be used later to write a file.)
I'll try to cache the resulting enum.
|
merging under the assumption that the minor comments were addressed in my latest PR. @tfenne please let me know if I was being overly presumptuous and I'll be happy to revert and discuss further. |
yfarjoun commentedApr 20, 2017
Description
Adds validation to the values in the SO and GO tags in the SAM header.