Buggy code:
private static final String STRING_THURSDAY = "thursday" ; private static final String STRING_FRIDAY = "friday" ; private static final String STRING_SATURDAY = "saturday" ; private static final String STRING_SUNDAY = "sunday" ; public static ParsedInput parseInput ( String input ) throws InvalidRecurringException , InvalidTodoNameException { boolean hasLimit = false ; boolean isRecurring = false ; Period period = new Period ( ) ; ArrayList < String > words = Parser . tokenize ( input ) ; Keywords cType = Parser . getCommandType ( words ) ; if ( cType == ( Keywords . ERROR ) ) { return ParsedInput . getPlaceholder ( ) ; } ArrayList < Integer > dateIndexes = new ArrayList < Integer > ( ) ; DateTime limit = new DateTime ( 0 ) ; List < DateTime > dateTimes = new ArrayList < DateTime > ( ) ; ParsedInput returnInput ; ArrayList < KeyParamPair > keyParamPairs = Parser . extractParam ( words ) ; if ( cType == ( Keywords . ADD ) ) { for ( int i = 1 ; i < ( keyParamPairs . size ( ) ) ; i ++ ) { KeyParamPair currentPair = keyParamPairs . get ( i ) ; Keywords key = currentPair . getKeyword ( ) ; if ( InputStringKeyword . isFlag ( currentPair . getKeyString ( ) ) ) { throw new InvalidTodoNameException ( ) ; } if ( key == ( Keywords . UNTIL ) ) { if ( isRecurring ) { List < DateTime > parsedLimits = Parser . interpretAsDate ( keyParamPairs , currentPair , true ) ; if ( ! ( parsedLimits . isEmpty ( ) ) ) { limit = parsedLimits . get ( 0 ) ; hasLimit = true ; } } else { Parser . interpretAsName ( keyParamPairs , currentPair ) ; } } else if ( key == ( Keywords . EVERY ) ) { period = Parser . interpretAsPeriod ( period , keyParamPairs , currentPair ) ; if ( ! ( period . equals ( new Period ( ) ) ) ) { isRecurring = true ; if ( ( period . equals ( new Period ( ) . withDays ( 1 ) ) ) && ( dateTimes . isEmpty ( ) ) ) { dateTimes . add ( new DateTime ( ) . withTime ( 23 , 59 , 0 , 0 ) ) ; } } if ( dateTimes . isEmpty ( ) ) { List < DateTime > parsedDate = Parser . interpretAsDate ( keyParamPairs , currentPair , false ) ; if ( ! ( parsedDate . isEmpty ( ) ) ) { if ( ! isRecurring ) { period = period . withYears ( 1 ) ; isRecurring = true ; } Parser . addToDateTimes ( parsedDate , dateTimes , keyParamPairs , dateIndexes , i ) ; } } else if ( ! isRecurring ) { Parser . interpretAsName ( keyParamPairs , currentPair ) ; } } else { List < DateTime > parsedDates = Parser . interpretAsDate ( keyParamPairs , currentPair , true ) ; if ( ! ( parsedDates . isEmpty ( ) ) ) { Parser . addToDateTimes ( parsedDates , dateTimes , keyParamPairs , dateIndexes , i ) ; } } } for ( int i = ( keyParamPairs . size ( ) ) - 1 ; i > 0 ; i -- ) { keyParamPairs . remove ( i ) ; } } if ( cType == ( Keywords . EDIT ) ) { int toIndex ; String firstParam = keyParamPairs . get ( 0 ) . getParam ( ) ; if ( ( toIndex = firstParam . indexOf ( Parser . STRING_TO ) ) != ( - 1 ) ) { String toString = firstParam . substring ( toIndex , firstParam . length ( ) ) ; String toParam = toString . substring ( 3 , toString . length ( ) ) ; <START_BUG> keyParamPairs . get ( 0 ) . setParam ( firstParam . substring ( 0 , toIndex ) ) ; <END_BUG> keyParamPairs . add ( new KeyParamPair ( Keywords . TO , Parser . STRING_TO , toParam ) ) ; } for ( int i = 1 ; i < ( keyParamPairs . size ( ) ) ; i ++ ) { KeyParamPair currentPair = keyParamPairs . get ( i ) ; Keywords key = currentPair . getKeyword ( ) ; if ( key == ( Keywords . UNTIL ) ) { if ( isRecurring ) { List < DateTime > parsedLimits = Parser . interpretAsDate ( keyParamPairs , currentPair , true ) ; if ( ! ( parsedLimits . isEmpty ( ) ) ) { limit = parsedLimits . get ( 0 ) ; hasLimit = true ; } } else { Parser . interpretAsName ( keyParamPairs , currentPair ) ; } } else if ( key == ( Keywords . EVERY ) ) { period = Parser . interpretAsPeriod ( period , keyParamPairs , currentPair ) ; if ( ! ( period . equals ( new Period ( ) ) ) ) { isRecurring = true ; if ( ( period . equals ( new Period ( ) . withDays ( 1 ) ) ) && ( dateTimes . isEmpty ( ) ) ) { dateTimes . add ( new DateTime ( ) . withTime ( 23 , 59 , 0 , 0 ) ) ; } } if ( dateTimes . isEmpty ( ) ) { List < DateTime > parsedDate = Parser . interpretAsDate ( keyParamPairs , currentPair , false ) ; if ( ! ( parsedDate . isEmpty ( ) ) ) { if ( ! isRecurring ) { period = period . withYears ( 1 ) ; isRecurring = true ; } Parser . addToDateTimes ( parsedDate , dateTimes , keyParamPairs , dateIndexes , i ) ; } } else if ( ! isRecurring ) { Parser . interpretAsName ( keyParamPairs , currentPair ) ; } }

Fix:
keyParamPairs . get ( 0 ) . setParam ( firstParam . substring ( 0 , ( toIndex - 1 ) ) ) ;