Program: 127304
Project: 127304
Buggy source:
public static List<MetadataColumn> guessSchemaFromArray(final CsvArray csvArray,boolean isFirstLineCaption,MetadataEmfTableEditorView tableEditorView,int header){
  List<MetadataColumn> columns=new ArrayList<MetadataColumn>();
  if (csvArray == null) {
    return columns;
  }
 else {
    List<String[]> csvRows=csvArray.getRows();
    if (csvRows.isEmpty()) {
      return columns;
    }
    String[] fields=csvRows.get(0);
    Integer numberOfCol=getRightFirstRow(csvRows);
    int firstRowToExtractMetadata=header;
    String[] label=new String[numberOfCol.intValue()];
    for (int i=0; i < numberOfCol; i++) {
      label[i]=DEFAULT_LABEL + i;
      if (isFirstLineCaption) {
        if (numberOfCol <= fields.length) {
          if (fields[i] != null && !("String_Node_Str").equals(fields[i])) {
            label[i]=fields[i].trim().replaceAll("String_Node_Str","String_Node_Str");
            label[i]=MetadataToolHelper.validateColumnName(label[i],i);
          }
 else {
            label[i]=DEFAULT_LABEL + i;
          }
        }
 else {
          if (i < fields.length) {
            if (fields[i] != null && !("String_Node_Str").equals(fields[i])) {
              label[i]=fields[i].trim().replaceAll("String_Node_Str","String_Node_Str");
            }
 else {
              label[i]=DEFAULT_LABEL + "String_Node_Str" + i;
            }
          }
 else {
            label[i]=DEFAULT_LABEL + "String_Node_Str" + i;
          }
        }
      }
    }
    ShadowProcessPreview.fixDuplicateNames(label);
    for (int i=0; i < numberOfCol.intValue(); i++) {
      String globalType=null;
      int lengthValue=0;
      int precisionValue=0;
      int current=firstRowToExtractMetadata;
      while (globalType == null) {
        if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
          if (current == csvRows.size()) {
            globalType="String_Node_Str";
            continue;
          }
 else           if (i >= csvRows.get(current).length) {
            globalType="String_Node_Str";
          }
 else {
            globalType=JavaDataTypeHelper.getTalendTypeOfValue(csvRows.get(current)[i]);
            current++;
          }
        }
 else {
          if (current == csvRows.size()) {
            globalType="String_Node_Str";
            continue;
          }
          if (i >= csvRows.get(current).length) {
            globalType="String_Node_Str";
          }
 else {
            globalType=PerlDataTypeHelper.getTalendTypeOfValue(csvRows.get(current)[i]);
            current++;
          }
        }
      }
      for (int f=firstRowToExtractMetadata; f < csvRows.size(); f++) {
        fields=csvRows.get(f);
        if (fields.length > i) {
          String value=fields[i];
          if (!value.equals("String_Node_Str")) {
            if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
              if (!JavaDataTypeHelper.getTalendTypeOfValue(value).equals(globalType)) {
                globalType=JavaDataTypeHelper.getCommonType(globalType,JavaDataTypeHelper.getTalendTypeOfValue(value));
              }
            }
 else {
              if (!PerlDataTypeHelper.getTalendTypeOfValue(value).equals(globalType)) {
                globalType=PerlDataTypeHelper.getCommonType(globalType,PerlDataTypeHelper.getTalendTypeOfValue(value));
              }
            }
            if (lengthValue < value.length()) {
              lengthValue=value.length();
            }
            int positionDecimal=0;
            if (value.indexOf(',') > -1) {
              positionDecimal=value.lastIndexOf(',');
              precisionValue=lengthValue - positionDecimal;
            }
 else             if (value.indexOf('.') > -1) {
              positionDecimal=value.lastIndexOf('.');
              precisionValue=lengthValue - positionDecimal;
            }
          }
 else {
            ICoreService coreService=CoreRuntimePlugin.getInstance().getCoreService();
            IPreferenceStore preferenceStore=coreService.getPreferenceStore();
            if (preferenceStore != null) {
              if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                if (preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE) != null && !preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE).equals("String_Node_Str")) {
                  globalType=preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE);
                  if (preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH) != null && !preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH).equals("String_Node_Str")) {
                    lengthValue=Integer.parseInt(preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH));
                  }
                }
              }
 else {
                if (preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_TYPE) != null && !preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_TYPE).equals("String_Node_Str")) {
                  globalType=preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_TYPE);
                  if (preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_LENGTH) != null && !preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_LENGTH).equals("String_Node_Str")) {
                    lengthValue=Integer.parseInt(preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_LENGTH));
                  }
                }
              }
            }
          }
        }
      }
      if (csvRows.size() <= 1 && firstRowToExtractMetadata == 1) {
        lengthValue=255;
      }
      MetadataColumn metadataColumn=ConnectionFactory.eINSTANCE.createMetadataColumn();
      metadataColumn.setPattern("String_Node_Str");
      String talendType=null;
      if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
        talendType=globalType;
        if (globalType.equals(JavaTypesManager.FLOAT.getId()) || globalType.equals(JavaTypesManager.DOUBLE.getId())) {
          metadataColumn.setPrecision(precisionValue);
        }
 else {
          metadataColumn.setPrecision(0);
        }
      }
 else {
        talendType=PerlTypesManager.getNewTypeName(MetadataTalendType.loadTalendType(globalType,"String_Node_Str",false));
        if (globalType.equals("String_Node_Str") || globalType.equals("String_Node_Str")) {
          metadataColumn.setPrecision(precisionValue);
        }
 else {
          metadataColumn.setPrecision(0);
        }
      }
      metadataColumn.setTalendType(talendType);
      metadataColumn.setLength(lengthValue);
      metadataColumn.setLabel(tableEditorView.getMetadataEditor().getNextGeneratedColumnName(label[i]));
      columns.add(i,metadataColumn);
    }
  }
  return columns;
}

Fixed version (ground truth):
public static List<MetadataColumn> guessSchemaFromArray(final CsvArray csvArray,boolean isFirstLineCaption,MetadataEmfTableEditorView tableEditorView,int header){
  List<MetadataColumn> columns=new ArrayList<MetadataColumn>();
  if (csvArray == null) {
    return columns;
  }
 else {
    List<String[]> csvRows=csvArray.getRows();
    if (csvRows.isEmpty()) {
      return columns;
    }
    String[] fields=csvRows.get(0);
    Integer numberOfCol=getRightFirstRow(csvRows);
    int firstRowToExtractMetadata=header;
    String[] label=new String[numberOfCol.intValue()];
    for (int i=0; i < numberOfCol; i++) {
      label[i]=DEFAULT_LABEL + i;
      if (isFirstLineCaption) {
        if (numberOfCol <= fields.length) {
          if (fields[i] != null && !("String_Node_Str").equals(fields[i])) {
            label[i]=fields[i].trim().replaceAll("String_Node_Str","String_Node_Str");
            label[i]=MetadataToolHelper.validateColumnName(label[i],i);
          }
 else {
            label[i]=DEFAULT_LABEL + i;
          }
        }
 else {
          if (i < fields.length) {
            if (fields[i] != null && !("String_Node_Str").equals(fields[i])) {
              label[i]=fields[i].trim().replaceAll("String_Node_Str","String_Node_Str");
            }
 else {
              label[i]=DEFAULT_LABEL + "String_Node_Str" + i;
            }
          }
 else {
            label[i]=DEFAULT_LABEL + "String_Node_Str" + i;
          }
        }
      }
    }
    ShadowProcessPreview.fixDuplicateNames(label);
    for (int i=0; i < numberOfCol.intValue(); i++) {
      String globalType=null;
      int lengthValue=0;
      int precisionValue=0;
      int current=firstRowToExtractMetadata;
      while (globalType == null) {
        if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
          if (current == csvRows.size()) {
            globalType="String_Node_Str";
            continue;
          }
 else           if (i >= csvRows.get(current).length) {
            globalType="String_Node_Str";
          }
 else {
            globalType=JavaDataTypeHelper.getTalendTypeOfValue(csvRows.get(current)[i]);
            current++;
          }
        }
 else {
          if (current == csvRows.size()) {
            globalType="String_Node_Str";
            continue;
          }
          if (i >= csvRows.get(current).length) {
            globalType="String_Node_Str";
          }
 else {
            globalType=PerlDataTypeHelper.getTalendTypeOfValue(csvRows.get(current)[i]);
            current++;
          }
        }
      }
      for (int f=firstRowToExtractMetadata; f < csvRows.size(); f++) {
        fields=csvRows.get(f);
        if (fields.length > i) {
          String value=fields[i];
          if (!value.equals("String_Node_Str")) {
            if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
              if (!JavaDataTypeHelper.getTalendTypeOfValue(value).equals(globalType)) {
                globalType=JavaDataTypeHelper.getCommonType(globalType,JavaDataTypeHelper.getTalendTypeOfValue(value));
              }
            }
 else {
              if (!PerlDataTypeHelper.getTalendTypeOfValue(value).equals(globalType)) {
                globalType=PerlDataTypeHelper.getCommonType(globalType,PerlDataTypeHelper.getTalendTypeOfValue(value));
              }
            }
            if (lengthValue < value.length()) {
              lengthValue=value.length();
            }
            int positionDecimal=0;
            if (value.indexOf(',') > -1) {
              positionDecimal=value.lastIndexOf(',');
              precisionValue=lengthValue - positionDecimal;
            }
 else             if (value.indexOf('.') > -1) {
              positionDecimal=value.lastIndexOf('.');
              precisionValue=lengthValue - positionDecimal;
            }
          }
 else {
            ICoreService coreService=CoreRuntimePlugin.getInstance().getCoreService();
            IPreferenceStore preferenceStore=coreService.getPreferenceStore();
            if (preferenceStore != null) {
              if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                if (preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE) != null && !preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE).equals("String_Node_Str")) {
                  globalType=preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE);
                  if (preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH) != null && !preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH).equals("String_Node_Str")) {
                    lengthValue=Integer.parseInt(preferenceStore.getString(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH));
                  }
                }
              }
 else {
                if (preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_TYPE) != null && !preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_TYPE).equals("String_Node_Str")) {
                  globalType=preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_TYPE);
                  if (preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_LENGTH) != null && !preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_LENGTH).equals("String_Node_Str")) {
                    lengthValue=Integer.parseInt(preferenceStore.getString(MetadataTypeLengthConstants.PERL_VALUE_DEFAULT_LENGTH));
                  }
                }
              }
            }
          }
        }
      }
      if (csvRows.size() <= 1 && firstRowToExtractMetadata == 1) {
        lengthValue=255;
      }
      MetadataColumn metadataColumn=ColumnHelper.createTdColumn(tableEditorView.getMetadataEditor().getNextGeneratedColumnName(label[i]));
      metadataColumn.setPattern("String_Node_Str");
      String talendType=null;
      if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
        talendType=globalType;
        if (globalType.equals(JavaTypesManager.FLOAT.getId()) || globalType.equals(JavaTypesManager.DOUBLE.getId())) {
          metadataColumn.setPrecision(precisionValue);
        }
 else {
          metadataColumn.setPrecision(0);
        }
      }
 else {
        talendType=PerlTypesManager.getNewTypeName(MetadataTalendType.loadTalendType(globalType,"String_Node_Str",false));
        if (globalType.equals("String_Node_Str") || globalType.equals("String_Node_Str")) {
          metadataColumn.setPrecision(precisionValue);
        }
 else {
          metadataColumn.setPrecision(0);
        }
      }
      metadataColumn.setTalendType(talendType);
      metadataColumn.setLength(lengthValue);
      columns.add(i,metadataColumn);
    }
  }
  return columns;
}