[Demonstration 1]

[Buggy Method]
public boolean canMove(GameState g, int x, int y) {
    int dx = x - getX();
    int dy = y - getY();
    System.out.println("Attempting to check legality of move...");
    if (x < 1 || x > 8 || y < 1 || y > 8) {
        System.out.println("Cannot move outside the chessboard!");
        return false;
    }
    if (Math.abs(dy) > 2 || Math.abs(dx) > 1) {
        //Pawns can never move more than 2 squres forward and one square sideways
        System.out.println("Cannot move more than two square forward or one sideways!");
        return false;
    }
    if (this.getColor() == 0) {
        //White
        if (dy < 1) {
            //Cannot move backwards
            System.out.println("Cannot move backwards! Piece is white.");
            return false;
        }
    } else {
        //Black
        if (dy > -1) {
            //Cannot move backwards
            System.out.println("Cannot move backwards! Piece is black.");
            return false;
        }
    }
    if (Math.abs(dx) == 1 && Math.abs(dy) == 1) {
        //Capturing
        System.out.println("Attempting to capture");
        //Check if there is not a piece of the same color at the target square
        Piece target = g.getPieceAt(x, y);
        if (target == null) {
            //Target Square is empty
            return false;
        } else {
            //There is a piece at the target square
            if (target.getColor() == this.getColor()) {
                //The piece at the target is the same colour as this piece. Illegal move
                return false;
            }
        }
    } else if (Math.abs(dy) == 2) {
        //Moving forward by 2 squares
        //System.out.println("Attempting to move forward by 2 squares");
        if (this.getColor() == 0) {
            //White
            if (getY() != 2) {
                //Cannot move by two squares unless its the first move by the pawn
                System.out.println("Cannot move by two squares now!");
                return false;
            }
        } else {
            //Black
            if (getX() != 7) {
                //Cannot move by two squares unless its the first move by the pawn
                System.out.println("Cannot move by two squares now!");
                return false;
            }
        }
        Piece target = g.getPieceAt(x, y);
        Piece between = g.getPieceAt(x, (int) (0.5 * (y + getY())));
        if (target != null || between != null) {
            //There is a piece at the target square or in the way.
            System.err.println("Error while moving " + this.toString() + ". A piece (" + target.toString() + between.toString() + ") is in the way.");
            return false;
        }
    } else if (Math.abs(dy) == 1) {
        System.out.println("Attempting to move forward by 1 square");
        Piece target = g.getPieceAt(x, y);
        if (target == null) {
            //There is a piece at the target square
            System.err.println("Error while moving " + this.toString() + ". A piece (" + g.getPieceAt(x, y).toString() + ") is in the way.");
            return false;
        }
    } else {
        System.out.println("Invalid move! dx: " + dx + " dy: " + dy);
    }
    return true;
}

[Buggy Hunk]
if (target == null) {

[Patch]
if (target != null) {

[Demonstration 2]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));

[Demonstration 3]

[Buggy Method]
private void displayView(int position) {
    switch(position) {
        case 0:
            if (isUserLoggedIn()) {
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Home Fragment..... ");
                //display Category Fragment
                FragmentRouter fragmentRouter = new FragmentRouter().newInstance(true);
                updateFragment(fragmentRouter, position);
                setFragmentTitle(position);
            }
            break;
        case 1:
            if (isUserLoggedIn()) {
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Closet Fragment..... ");
                //display Category Fragment
                ClosetFragment closetFragment = new ClosetFragment().newInstance(tokenId);
                updateFragment(closetFragment, position);
                setFragmentTitle(position);
            }
            break;
        case 2:
            if (isUserLoggedIn()) {
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Search Fragment..... ");
                //display Search Fragment
                SearchTabFragment searchTabFragment = new SearchTabFragment();
                updateFragment(searchTabFragment, position);
                setFragmentTitle(position);
            }
            break;
        case 3:
            if (isUserLoggedIn()) {
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": New Tag Fragment..... ");
                //display New Tag Fragment
                NewTagFragment newTagFragment = new NewTagFragment();
                updateFragment(newTagFragment, position);
                setFragmentTitle(position);
            }
            break;
        case 4:
            if (isUserLoggedIn()) {
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Profile Fragment..... ");
                //display Profile Fragment
                ProfileFragment profileFragmenet = new ProfileFragment();
                updateFragment(profileFragmenet, position);
                setFragmentTitle(position);
            }
            break;
        case 5:
            if (isUserLoggedIn()) {
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Match Fragment..... ");
                //display Match Fragment
                MatchFragment matchFragment = MatchFragment.newInstance(null, false);
                updateFragment(matchFragment, position);
                setFragmentTitle(position);
            }
            break;
        case 6:
            Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Log out..... ");
            if (mGoogleApiClient.isConnected()) {
                //start the progress dialog
                progressDialog = ProgressDialog.show(MainActivity.this, "", "Logging out...");
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            //log out currently logged user
                            Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
                            mGoogleApiClient.disconnect();
                            Thread.sleep(2000);
                        } catch (Exception e) {
                            Log.e(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Error while loggin out");
                        }
                        //dismiss the progress dialog
                        progressDialog.dismiss();
                    }
                }).start();
                //launch LogIn/Create Account page
                Log.i(SmartClosetConstants.SMARTCLOSET_DEBUG_TAG, CLASSNAME + ": Home Fragment..... ");
                //display Category Fragment - mark isLoggenIn to false
                FragmentRouter fragmentRouter = new FragmentRouter().newInstance(false);
                updateFragment(fragmentRouter, SmartClosetConstants.SLIDEMENU_HOME_ITEM);
                setFragmentTitle(SmartClosetConstants.SLIDEMENU_HOME_ITEM);
            }
        default:
            break;
    }
    drawerLayout.closeDrawer(drawerList);
}

[Buggy Hunk]
ClosetFragment closetFragment = new ClosetFragment().newInstance(tokenId);

[Patch]
ClosetFragment closetFragment = new ClosetFragment().newInstance(tokenId, userEmail);