auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean isIdentityProvider() { try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); for (ActivityInfo activityInfo : packageInfo.activities) { if (activityInfo.name.equals(IDPAccountPickerActivity.class.getName())) { return true; } } } catch (NameNotFoundException e) { SalesforceSDKLogger.e(TAG, "Exception occurred while examining application info", e); } return false; }

Target:
Could we keep this API private?
Source:
public List<BlockedItem> getBlockedItems() { return new ArrayList<BlockedItem>(snapshot.blockedProjects); }

Target:
@olivergondza noted in the commit that this should not be public as it is for testing only
Source:
public IStatus validate(String path) { if (fTrace == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceTypeHelper_ValidateNoTrace); } return fTrace.validate(null, path); }

Target:
I don't think it makes sense for the trace to be null here. We shouldn't have to create a new Message file for this case...
Source:
public static boolean isTCCPacket(ByteArrayBuffer baf) { int rc = RTCPHeaderUtils.getReportCount(baf); return isRTPFBPacket(baf) && rc == FMT; }

Target:
just wondering...is it worth putting the `rc == FMT` check first for a short-circuiting efficiency improvement?
Source:
private Result waitForCompletion() throws InterruptedException, IOException { // wait for the completion Result result; while((result = checkForCompletion()) != null) { Thread.sleep(1000); } return result; }

Target:
@bkmeneguello Are you sure that <code>!=</code> is correct?
Source:
public void testUnderlyingReaders() throws IOException, FormatException { FakeReader reader = new FakeReader(); FileStitcher fs = new FileStitcher(reader); assertNotNull(fs.getUnderlyingReaders()); fs.setId("test_z<0-2>.fake"); assertNotNull(fs.getUnderlyingReaders()); }

Target:
Missing fs.close()
Source:
public void shouldGetDiagnosisByUuid() { String uuid = "4e663d66-6b78-11e0-93c3-18a905e044dc"; int diagnosisId = 1; Diagnosis diagnosis = diagnosisDAO.getDiagnosisByUuid(uuid); assertEquals(diagnosisId, (int) diagnosis.getId()); }

Target:
We can get rid of these variables if they are being used in one place.
Source:
public void setUpCallToAction(String callToActionText) { if (callToActionText == null) { callToActionContainer.setVisibility(GONE); } else { callToActionContainer.setVisibility(VISIBLE); callToActionTextView.setText(callToActionText); } }

Target:
I don't think the logic is necessary. We can have the default visibility as `GONE`.
Source:
public AbstractTableViewer getTableViewer() { return actionContext.getViewer(); }

Target:
Could this be protected as well?
Source:
void start() { if (!started) { log.info("Starting prefetching thread."); executorService.execute(new DefaultGetRecordsCacheDaemon()); } started = true; }

Target:
This probably should be public, and in the interface.
Source:
public SymbolTableBuilder(String fullyQualifiedModuleName) { this.fullyQualifiedModuleName = new ArrayList<>(Arrays.asList(fullyQualifiedModuleName.split("\\."))); }

Target:
Why `new ArrayList<>(`?
Source:
public long getNextTimestamp() throws TimestampIOException { long nextTS = _timestampCounter.addAndGet(TIMESTAMP_INCREMENT); long maxTS = _maxReservedTimestamp; // avoid the double volatile read if (nextTS > maxTS) { reserveNextBlock(nextTS); } _numTimestampsCreated.incrementAndGet(); // JMX metric return nextTS; }

Target:
Double volatile read is gone. Can get rid of maxTS.
Source:
public TileRenderRunnable( TileCanvasViewGroup viewGroup, Tile tile) { this.mTileCanvasViewGroup = new WeakReference<>( viewGroup ); this.mTile = new WeakReference<>( tile ); }

Target:
please remove `this.` on this line and the next
Source:
public Response viewDataverse(@PathParam("identifier") String idtf) { return allowCors(response(req -> ok( json(execCommand(new GetDataverseCommand(req, findDataverseOrDie(idtf))), false, settingsService.isTrueForKey(SettingsServiceBean.Key.ExcludeEmailFromExport, false) )))); }

Target:
@matthew-a-dunlap please update the docs on `:ExcludeEmailFromExport`. Thanks!
Source:
public ResourceNotFoundException(IdString id) { super(id.encoded()); }

Target:
Should this better be: super(id.get()) ? At least in some other places [1] we provide the decoded id to ResourceNotFoundException(String). Shouldn't it be the same in all places, either always the decoded id or always the encoded id? [1] https://gerrit-review.googlesource.com/#/c/41733/1/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupsCollection.java
Source:
private AppiumDriver getDriverSafe() { WebDriver driver = getDriver(); if (driver instanceof EventFiringWebDriver) { driver = ((EventFiringWebDriver) driver).getWrappedDriver(); if (driver instanceof AppiumDriver) { return (AppiumDriver) driver; } } throw new ClassCastException("Appium Driver can not be casted from the actual driver."); }

Target:
if you use AppiumDriver<?> driver = (AppiumDriver<?>) getDriverSafe(); then there is no sense in if (driver instanceof AppiumDriver)
Source:
public void assertSimilarity(final File actualFile, final double maxDistance) throws IOException { BufferedImage tempImg = ImageIO.read(actualFile); File tempFile = File.createTempFile("print-test", ".png"); ImageIO.write(tempImg, "png", tempFile); assertSimilarity(ImageIO.read(tempFile), maxDistance); }

Target:
You forgot to revert that
Source:
public URI getLocationHeaderAsURI() { try { return locationHeader != null ? new URI(locationHeader) : null; } catch (URISyntaxException e) { if (LRALogger.logger.isInfoEnabled()) { LRALogger.logger.infof("LRARecord.doEnd missing Location header on ACCEPTED response %s failed: %s", getRequestURI(), e.getMessage()); } return null; } }

Target:
Good catch. I also just spotted that a few other log messages in tryDoEnd are attribued to this. It will be clearer to just remove the LRARecord.doEnd prefix I think.
Source:
public void setup(Method method) throws Exception { logger.info("test name: " + method.getName()); KerberosHelper.loginFromKeytab(MerlinConstants.CURRENT_USER_NAME); bundles[0] = Util.readELBundles()[0][0]; bundles[0] = new Bundle(bundles[0], cluster.getEnvFileName(), cluster.getPrefix()); bundles[0].generateUniqueBundle(); bundles[0].setProcessWorkflow(aggregateWorkflowDir); }

Target:
This seems redundant to me as we are logging in as the current user in the base class.
Source:
public View getOverflowMenuAnchor() { View view = getToolbar().findViewById(R.id.menu_overflow_button); return getToolbar(); }

Target:
Any reason not to check value of the view?
Source:
public List<ResponseInfo> sendAndPoll(List<RequestInfo> requestInfos) throws IOException { if (closed) { throw new IllegalStateException("The NetworkClient is closed."); } List<ResponseInfo> responseInfoList = new ArrayList<ResponseInfo>(); for (RequestInfo requestInfo : requestInfos) { pendingRequests.add(new RequestMetadata(time.milliseconds(), requestInfo, null)); } List<NetworkSend> sends = prepareSends(responseInfoList); selector.poll(POLL_TIMEOUT_MS, sends); handleSelectorEvents(responseInfoList); return responseInfoList; }

Target:
I thought we will catch the exception and call close() here and then rethrow
Source:
public void handleQuotaColumnVisibility() { isQuotaVisible = false; SystemTreeItemModel treeItem = (SystemTreeItemModel) CommonModel.getInstance().getSystemTree().getSelectedItem(); if (treeItem != null && SystemTreeItemType.DataCenter.equals(treeItem.getType())) { StoragePool storagePool = (StoragePool) treeItem.getEntity(); if (!QuotaEnforcementTypeEnum.DISABLED.equals(storagePool.getQuotaEnforcementType())) { isQuotaVisible = true; } } onDiskViewTypeChanged(); }

Target:
As far as I know, enums can be used with the ==/!= operators. It's a matter of style, but I prefer them (since an instance of an enum is really the same referenced entity as the enum constant). However, you can do whatever you like, either is fine by me.
Source:
public CompletableFuture<StaticResource> getResource(String name) { StaticResource template = templates.get(name); if (template != null) { return CompletableFuture.completedFuture(template); } return delegate .getResource(name) .exceptionally((th) -> { templates.putIfAbsent(name, null); return null; } ) .thenApply( (file) -> { templates.putIfAbsent(name, file); return file; }); }

Target:
shouldn't you force the put? Otherwise, what is returned might be different than what's in the cache, it's also possible that doesn't matter.
Source:
public void testSessionTicketsWithTLSv13AndNoKey() throws Throwable { assumeTrue(OpenSsl.isTlsv13Supported()); assumeTrue(OpenSsl.isBoringSSL()); testSessionTickets(SslUtils.PROTOCOL_TLS_V1_3, false); }

Target:
OpenSSL also supports it in a similar way on the server-side. See SSL_OP_NO_TICKET on this page: https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_options.html.
Source:
public void setUp() { TmfEventMatching.registerMatchObject(new TcpEventMatching()); TmfEventMatching.registerMatchObject(new TcpLttngEventMatching()); }

Target:
a BeforeClass has to be static (it doesn't tell you until you actually try to run it) I was wondering why this passed Hudson, but then remembered the perf tests don't run, yet...
Source:
protected void updateTitle(String brand) { if (brand != null) { IBrandManager brandManager = TasksUiPlugin.getDefault().getBrandManager(); setTitle(brandManager.getConnectorLabel(getConnector(), brand)); } }

Target:
Would it make more sense to mark the brand parameter of setBrand as @NonNull instead of checking it here?
Source:
public static int getSegmentForKey(Object key, Cache cache) { KeyPartitioner keyPartitioner = extractComponent(cache, KeyPartitioner.class); if (keyPartitioner != null) { return keyPartitioner.getSegment(key); } return SegmentSpecificCommand.UNKNOWN_SEGMENT; }

Target:
I'd rather throw an exception