Program: 72340
Project: 72340
Buggy source:
/** 
 * Write a report containing(in a .csv file   {@link #_csvFile}), among other informations, the number of ticks, the delay between a NER or a TAR and its respective TAG, the number of UAVs and RAVs.
 */
public void writeDelays(){
  String fullName=federateName.toString();
  String nameOfTheFile=fullName.substring(fullName.indexOf('{') + 1,fullName.lastIndexOf('.'));
  nameOfTheFile=nameOfTheFile.substring(1,nameOfTheFile.lastIndexOf('.')) + "String_Node_Str";
  String nameOfTheFederate=fullName.substring(fullName.indexOf('"'));
  String info="String_Node_Str" + nameOfTheFederate + "String_Node_Str"+ nameOfTheFile+ "String_Node_Str"+ _hlaTimeUnitValue+ "String_Node_Str"+ _hlaLookAHead+ "String_Node_Str"+ _runtime+ "String_Node_Str";
  if (_timeStepped) {
    info=info + "String_Node_Str" + _hlaTimeStep+ "String_Node_Str"+ _numberOfTARs+ "String_Node_Str";
  }
 else   if (_eventBased) {
    info=info + "String_Node_Str" + _numberOfNERs+ "String_Node_Str";
  }
  info=info + "String_Node_Str" + _numberOfUAVs+ "String_Node_Str"+ _numberOfRAVs+ "String_Node_Str"+ _numberOfTAGs;
  String numberOfTicks="String_Node_Str";
  String delay="String_Node_Str";
  double averageNumberOfTicks=0;
  double averageDelay=0;
  StringBuffer header=new StringBuffer("String_Node_Str");
  String delayPerTick="String_Node_Str";
  for (int i=0; i < _numberOfTAGs; i++) {
    if (i < 10) {
      header.append((i + 1) + "String_Node_Str");
      numberOfTicks=numberOfTicks + _numberOfTicks.get(i) + "String_Node_Str";
      delay=delay + _TAGDelay.get(i) + "String_Node_Str";
      if (_numberOfTicks.get(i) > 0) {
        delayPerTick=delayPerTick + (_TAGDelay.get(i) / _numberOfTicks.get(i)) + "String_Node_Str";
      }
 else {
        delayPerTick=delayPerTick + "String_Node_Str";
      }
    }
    averageNumberOfTicks=averageNumberOfTicks + _numberOfTicks.get(i);
    averageDelay=averageDelay + _TAGDelay.get(i);
  }
  header.append("String_Node_Str");
  int totalNumberOfHLACalls=_numberOfOtherTicks + (int)averageNumberOfTicks + _numberOfTARs+ _numberOfNERs+ _numberOfRAVs+ _numberOfUAVs+ _numberOfTAGs;
  numberOfTicks=numberOfTicks + averageNumberOfTicks + "String_Node_Str";
  delay=delay + averageDelay + "String_Node_Str";
  delayPerTick=delayPerTick + "String_Node_Str";
  header.append("String_Node_Str");
  if (_timeStepped) {
    _reportFile=_createTextFile(nameOfTheFederate.substring(1,nameOfTheFederate.length() - 1) + "String_Node_Str" + "String_Node_Str","String_Node_Str");
    writeInTextFile(_reportFile,_date + "String_Node_Str" + _hlaTimeStep+ "String_Node_Str"+ _hlaLookAHead+ "String_Node_Str"+ _runtime+ "String_Node_Str"+ totalNumberOfHLACalls+ "String_Node_Str"+ _numberOfTARs+ "String_Node_Str"+ _numberOfTAGs+ "String_Node_Str"+ _numberOfRAVs+ "String_Node_Str"+ _numberOfUAVs+ "String_Node_Str"+ _numberOfTicks2+ "String_Node_Str"+ averageDelay);
  }
 else {
    _reportFile=_createTextFile(nameOfTheFederate.substring(1,nameOfTheFederate.length() - 1) + "String_Node_Str" + "String_Node_Str","String_Node_Str");
    writeInTextFile(_reportFile,_date + "String_Node_Str" + _hlaLookAHead+ "String_Node_Str"+ _runtime+ "String_Node_Str"+ totalNumberOfHLACalls+ "String_Node_Str"+ _numberOfNERs+ "String_Node_Str"+ _numberOfTAGs+ "String_Node_Str"+ _numberOfRAVs+ "String_Node_Str"+ _numberOfUAVs+ "String_Node_Str"+ _numberOfTicks2+ "String_Node_Str"+ averageDelay);
  }
  averageNumberOfTicks=averageNumberOfTicks / _numberOfTAGs;
  averageDelay=averageDelay / _numberOfTAGs;
  delayPerTick=delayPerTick + (averageDelay / averageNumberOfTicks) + "String_Node_Str";
  numberOfTicks=numberOfTicks + averageNumberOfTicks + "String_Node_Str";
  delay=delay + averageDelay + "String_Node_Str";
  writeInTextFile(_csvFile,info + header + delay+ numberOfTicks+ delayPerTick+ "String_Node_Str"+ _numberOfOtherTicks+ "String_Node_Str"+ totalNumberOfHLACalls);
}

Fixed version (ground truth):
/** 
 * Write a report containing(in a .csv file   {@link #_csvFile}), among other informations, the number of ticks, the delay between a NER or a TAR and its respective TAG, the number of UAVs and RAVs.
 */
public void writeDelays(){
  String fullName=federateName.toString();
  String nameOfTheFile=fullName.substring(fullName.indexOf('{') + 1,fullName.lastIndexOf('.'));
  nameOfTheFile=nameOfTheFile.substring(1,nameOfTheFile.lastIndexOf('.')) + "String_Node_Str";
  String nameOfTheFederate=fullName.substring(fullName.indexOf('"'));
  String info="String_Node_Str" + nameOfTheFederate + "String_Node_Str"+ nameOfTheFile+ "String_Node_Str"+ _hlaTimeUnitValue+ "String_Node_Str"+ _hlaLookAHead+ "String_Node_Str"+ _runtime+ "String_Node_Str";
  if (_timeStepped) {
    info=info + "String_Node_Str" + _hlaTimeStep+ "String_Node_Str"+ _numberOfTARs+ "String_Node_Str";
  }
 else   if (_eventBased) {
    info=info + "String_Node_Str" + _numberOfNERs+ "String_Node_Str";
  }
  info=info + "String_Node_Str" + _numberOfUAVs+ "String_Node_Str"+ _numberOfRAVs+ "String_Node_Str"+ _numberOfTAGs;
  String numberOfTicks="String_Node_Str";
  String delay="String_Node_Str";
  double averageNumberOfTicks=0;
  double averageDelay=0;
  StringBuffer header=new StringBuffer("String_Node_Str");
  StringBuffer bufferDelayPerTick=new StringBuffer();
  bufferDelayPerTick.append("String_Node_Str");
  for (int i=0; i < _numberOfTAGs; i++) {
    if (i < 10) {
      header.append((i + 1) + "String_Node_Str");
      numberOfTicks=numberOfTicks + _numberOfTicks.get(i) + "String_Node_Str";
      delay=delay + _TAGDelay.get(i) + "String_Node_Str";
      if (_numberOfTicks.get(i) > 0) {
        bufferDelayPerTick.append((_TAGDelay.get(i) / _numberOfTicks.get(i)) + "String_Node_Str");
      }
 else {
        bufferDelayPerTick.append("String_Node_Str");
      }
    }
    averageNumberOfTicks=averageNumberOfTicks + _numberOfTicks.get(i);
    averageDelay=averageDelay + _TAGDelay.get(i);
  }
  header.append("String_Node_Str");
  int totalNumberOfHLACalls=_numberOfOtherTicks + (int)averageNumberOfTicks + _numberOfTARs+ _numberOfNERs+ _numberOfRAVs+ _numberOfUAVs+ _numberOfTAGs;
  numberOfTicks=numberOfTicks + averageNumberOfTicks + "String_Node_Str";
  delay=delay + averageDelay + "String_Node_Str";
  bufferDelayPerTick.append("String_Node_Str");
  header.append("String_Node_Str");
  if (_timeStepped) {
    _reportFile=_createTextFile(nameOfTheFederate.substring(1,nameOfTheFederate.length() - 1) + "String_Node_Str" + "String_Node_Str","String_Node_Str");
    writeInTextFile(_reportFile,_date + "String_Node_Str" + _hlaTimeStep+ "String_Node_Str"+ _hlaLookAHead+ "String_Node_Str"+ _runtime+ "String_Node_Str"+ totalNumberOfHLACalls+ "String_Node_Str"+ _numberOfTARs+ "String_Node_Str"+ _numberOfTAGs+ "String_Node_Str"+ _numberOfRAVs+ "String_Node_Str"+ _numberOfUAVs+ "String_Node_Str"+ _numberOfTicks2+ "String_Node_Str"+ averageDelay);
  }
 else {
    _reportFile=_createTextFile(nameOfTheFederate.substring(1,nameOfTheFederate.length() - 1) + "String_Node_Str" + "String_Node_Str","String_Node_Str");
    writeInTextFile(_reportFile,_date + "String_Node_Str" + _hlaLookAHead+ "String_Node_Str"+ _runtime+ "String_Node_Str"+ totalNumberOfHLACalls+ "String_Node_Str"+ _numberOfNERs+ "String_Node_Str"+ _numberOfTAGs+ "String_Node_Str"+ _numberOfRAVs+ "String_Node_Str"+ _numberOfUAVs+ "String_Node_Str"+ _numberOfTicks2+ "String_Node_Str"+ averageDelay);
  }
  averageNumberOfTicks=averageNumberOfTicks / _numberOfTAGs;
  averageDelay=averageDelay / _numberOfTAGs;
  bufferDelayPerTick.append((averageDelay / averageNumberOfTicks) + "String_Node_Str");
  String delayPerTick=bufferDelayPerTick.toString();
  numberOfTicks=numberOfTicks + averageNumberOfTicks + "String_Node_Str";
  delay=delay + averageDelay + "String_Node_Str";
  writeInTextFile(_csvFile,info + header + delay+ numberOfTicks+ delayPerTick+ "String_Node_Str"+ _numberOfOtherTicks+ "String_Node_Str"+ totalNumberOfHLACalls);
}