Buggy code:
public class NoteComplexityVisitor implements IMusicElementVisitor { private static final int SCORE_REQUIRED = 2 ; private static final int INITIAL_LAST_NOTE_VALUE = - 1 ; private File xmlToParse ; private NodeList measures ; private int measureCount ; private int realMeasures ; private int currentMeasure ; private int noteCount ; private int lowNote ; private int highNote ; private double lowDuration ; private double highDuration ; private double totalDuration ; private int lastNote ; private int lowInterval ; private int highInterval ; private int totalInterval ; private int totalNoteChanges ; private int currentKey ; private int keyChanges ; private int beatsPerMeasure ; private int timeChanges ; private int tempo ; private int tempoChanges ; private HashMap < Integer , Integer > tempoByMeasure ; private Dynamic dynamics ; private int dynamicChanges ; private Articulation oldArticulations ; private Articulation articulations ; private int articulationChanges ; private double currentScore ; private List < ComplexityScore > allScores ; private DifficultyReaderVisitor diffs ; private boolean tied ; private double tieDuration ; private int worstMeasureNumber ; private double worstMeasureValue ; private double currentMeasureValue ; private double noteTotal ; private double intervalTotal ; private HashMap < String , String > partIdsToNames ; public NoteComplexityVisitor ( File xmlFile , DifficultyLevel difficulty ) { } public void initializeValues ( ) { } public NodeList setupXmlFile ( File xmlFile ) { } private void start ( NodeList list ) { } @ Override public void visit ( Score score ) { } @ Override public void visit ( PartList partList ) { } @ Override public void visit ( ScorePart scorePart ) { } @ Override public void visit ( PartName partName ) { } @ Override public void visit ( Part part ) { } @ Override public void visit ( Measure measure ) { Node elem = measure . getBase ( ) ; if ( elem == null ) { if ( Main . LOGGING ) { System . out . println ( "ERROR:<seq2seq4repair_space>A<seq2seq4repair_space>node<seq2seq4repair_space>turned<seq2seq4repair_space>up<seq2seq4repair_space>null<seq2seq4repair_space>for<seq2seq4repair_space>some<seq2seq4repair_space>reason.<seq2seq4repair_space>Stopping." ) ; } measures = null ; return ; } if ( ! ( elem . getNodeName ( ) . trim ( ) . equalsIgnoreCase ( MEASURE_NODE ) ) ) { ( realMeasures ) -- ; ( currentMeasure ) ++ ; return ; } double oldScore = currentScore ; NodeList list = elem . getChildNodes ( ) ; for ( int i = 0 ; i < ( list . getLength ( ) ) ; i ++ ) { elem = list . item ( i ) ; String name = elem . getNodeName ( ) . trim ( ) ; if ( name . equalsIgnoreCase ( SOUND_NODE ) ) { Sound sound = new Sound ( elem ) ; sound . accept ( this ) ; } else if ( name . equalsIgnoreCase ( DIRECTION_TYPE_NODE ) ) { DirectionType directionType = new DirectionType ( elem ) ; directionType . accept ( this ) ; } else if ( name . equalsIgnoreCase ( ATTRIBUTES_NODE ) ) { new Attribute ( elem ) . accept ( this ) ; } else if ( name . equalsIgnoreCase ( DIRECTION_NODE ) ) { new Direction ( elem ) . accept ( this ) ; } else if ( name . equalsIgnoreCase ( NOTE_NODE ) ) { ( noteCount ) ++ ; new Note ( elem ) . accept ( this ) ; } } currentMeasureValue = ( currentScore ) - oldScore ; if ( ( currentMeasureValue ) > ( worstMeasureValue ) ) { worstMeasureValue = currentMeasureValue ; <START_BUG> worstMeasureNumber = ( currentMeasure ) + 1 ; <END_BUG> } ( currentMeasure ) ++ ; } @ Override public void visit ( Note note ) { } @ Override public void visit ( Attribute attribute ) { } @ Override public void visit ( Direction direction ) { } @ Override public void visit ( DirectionType directionType ) { } @ Override public void visit ( DynamicsNode dynamics ) { } @ Override public void visit ( Key key ) { } @ Override public void visit ( Fifths fifths ) { } @ Override public void visit ( Time time ) { } @ Override public void visit ( BeatType beatType ) { } @ Override public void visit ( Sound sound ) { } @ Override public void visit ( Tempo tempo ) { } @ Override public void visit ( Pitch pitch ) { } @ Override public void visit ( Rest rest ) { } @ Override public void visit ( Notations notations ) { } private void updateArticulations ( ) { } private void updateNoteTracking ( int noteNum ) { } public List < ComplexityScore > getAllScores ( ) { } private int getCurrentTempo ( int measureNumber ) { } public void statusReport ( ) { } No newline ; at end ; of file ; }

Fix:
worstMeasureNumber = ( ( currentMeasure ) - ( ( measureCount ) - ( realMeasures ) ) ) + 1 ;