auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static DateTime weekFloor(DateTime dt) { DateTime startOfWeek = dt.minusDays(dt.getDayOfWeek() - 1); return dayFloor(dt).withYear(startOfWeek.getYear()) .withMonthOfYear(startOfWeek.getMonthOfYear()) START .withDayOfMonth(startOfWeek.getDayOfMonth()); END } Having a hard time following this, can we just make it "return dayFloor(dt.minusDays(dt.getDayOfWeek() -1)"? Sorry if I'm being dense, but I can't understand the reason for the withMonth/withDay/withYear code.

Target:
public static DateTime weekFloor(DateTime dt) { return dayFloor(dt.minusDays(dt.getDayOfWeek() -1)); }
Source:
public static void startRequestDetailActivity(Context ctx, Request request) { Intent i = ActivityUtil.newIntent(ctx, RequestDetailActivity.class); i.putExtra(RequestDetailActivity.REQUEST_ID, request.getObjectId()); START i.putExtra(RequestDetailActivity.REQUEST_STATE, request.getState().toString()); END ctx.startActivity(i); ActivityUtil.transitionRight((Activity)ctx); } Why not just pass the enum, will that not work?

Target:
public static void startRequestDetailActivity(Context ctx, Request request) { Intent i = ActivityUtil.newIntent(ctx, RequestDetailActivity.class); i.putExtra(RequestDetailActivity.REQUEST_ID, request.getObjectId()); i.putExtra(RequestDetailActivity.REQUEST_STATE, request.getState()); ctx.startActivity(i); ActivityUtil.transitionRight((Activity)ctx); }
Source:
public ParseGeoPoint getLocation() { START return (ParseGeoPoint) getClient().get("location"); END } Change to getParseGeoPoint("location") so we can get rid of this casting stuff?

Target:
public ParseGeoPoint getLocation() { return getClient().getLocation(); }
Source:
public static UserFragment newInstance(String login) { UserFragment f = new UserFragment(); Bundle args = new Bundle(); START args.putString(Constants.EXTRA_LOGIN, login); END f.setArguments(args); return f; } Keep extra in this file.

Target:
public static UserFragment newInstance(String login) { UserFragment f = new UserFragment(); Bundle args = new Bundle(); args.putString(EXTRA_LOGIN, login); f.setArguments(args); return f; }
Source:
START public void loadRepository(boolean refresh) { END Consumer subscriber = repository -> { mRepository = (Repository) repository; updateTitle(); invalidateTabs(); // Apply initial page selection first time the repo is loaded if (mInitialPage >= PAGE_REPO_OVERVIEW && mInitialPage <= PAGE_ACTIVITY) { getPager().setCurrentItem(mInitialPage); mInitialPage = -1; } setContentShown(true); supportInvalidateOptionsMenu(); }; RepositoryService.loadRepository(this, mRepoOwner, mRepoName, refresh) .subscribe(subscriber, e -> {}); } private Also, should put the 3 load methods in proximity to each other.

Target:
private void loadRepository(boolean refresh) { Consumer<Repository> subscriber = repository -> { mRepository = repository; updateTitle(); invalidateTabs(); // Apply initial page selection first time the repo is loaded if (mInitialPage >= PAGE_REPO_OVERVIEW && mInitialPage <= PAGE_ACTIVITY) { getPager().setCurrentItem(mInitialPage); mInitialPage = -1; } setContentShown(true); supportInvalidateOptionsMenu(); }; RepositoryService.loadRepository(this, mRepoOwner, mRepoName, refresh) .subscribe(subscriber, error -> {}); }
Source:
START public void reloadData() { END setContentShown(false); Log.d("TEST", "reloadData callleeeed"); loadReadme(true); loadPullRequestsCount(true); } private

Target:
private void reloadData() { setContentShown(false); loadReadme(true); loadPullRequestsCount(true); }
Source:
public static NotificationListFragment newInstance() { NotificationListFragment fragment = new NotificationListFragment(); Bundle args = new Bundle(); fragment.setArguments(args); START return fragment; END } This change isn't really needed, right?

Target:
public static NotificationListFragment newInstance() { return new NotificationListFragment(); }
Source:
protected void onInitExtras(Bundle extras) { super.onInitExtras(extras); mRepoOwner = extras.getString("owner"); mRepoName = extras.getString("repo"); mPullRequestNumber = extras.getInt("number"); mInitialCommentId = extras.getLong("initial_comment", -1); mInitialPage = extras.getInt("initial_page", -1); extras.remove("initial_comment"); START extras.remove("target_screen"); END } Oops, right.

Target:
protected void onInitExtras(Bundle extras) { super.onInitExtras(extras); mRepoOwner = extras.getString("owner"); mRepoName = extras.getString("repo"); mPullRequestNumber = extras.getInt("number"); mInitialCommentId = extras.getLong("initial_comment", -1); mInitialPage = extras.getInt("initial_page", -1); extras.remove("initial_comment"); extras.remove("initial_page"); }
Source:
protected Fragment getFragment(int position) { final IssueMilestoneListFragment f = IssueMilestoneListFragment.newInstance(mRepoOwner, mRepoName, position == 1); START if (position != 1) { END mOpenFragment = f; } return f; } if (position == 0) probably better expresses what this is about.

Target:
protected Fragment getFragment(int position) { final IssueMilestoneListFragment f = IssueMilestoneListFragment.newInstance(mRepoOwner, mRepoName, position == 1); if (position == 0) { mOpenFragment = f; } return f; }
Source:
int read() { START if (this.hasNext() == false) { END throw new IllegalStateException("This stream hasn't any other value, all values were already read."); } int value = this.interval[nextPos]; this.nextPos++; return value; } `if (!this.hasNext())`

Target:
int read() { if (!this.hasNext()) { throw new IllegalStateException("This stream hasn't any other value, all values were already read."); } int value = this.interval[nextPos]; this.nextPos++; return value; }
Source:
START public void testIntersectsOnGeometryCollection() { END OGCGeometry ogcGeometry = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))"); assertTrue(ogcGeometry.intersects(OGCGeometry.fromText("POINT (1 1)"))); } I modified the test to ensure that if `intersects` is symmetrical and the test failed with NPE: ``` @Test public void testIntersectsOnGeometryCollection() { assertIntersects("GEOMETRYCOLLECTION (POINT (1 1))", "POINT (1 1)", true); } private void assertIntersects(String wkt, String otherWkt, boolean intersects) { assertEquals(OGCGeometry.fromText(wkt).intersects(OGCGeometry.fromText(otherWkt)), intersects); assertEquals(OGCGeometry.fromText(otherWkt).intersects(OGCGeometry.fromText(wkt)), intersects); } ``` Here is the failure: ``` java.lang.NullPointerException at com.esri.core.geometry.RelationalOperations.relate(RelationalOperations.java:45) at com.esri.core.geometry.OperatorDisjointLocal.execute(OperatorDisjointLocal.java:31) at com.esri.core.geometry.GeometryEngine.disjoint(GeometryEngine.java:376) at com.esri.core.geometry.ogc.OGCGeometry.disjoint(OGCGeometry.java:275) at com.esri.core.geometry.ogc.OGCGeometry.intersects(OGCGeometry.java:280) at com.esri.core.geometry.TestOGC.assertIntersects(TestOGC.java:1007) at com.esri.core.geometry.TestOGC.testIntersectsOnGeometryCollection(TestOGC.java:1001) ```

Target:
public void testIntersectsOnGeometryCollection() { OGCGeometry ogcGeometry = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))"); assertTrue(ogcGeometry.intersects(OGCGeometry.fromText("POINT (1 1)"))); ogcGeometry = OGCGeometry.fromText("POINT (1 1)"); assertTrue(ogcGeometry.intersects(OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))"))); }
Source:
public Unit(String unitName, boolean enemy) { START this(unitName, 1, enemy, GameController.getInstance().getUnitLife(unitName)); END } Que es este 1?

Target:
public Unit(String unitName, boolean enemy) { this(unitName, -1, enemy, GameController.getInstance().getUnitLife(unitName)); }