[Demonstration 1]

[Buggy Method]
public HashMap<Integer, ArrayList<String>> parseEachUsefulClusteringResult(int clusterSizeThreshold, boolean hasGroundTruth, String combination, boolean isOriginalGraph) {
    clusterResultMap = new HashMap<>();
    String clusterFilePath = analysisDir + combination + suffix_ClusterFile;
    String clusterResultListString = "";
    ProcessingText processingText = new ProcessingText();
    //        processingText.rewriteFile("", analysisDir + combination + "_edgeCuttingRecord.txt");
    //        processingText.rewriteFile("", analysisDir + combination + "_LOC_split.txt");
    if (hasGroundTruth) {
        //            processingText.rewriteFile("", analysisDir + combination + "_accuracy.txt");
        //            processingText.rewriteFile("", analysisDir + combination + "_joined_accuracy.txt");
    }
    /**
     * get fork added node *
     */
    File forkAddedFile = new File(testCaseDir + forkAddedNodeTxt);
    if (forkAddedFile.exists()) {
        try {
            forkAddedNode = processingText.readResult(testCaseDir + forkAddedNodeTxt);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    try {
        /**
         * add tags for each line of source code in order to generate html page later, and it also generates toggle.js file  *
         */
        //            colorCode.createSourceFileHtml();
        clusterResultListString = processingText.readResult(clusterFilePath);
    } catch (IOException e) {
        e.printStackTrace();
    }
    int pre_numberOfCommunites = 0;
    int previous_cutted_edge_num = 0;
    String weight_List = "";
    /**
     * split edge cutting result  *
     */
    String[] resultArray = clusterResultListString.split("--------Graph-------");
    for (int i = 0; i < resultArray.length; i++) {
        /**
         *  one edge cutting result *
         */
        String result = resultArray[i];
        if (result.contains("communities")) {
            /**
             *     calculating cluster info, such as modularity, #edge cut ..  *
             */
            double[] clusterInfo = getClusterInfo(result.split("communities")[0], isOriginalGraph);
            int numberOfCommunities = (int) clusterInfo[0];
            if (numberOfCommunities > 1) {
                int weight = (int) clusterInfo[3];
                if (pre_numberOfCommunites != numberOfCommunities) {
                    ArrayList<String> clusters = getClusters(result);
                    clusterResultMap.put(numberOfCommunities, clusters);
                    /**
                     * generates current clustering result map
                     * #index  -> hashset of nodeid  *
                     */
                    //todo  isjoined = false as hard coded
                    //                        HashMap<String, HashSet<Integer>> current_clustering_result = generateCurrentClusteringResultMap(clusters, "original",true);
                    HashMap<String, HashSet<Integer>> current_clustering_result = generateCurrentClusteringResultMap(clusters, "original", true, false);
                    /**
                     * generateing toggle.js file for each cluster *
                     */
                    //                        generateToggleFileForEachCluster(current_clustering_result, false, numberOfCommunities);
                    /**
                     * calculating accuracy for clustering result
                     * 0 - true_positive,1 - false_positive, 2 - true_negtive, 3 - false_negtive, 4- accuracy
                     * *
                     */
                    //                        if (hasGroundTruth) {
                    //                            calculatingAccuracy(groundTruthClusters, current_clustering_result, false, combination);
                    //                        }
                    if (!isMS_CLUSTERCHANGES) {
                        //                            HashMap<String, HashSet<Integer>> joined_clusters = null;
                        //                            if (isOriginalGraph) {
                        /**
                         *  get list of clusterSet, each list represent a set of clusters that close to each other *
                         */
                        ArrayList<HashSet<String>> closeClusters_list;
                        if (combination.equals("original")) {
                            closeClusters_list = colorCode.joiningCloseClusters(clusters, combination, clusterSizeThreshold);
                            /**
                             *   get joined clusters   *
                             */
                            joined_clusters = getJoinedClusters(colorCode, combination, clusters, current_clustering_result, clusterSizeThreshold, closeClusters_list);
                        } else {
                            joined_clusters = getJoinedClustersForSplittingStep(combination);
                        }
                        //                                /** generateing toggle.js file for each cluster **/
                        //                                generateToggleFileForEachCluster(joined_clusters, true, numberOfCommunities);
                        if (combination.split("--").length > 5 || combination.equals("original")) {
                            processingText.writeToJoinClusterFile(analysisDir, joined_clusters, combination);
                        }
                        if (hasGroundTruth) {
                            /**
                             * calculate accuracy result for joined clusters *
                             */
                            calculatingAccuracy(groundTruthClusters, joined_clusters, true, combination);
                        }
                        //                            }
                        if (isOriginalGraph) {
                            /**
                             *   write to css file        *
                             */
                            colorCode.writeClusterToCSS(clusters, numberOfCommunities, clusterResultMap, nodeMap, expectNodeMap, clusterSizeThreshold, hasGroundTruth, combination);
                        }
                        /**
                         * remove 3  generatingClusteringTable    step for new infox
                         * generating clustering table  *
                         */
                        //
                        ////                            generatingClusteringTable(testCaseDir, testDir, String.valueOf(numberOfCommunities), false, clusterSizeThreshold, current_clustering_result, hasGroundTruth);
                        //                            generatingClusteringTable(testCaseDir, testDir, combination, false, clusterSizeThreshold, current_clustering_result, hasGroundTruth, isOriginalGraph);
                        ////                            generatingClusteringTable(testCaseDir, testDir, numberOfCommunities, true, clusterSizeThreshold, current_clustering_result, hasGroundTruth);
                        //
                        //                            if (isOriginalGraph) {
                        //                                /** generating join clustering table  **/
                        //                                generatingClusteringTable(testCaseDir, testDir, combination, true, clusterSizeThreshold, joined_clusters, hasGroundTruth, isOriginalGraph);
                        //                            }
                    }
                    if (isMS_CLUSTERCHANGES && isOriginalGraph) {
                        /**
                         *   write to css file        *
                         */
                        colorCode.writeClusterToCSS(clusters, numberOfCommunities, clusterResultMap, nodeMap, expectNodeMap, clusterSizeThreshold, hasGroundTruth, combination);
                    }
                    /**
                     * generating clustering table for MS approach *
                     */
                    //                        generatingClusteringTable(testCaseDir, testDir, combination, false, 0, current_clustering_result, hasGroundTruth, isOriginalGraph);
                    /**
                     *  combining multifles in order to generate html files *
                     */
                    // remove
                    //                        colorCode.combineFiles(combination, clusterSizeThreshold, false);
                    //                        if (isOriginalGraph) {
                    //                            colorCode.combineFiles(combination, clusterSizeThreshold, true);
                    //                        }
                    pre_numberOfCommunites = numberOfCommunities;
                    int numberOfCutEdges = (int) clusterInfo[1] - 1;
                    double modularity = clusterInfo[2];
                    double betweenness = clusterInfo[4];
                    //                        processingText.writeTofile(numberOfCommunities + "," + (numberOfCutEdges - previous_cutted_edge_num) + "," + modularity + "," + weight_List + "," + betweenness + "\n", analysisDir + combination + "_edgeCuttingRecord.txt");
                    weight_List = weight + "->";
                    previous_cutted_edge_num = numberOfCutEdges;
                } else {
                    weight_List += weight + "->";
                }
            }
        }
    }
    /**
     * generating cutting summary table *
     */
    //        generateCuttingSummaryTable(clusterSizeThreshold, hasGroundTruth, combination);
    return clusterResultMap;
}

[Buggy Hunk]
joined_clusters = getJoinedClustersForSplittingStep(combination);

[Patch]
joined_clusters = getJoinedClustersForSplittingStep(combination, clusterSizeThreshold);

[Demonstration 2]

[Buggy Method]
public Map<String, Integer> readAll() {
    LOG.info("Loading file " + file.getAbsolutePath());
    Map<String, Integer> nGramMap = new TreeMap<>();
    try (CSVReader reader = new CSVReader(new FileReader(file), '\t')) {
        String[] record;
        while ((record = reader.readNext()) != null) {
            if (record.length != 2) {
                LOG.debug(String.format("Unexpected record length (%s) at line %s.", record.length, reader.getLinesRead()));
                continue;
            }
            int count = Integer.parseInt(record[0].trim());
            String ngram = record[1].trim();
            nGramMap.put(ngram, count);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return nGramMap;
}

[Buggy Hunk]
try (CSVReader reader = new CSVReader(new FileReader(file), '\t');) {

[Patch]
try (CSVReader reader = new CSVReader(new FileReader(file), '\t', '\0');) {

[Demonstration 3]

[Buggy Method]
@Nonnull
protected Iterable<ClassDef> getDirectInterfaces() {
    Iterable<ClassDef> directInterfaces = FluentIterable.from(getInterfaces().values()).filter(Predicates.notNull());
    if (!interfacesFullyResolved) {
        throw new UnresolvedClassException("Interfaces for class %s not fully resolved: %s", getType(), String.join(",", getUnresolvedInterfaces()));
    }
    return directInterfaces;
}

[Buggy Hunk]
String.join(",", getUnresolvedInterfaces()));

[Patch]
Joiner.on(',').join(getUnresolvedInterfaces()));