From 10187777c3bc254a8ab74e13389ecc7a55d7c9a0 Mon Sep 17 00:00:00 2001 From: Cody Hansen Date: Wed, 2 Aug 2023 07:02:01 -1000 Subject: [PATCH] Removed some redundant code --- .../merlin/processor/utils/JavadocParser.java | 15 +++++++-------- .../aerie/scheduler/goals/CardinalityGoal.java | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/merlin-framework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/utils/JavadocParser.java b/merlin-framework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/utils/JavadocParser.java index d1b4dbcb34..24043062bf 100644 --- a/merlin-framework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/utils/JavadocParser.java +++ b/merlin-framework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/utils/JavadocParser.java @@ -51,7 +51,7 @@ public static Map parseMissionModelUnits(Elements elementUtils, property = "/" + property; } - parsedUnits.put(property, extractTagValue(UNITS_TAG, value)); + parsedUnits.put(property, extractTagValue(value)); } }); @@ -59,7 +59,7 @@ public static Map parseMissionModelUnits(Elements elementUtils, } /** - * Parses javadocs searching for parameters + unit paris and computed attributes + unit pairs. + * Parses javadocs searching for parameters + unit paris and computed attributes + unit pairs. * @param elementUtils Utility functions for file parsing. * @param element The element we're parsing the comments for. * @return A pair of maps, one with the parameter units and one with the computed attribute units. @@ -85,7 +85,7 @@ public static Pair, Map> parseActivityTypeUn var property = $.getKey(); if (value.contains(UNITS_TAG) && !value.contains(COMPUTED_ATTRIBUTE_TAG)) { - parameterUnits.put(property, extractTagValue(UNITS_TAG, value)); + parameterUnits.put(property, extractTagValue(value)); } }); @@ -129,16 +129,15 @@ public static String removeSingleLeadingSpaceFromEachLine(final String s) { * Extracts the tag value from a given tag and comment. * Ex: "@unit mass in grams" will return "mass in grams". * - * @param tag The tag to search for. * @param comment The entire comment string that we're parsing the tag value from. * @return The comment value after the found tag. */ - private static String extractTagValue(String tag, String comment) { - if (comment.isEmpty() || !comment.contains(tag)) { + private static String extractTagValue(String comment) { + if (!comment.contains(JavadocParser.UNITS_TAG)) { return ""; } - return comment.substring(comment.indexOf(tag) + tag.length()).trim(); + return comment.substring(comment.indexOf(JavadocParser.UNITS_TAG) + JavadocParser.UNITS_TAG.length()).trim(); } private static void parseComment(String comment, Map parsedUnits, String tag) { @@ -151,7 +150,7 @@ private static void parseComment(String comment, Map parsedUnits } if (!lastItem.isEmpty() && splitComment.contains(UNITS_TAG)) { - parsedUnits.put(lastItem, extractTagValue(UNITS_TAG, splitComment)); + parsedUnits.put(lastItem, extractTagValue(splitComment)); } } } diff --git a/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/goals/CardinalityGoal.java b/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/goals/CardinalityGoal.java index 1dd01c4cfc..fe8cec9f10 100644 --- a/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/goals/CardinalityGoal.java +++ b/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/goals/CardinalityGoal.java @@ -161,7 +161,6 @@ else if (this.initiallyEvaluatedTemporalContext == null) { if (total.compareTo(this.durationRange.start) < 0) { durToSchedule = this.durationRange.start.minus(total); } else if (total.compareTo(this.durationRange.end) > 0) { - logger.warn( "Need to decrease duration of activities from the plan, impossible because scheduler cannot remove activities"); return List.of(new UnsatisfiableGoalConflict( this,