auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void scale(final int width, final int height, final int toWidth, final int toHeight, final boolean keepAspectRatio) { if (null != getHandler() && null != getHandler().getDiagram()) { final double[] sfactor = LienzoUtils.getScaleFactor(width, height, toWidth, toHeight); <START> if (1 != sfactor[0] || 1 != sfactor[1]) { <END> final double[] factor = getScaleFactor(sfactor, keepAspectRatio); getZoomControl().scale(factor[0], factor[1]); scalePanel(toWidth, toHeight); } } else { LOGGER.log(Level.WARNING, "Nothing to scale!"); } }</code><technical_language>is danger equality tests floating point values. Is correct usage here</technical_language>

Target:
protected void scale(final int width, final int height, final int toWidth, final int toHeight, final boolean keepAspectRatio) { if (null != getHandler() && null != getHandler().getDiagram()) { final double[] sfactor = LienzoUtils.getScaleFactor(width, height, toWidth, toHeight); if (0 != Double.compare(1,sfactor[0]) || 0 != Double.compare(1, sfactor[1])) { final double[] factor = getScaleFactor(sfactor, keepAspectRatio); getZoomControl().scale(factor[0], factor[1]); scalePanel(toWidth, toHeight); } } else { LOGGER.log(Level.WARNING, "Nothing to scale!"); } }
Source:
<code><START> public Date getTimeOfEntry() { <END> return this.timeOfEntry; }</code><technical_language>For consistency DateTime in stead of Date (like in other microgrids DTOs)</technical_language>

Target:
public DateTime getTimeOfEntry() { return this.timeOfEntry; }
Source:
<code>public StatsDEmitter(StatsDEmitterConfig config, ObjectMapper mapper) { this.config = config; this.converter = new DimensionConverter(mapper, config.getDimensionMapPath()); statsd = new NonBlockingStatsDClient( config.getPrefix(), config.getHostname(), config.getPort(), new StatsDClientErrorHandler() { @Override public void handle(Exception exception) { <START> log.error(exception, "Error sending metric to StatsD."); <END> } } ); }</code><technical_language>if this log emit error, need print thousand flood logs exception</technical_language>

Target:
public StatsDEmitter(StatsDEmitterConfig config, ObjectMapper mapper) { this.config = config; this.converter = new DimensionConverter(mapper, config.getDimensionMapPath()); statsd = new NonBlockingStatsDClient( config.getPrefix(), config.getHostname(), config.getPort(), new StatsDClientErrorHandler() { private int exceptionCount = 0; @Override public void handle(Exception exception) { if (exceptionCount % 1000 == 0) { log.error(exception, "Error sending metric to StatsD."); } exceptionCount += 1; } } ); }
Source:
<code>public static Map<String, String> decodeSmallHeaders(ByteBuf buffer) { short numHeaders = buffer.readUnsignedByte(); <START> Map<String, String> headers = new HashMap<>(numHeaders); <END> for (int i = 0; i < numHeaders; i++) { String key = CodecUtils.decodeSmallString(buffer); String value = CodecUtils.decodeSmallString(buffer); headers.put(key, value); } return headers; }</code><technical_language>com.google.common.collect.Maps.newHashMapWithExpectedSize(numHeaders)</technical_language>

Target:
public static Map<String, String> decodeSmallHeaders(ByteBuf buffer) { short numHeaders = buffer.readUnsignedByte(); Map<String, String> headers = Maps.newHashMapWithExpectedSize(numHeaders); for (int i = 0; i < numHeaders; i++) { String key = CodecUtils.decodeSmallString(buffer); String value = CodecUtils.decodeSmallString(buffer); headers.put(key, value); } return headers; }
Source:
<code><START> public void initializeBlockEncodingBuffers(DecodedBlockNode[] decodedBlocks) <END> { if (blockEncodingBuffers == null) { int channelCount = decodedBlocks.length; int initialElementCount = channelCount == 0 ? 0 : min(capacity / channelCount / DEFAULT_ELEMENT_SIZE_IN_BYTES, INITIAL_POSITION_COUNT); blockEncodingBuffers = new BlockEncodingBuffers[channelCount]; for (int i = 0; i < channelCount; i++) { blockEncodingBuffers[i] = createBlockEncodingBuffers(decodedBlocks[i], initialElementCount); } } }</code><technical_language>this private; is called appendRows method</technical_language>

Target:
private void initializeBlockEncodingBuffers(DecodedBlockNode[] decodedBlocks) { if (blockEncodingBuffers == null) { int initialElementCount = min(capacity / channelCount / DEFAULT_ELEMENT_SIZE_IN_BYTES, INITIAL_POSITION_COUNT); blockEncodingBuffers = new BlockEncodingBuffers[channelCount]; for (int i = 0; i < channelCount; i++) { blockEncodingBuffers[i] = createBlockEncodingBuffers(decodedBlocks[i], initialElementCount); } } }
Source:
<code>public void testShutdownRemove() throws Throwable { assertNotNull("No ShutdownHookManager", mgr); assertEquals(0, mgr.getShutdownHooksInOrder().size()); Hook hook1 = new Hook("hook1", 0, false); Hook hook2 = new Hook("hook2", 0, false); mgr.addShutdownHook(hook1, 9); <START> assertTrue(mgr.hasShutdownHook(hook1)); END> assertEquals(1, mgr.getShutdownHooksInOrder().size()); assertFalse(mgr.removeShutdownHook(hook2)); assertTrue(mgr.removeShutdownHook(hook1)); assertEquals(0, mgr.getShutdownHooksInOrder().size()); }</code><technical_language>needs a message</technical_language>

Target:
public void testShutdownRemove() throws Throwable { assertNotNull("No ShutdownHookManager", mgr); assertEquals(0, mgr.getShutdownHooksInOrder().size()); Hook hook1 = new Hook("hook1", 0, false); Hook hook2 = new Hook("hook2", 0, false); mgr.addShutdownHook(hook1, 9); assertTrue("No hook1", mgr.hasShutdownHook(hook1)); assertEquals(1, mgr.getShutdownHooksInOrder().size()); assertFalse("Delete hook2 should not be allowed", mgr.removeShutdownHook(hook2)); assertTrue("Can't delete hook1", mgr.removeShutdownHook(hook1)); assertEquals(0, mgr.getShutdownHooksInOrder().size()); }
Source:
<code>private boolean TestOperationImplemented(OperationEnum operation, BaseDelegatingResource resource) { Method method = null; switch (operation) { case get: <START> method = ReflectionUtils.findMethod(resource.getClass(), Operation.OPERATION_GET_ALL_METHOD, RequestContext.class); <END> return method != null && !method.getDeclaringClass().getName().endsWith("DelegatingCrudResource"); } return true; }</code><technical_language>I doubt if this is guaranteed work a resource implement a method throw exception, this is i assume invoking method catching ResourceDoesNotSupportOperationException is option</technical_language>

Target:
private boolean TestOperationImplemented(OperationEnum operation, BaseDelegatingResource resource) { try { switch (operation) { case get: case getSubresource: ((Listable) resource).getAll(BuildDummyRequestContextForOperationTest(operation)); break; case getWithUUID: case getSubresourceWithUUID: resource.getByUniqueId(IMPOSSIBLE_UNIQUE_ID); case postCreate: case postSubresource: resource.save(null); } return true; } catch (ResourceDoesNotSupportOperationException e) { return false; } catch (Exception e) { return true; } }
Source:
<code>protected Builder() { id("profitbricks-rest") <START> .name("DigitalOcean Compute Services") <END> .apiMetadata(new ProfitBricksApiMetadata()) .homepage(URI.create("<LINK_2>")) .console(URI.create("<LINK_0>")) .endpoint("<LINK_1>") .defaultProperties(ProfitBricksProviderMetadata.defaultProperties()); }</code><technical_language>Fix this literal</technical_language>

Target:
protected Builder() { id("profitbricks-rest") .name("ProfitBricks REST Compute") .apiMetadata(new ProfitBricksApiMetadata()) .homepage(URI.create("<LINK_2>")) .console(URI.create("<LINK_0>")) .iso3166Codes("DE-FKB", "DE-FRA", "US-LAS", "US-LASDEV") .endpoint("<LINK_1>") .defaultProperties(ProfitBricksProviderMetadata.defaultProperties()); }
Source:
<code>public static boolean playerRemoveBlock(World world, BlockPos pos, @Nullable EntityPlayer player, boolean dropBlock) { if (player == null) player = RailcraftFakePlayer.get((WorldServer) world, pos); IBlockState state = getBlockState(world, pos); if (MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(world, pos, state, player))) return false; if (!state.getBlock().removedByPlayer(state, world, pos, player, dropBlock)) return false; if (dropBlock) { <START> state.getBlock().harvestBlock(world, player, pos, state, getBlockTile(world, pos), player.getHeldItem(player.getActiveHand())); <END> } return true; }</code><technical_language>I do here, tile longer exists this point, calling getBlockTile(world, pos) return null always</technical_language>

Target:
public static boolean playerRemoveBlock(World world, BlockPos pos, @Nullable EntityPlayer player, boolean dropBlock) { if (player == null) player = RailcraftFakePlayer.get((WorldServer) world, pos); IBlockState state = getBlockState(world, pos); TileEntity te = getBlockTile(world, pos); if (MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(world, pos, state, player))) return false; if (!state.getBlock().removedByPlayer(state, world, pos, player, dropBlock)) return false; if (dropBlock) { state.getBlock().harvestBlock(world, player, pos, state, te, player.getHeldItem(player.getActiveHand())); } return true; }
Source:
<code>public boolean test( Object value ) { assert false : "StringContainsPredicate.test() has not been tested yet... Add tests and remove assert"; <START> return value != null && value instanceof String && ((String)value).contains( contains ); <END> }</code><technical_language>This</technical_language>

Target:
public boolean test( Object value ) { return value != null && value instanceof String && ((String)value).contains( contains ); }
Source:
<code>public void skipBytes(final int count) { try { for (int s = count; s > 0;) { final int skipped = (int)in.skip(s); if (skipped <= 0) <START> throw new RuntimeIOException("Failed to skip " + s); <END> s -= skipped; } } catch (final IOException e) { throw new RuntimeIOException(e); } }</code><technical_language>{}</technical_language>

Target:
public void skipBytes(final int count) { try { for (int s = count; s > 0;) { final int skipped = (int)in.skip(s); if (skipped <= 0) { throw new RuntimeIOException("Failed to skip " + s); } s -= skipped; } } catch (final IOException e) { throw new RuntimeIOException(e); } }
Source:
<code>public Status update(String table, String endpoint, HashMap<String, ByteIterator> values) { int responseCode; try { responseCode = httpExecute(new HttpPut(urlPrefix + endpoint), values.get("data").toString()); <START> } catch (Exception e) { <END> responseCode = handleExceptions(e); } if (logEnabled) { System.out.println(new StringBuilder("PUT Request: ").append(urlPrefix).append(endpoint) .append(" | Response Code: ").append(responseCode).toString()); } return getStatus(responseCode); }</code><technical_language>This is catching exceptions printing happened? nice log actual exception</technical_language>

Target:
public Status update(String table, String endpoint, HashMap<String, ByteIterator> values) { int responseCode; try { responseCode = httpExecute(new HttpPut(urlPrefix + endpoint), values.get("data").toString()); } catch (Exception e) { responseCode = handleExceptions(e, urlPrefix + endpoint, HttpMethod.PUT); } if (logEnabled) { System.err.println(new StringBuilder("PUT Request: ").append(urlPrefix).append(endpoint) .append(" | Response Code: ").append(responseCode).toString()); } return getStatus(responseCode); }
Source:
<code>public static Set<SecureStoreData> findSecureStores(File pluginFile, String pluginName) throws InvalidPluginException, IOException, ClassNotFoundException { ImmutableSet.Builder<SecureStoreData> result = new ImmutableSet.Builder<SecureStoreData>(); <START> Iterable<ExtensionMetaData> exports = <END> JarScanner.scan(pluginFile, pluginName, Export.class); for (ExtensionMetaData export : exports) { String className = export.getClassName(); Class<?> clazz = Class.forName(className); if (is("com.google.gerrit.server.securestore.SecureStore", clazz)) { String storeName = export.getAnnotationValue(); SecureStoreData metadata = new SecureStoreData(pluginName, className, pluginFile, storeName); result.add(metadata); } } return result.build(); }</code><technical_language>need it, inline JarScanner.scan for()</technical_language>

Target:
public static Set<SecureStoreData> findSecureStores(File pluginFile, String pluginName) throws InvalidPluginException, IOException, ClassNotFoundException { ImmutableSet.Builder<SecureStoreData> result = new ImmutableSet.Builder<SecureStoreData>(); Iterable<ExtensionMetaData> exports = JarScanner.scan(pluginFile, pluginName, Export.class); for (ExtensionMetaData export : exports) { String className = export.getClassName(); Optional<String> implementsSecureStore = tryFind(export.getInterfaces(), equalTo(SECURE_STORE_INTERFACE)); if (implementsSecureStore.isPresent()) { String storeName = export.getAnnotationValue(); SecureStoreData metadata = new SecureStoreData(pluginName, className, pluginFile, storeName); result.add(metadata); } } return result.build(); }
Source:
<code>private IASTAttributeList getFallthroughAttributeList(ICPPNodeFactory factory) { IASTAttribute attribute = <START> factory.newAttribute("fallthrough".toCharArray(), <END> null); IASTAttributeList attributeList = factory.newAttributeList(); attributeList.addAttribute(attribute); return attributeList; }</code><technical_language>literals for specific attributes. create a class in cdt.core StandardAttributes string constants (Suggestion P. Sommerlad)</technical_language>

Target:
private IASTAttributeList getFallthroughAttributeList(ICPPNodeFactory factory) { IASTAttribute attribute = factory.newAttribute(StandardAttributes.cFALLTHROUGH, null); IASTAttributeList attributeList = factory.newAttributeList(); attributeList.addAttribute(attribute); return attributeList; }
Source:
<code>public void testEng19702() throws IOException, ProcCallException { if (isHSQL()) { return; } final Client client = getClient(); client.callProcedure("@AdHoc", "INSERT INTO Eng19702_Balance VALUES ('asi', 'abi', '2020-06-09')"); client.callProcedure("@AdHoc", "INSERT INTO Eng19702_BalanceValue VALUES ('asi', 'abi', 1000.0, '2020-05-01')"); <START> assertContentOfTable(new Object[][]{{1000.00}}, <END> client.callProcedure("@AdHoc", "SELECT Checksum from (\n" + " SELECT B.SubscriberId, B.BalanceId,\n" + " B.ExpiryDate,\n" + " SUM(BV.BalanceValue) AS BalanceValue,\n" + " MIN(LastUpdated) AS MinLastUpdated,\n" + " COALESCE(MAX(DECODE(B.BalanceId, 'abi', LastUpdated, NULL)), MAX(LastUpdated)) AS LastUpdated,\n" + " MAX(DECODE(B.BalanceId, 'abi', BV.BalanceValue, 0)) AS Checksum\n" + " FROM Eng19702_Balance B JOIN Eng19702_BalanceValue BV\n" + " ON B.SubscriberId = BV.SubscriberId AND B.SubscriberId = 'asi' AND B.BalanceId = BV.BalanceId\n" + " GROUP BY B.SubscriberId, B.BalanceId) subquery") .getResults()[0]); }</code><technical_language>pass in expected a BigDecimal instead of a Double? need cast BigDecimal Double in assertContentOfTable</technical_language>

Target:
public void testEng19702() throws IOException, ProcCallException { if (isHSQL()) { return; } final Client client = getClient(); client.callProcedure("@AdHoc", "INSERT INTO Eng19702_Balance VALUES ('asi', 'abi', '2020-06-09')"); client.callProcedure("@AdHoc", "INSERT INTO Eng19702_BalanceValue VALUES ('asi', 'abi', 1000.0, '2020-05-01')"); assertContentOfTable(new Object[][]{{new BigDecimal("1000.0")}}, client.callProcedure("@AdHoc", "SELECT Checksum from (\n" + " SELECT B.SubscriberId, B.BalanceId,\n" + " B.ExpiryDate,\n" + " SUM(BV.BalanceValue) AS BalanceValue,\n" + " MIN(LastUpdated) AS MinLastUpdated,\n" + " COALESCE(MAX(DECODE(B.BalanceId, 'abi', LastUpdated, NULL)), MAX(LastUpdated)) AS LastUpdated,\n" + " MAX(DECODE(B.BalanceId, 'abi', BV.BalanceValue, 0)) AS Checksum\n" + " FROM Eng19702_Balance B JOIN Eng19702_BalanceValue BV\n" + " ON B.SubscriberId = BV.SubscriberId AND B.SubscriberId = 'asi' AND B.BalanceId = BV.BalanceId\n" + " GROUP BY B.SubscriberId, B.BalanceId) subquery") .getResults()[0]); }
Source:
<code>private void saveSelectedPagesForOffline(@NonNull List<ReadingListPage> selectedPages, boolean forcedSave) { if (!selectedPages.isEmpty()) { <START> for (ReadingListPage page : selectedPages) { updatePageItemUI(page); } <END> ReadingListDbHelper.instance().markPagesForOffline(selectedPages, true, forcedSave); showMultiSelectOfflineStateChangeSnackbar(selectedPages, true); adapter.notifyDataSetChanged(); update(); } }</code><technical_language>invalidating entire dataset in adapter (a lines below), views redrawn, do need do this here</technical_language>

Target:
private void saveSelectedPagesForOffline(@NonNull List<ReadingListPage> selectedPages, boolean forcedSave) { if (!selectedPages.isEmpty()) { for (ReadingListPage page : selectedPages) { updatePageProgress(page); } ReadingListDbHelper.instance().markPagesForOffline(selectedPages, true, forcedSave); showMultiSelectOfflineStateChangeSnackbar(selectedPages, true); adapter.notifyDataSetChanged(); update(); } }
Source:
<code>private void checkLogData(long address, ILogData logData) { if (logData == null || logData.getType() == DataType.EMPTY) { throw new RuntimeException("Unexpected return of empty data at address " + address + " on read"); } else if (logData.isTrimmed()) { throw new TrimmedException(); } <START> } <END></code><technical_language>extra else statement, please remove</technical_language>

Target:
private void checkLogData(long address, ILogData logData) { if (logData == null || logData.getType() == DataType.EMPTY) { throw new RuntimeException("Unexpected return of empty data at address " + address + " on read"); } if (logData.isTrimmed()) { throw new TrimmedException(); } }
Source:
<code>public void introspect() throws IOException { HttpMessage importMessage = requestor.sendQuery( IntrospectionQuery.INTROSPECTION_QUERY, GraphQlParam.RequestMethodOption.POST_JSON); <START> if (importMessage != null) { <END> try { Map<String, Object> result = new Gson() .fromJson( importMessage.getResponseBody().toString(), new TypeToken<Map<String, Object>>() {}.getType()); @SuppressWarnings("unchecked") Document schema = new IntrospectionResultToSchema() .createSchemaDefinition((Map<String, Object>) result.get("data")); String schemaSdl = new SchemaPrinter().print(schema); parse(schemaSdl); } catch (JsonSyntaxException e) { throw new IOException("The response was not valid JSON."); } } }</code><technical_language>check null return avoid nesting</technical_language>

Target:
public void introspect() throws IOException { HttpMessage importMessage = requestor.sendQuery( IntrospectionQuery.INTROSPECTION_QUERY, GraphQlParam.RequestMethodOption.POST_JSON); if (importMessage == null) { throw new IOException("Could not obtain schema via Introspection."); } try { Map<String, Object> result = new Gson() .fromJson( importMessage.getResponseBody().toString(), new TypeToken<Map<String, Object>>() {}.getType()); @SuppressWarnings("unchecked") Document schema = new IntrospectionResultToSchema() .createSchemaDefinition((Map<String, Object>) result.get("data")); String schemaSdl = new SchemaPrinter().print(schema); parse(schemaSdl); } catch (JsonSyntaxException e) { throw new IOException("The response was not valid JSON."); } }
Source:
<code>public static boolean stateBackendFromApplicationOrConfigOrDefaultUseManagedMemory( Configuration config, Optional<Boolean> stateBackendFromApplicationUsesManagedMemory, ClassLoader classLoader) { checkNotNull(config, "config"); if (stateBackendFromApplicationUsesManagedMemory.isPresent()) { return stateBackendFromApplicationUsesManagedMemory.get(); } try { <START> final StateBackend fromConfig = loadStateBackendFromConfig(config, classLoader, null); <END> if (fromConfig != null) { return fromConfig.useManagedMemory(); } } catch (IllegalConfigurationException | DynamicCodeLoadingException | IOException e) { LOG.warn("Cannot decide whether state backend uses managed memory. Will reserve managed memory by default.", e); return true; } return false; }</code><technical_language>pass parameter LOG instead of null here</technical_language>

Target:
public static boolean stateBackendFromApplicationOrConfigOrDefaultUseManagedMemory( Configuration config, Optional<Boolean> stateBackendFromApplicationUsesManagedMemory, ClassLoader classLoader) { checkNotNull(config, "config"); if (stateBackendFromApplicationUsesManagedMemory.isPresent()) { return stateBackendFromApplicationUsesManagedMemory.get(); } try { final StateBackend fromConfig = loadStateBackendFromConfig(config, classLoader, LOG); if (fromConfig != null) { return fromConfig.useManagedMemory(); } } catch (IllegalConfigurationException | DynamicCodeLoadingException | IOException e) { LOG.warn("Cannot decide whether state backend uses managed memory. Will reserve managed memory by default.", e); return true; } return false; }
Source:
<code>private void startGame() { Tile <START> tile0 = <END> Tile.newRandomTile(); List<Location> locCopy = locations.stream().collect(Collectors.toList()); Collections.shuffle(locCopy); tile0.setLocation(locCopy.get(0)); gameGrid.put(tile0.getLocation(), tile0); Tile tile1 = Tile.newRandomTile(); tile1.setLocation(locCopy.get(1)); gameGrid.put(tile1.getLocation(), tile1); redrawTilesInGameGrid(); }</code><technical_language>Do names tile0, tile1, myVariable2,</technical_language>

Target:
private void startGame() { Tile tileNew = Tile.newRandomTile(); List<Location> locCopy = locations.stream().collect(Collectors.toList()); Collections.shuffle(locCopy); tileNew.setLocation(locCopy.get(0)); gameGrid.put(tileNew.getLocation(), tileNew); Tile tile1 = Tile.newRandomTile(); tile1.setLocation(locCopy.get(1)); gameGrid.put(tile1.getLocation(), tile1); redrawTilesInGameGrid(); }
Source:
<code>private void renderFinalStereoImage(RenderingStage renderingStage) { switch (renderingStage) { case LEFT_EYE: <START> if (postProcessor.isNotTakingScreenshot()) { END> sceneFinal.bind(); } else { ocUndistorted.bind(); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(0, 0, fullScale.width() / 2, fullScale.height()); break; case RIGHT_EYE: renderFullscreenQuad(fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height()); if (postProcessor.isNotTakingScreenshot()) { bindDisplay(); applyOculusDistortion(sceneFinal); } else { sceneFinal.bind(); applyOculusDistortion(ocUndistorted); postProcessor.saveScreenshot(); } break; case MONO: break; } }</code><technical_language>Errr... verify this push a new commit! =)</technical_language>

Target:
private void renderFinalStereoImage(RenderingStage renderingStage) { if (postProcessor.isNotTakingScreenshot()) { sceneFinal.bind(); } else { ocUndistorted.bind(); } switch (renderingStage) { case LEFT_EYE: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(0, 0, fullScale.width() / 2, fullScale.height()); break; case RIGHT_EYE: renderFullscreenQuad(fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height()); if (postProcessor.isNotTakingScreenshot()) { bindDisplay(); applyOculusDistortion(sceneFinal); } else { sceneFinal.bind(); applyOculusDistortion(ocUndistorted); postProcessor.saveScreenshot(); } break; case MONO: break; } }
Source:
<code>private Collection<List<MatchedAffiliation>> groupByOrganizationId(Iterable<MatchedAffiliation> matchedAffs) { Map<CharSequence, List<MatchedAffiliation>> matchedGroupedByOrgId = Maps.newHashMap(); for (MatchedAffiliation matched : matchedAffs) { <START> if (!matchedGroupedByOrgId.containsKey(matched.getOrganizationId())) { <END> matchedGroupedByOrgId.put(matched.getOrganizationId(), Lists.newArrayList(matched)); } else { matchedGroupedByOrgId.get(matched.getOrganizationId()).add(matched); } } return matchedGroupedByOrgId.values(); }</code><technical_language>is easier read conditions negations, I skip ! swap if else bodies</technical_language>

Target:
private Collection<List<MatchedAffiliation>> groupByOrganizationId(Iterable<MatchedAffiliation> matchedAffs) { Map<CharSequence, List<MatchedAffiliation>> matchedGroupedByOrgId = Maps.newHashMap(); for (MatchedAffiliation matched : matchedAffs) { if (matchedGroupedByOrgId.containsKey(matched.getOrganizationId())) { matchedGroupedByOrgId.get(matched.getOrganizationId()).add(matched); } else { matchedGroupedByOrgId.put(matched.getOrganizationId(), Lists.newArrayList(matched)); } } return matchedGroupedByOrgId.values(); }
Source:
<code>public void findConceptsByName_shouldGetCorrectConceptByName() { mDatabase.conceptRoomDAO().saveConcept(expectedConceptEntity1); mDatabase.conceptRoomDAO().saveConcept(expectedConceptEntity2); mDatabase.conceptRoomDAO().findConceptsByName(expectedConceptEntity1.getName()).subscribe(new SingleObserver<List<ConceptEntity>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onSuccess(List<ConceptEntity> conceptEntities) { Assert.assertEquals(conceptEntities.get(0), expectedConceptEntity1); <START> Assert.assertEquals(conceptEntities.get(1), expectedConceptEntity2); <END> } @Override public void onError(Throwable e) { Log.i(TAG, e.getMessage()); } }); }</code><technical_language>This list expectedConceptEntity1's expectedConceptEntity2's name is different</technical_language>

Target:
public void findConceptsByName_shouldGetCorrectConceptByName() { mDatabase.conceptRoomDAO().saveConcept(expectedConceptEntity1); mDatabase.conceptRoomDAO().saveConcept(expectedConceptEntity2); mDatabase.conceptRoomDAO().findConceptsByName(expectedConceptEntity1.getName()) .test() .assertValue(conceptEntities -> { ConceptEntity actualEntity = conceptEntities.get(0); return Objects.equals(actualEntity.getUuid(), expectedConceptEntity1.getUuid()) && Objects.equals(actualEntity.getName(), expectedConceptEntity1.getName()) && Objects.equals(actualEntity.getDisplay(), expectedConceptEntity1.getDisplay()); }); }
Source:
<code>public void onScrollChanged(int oldScrollY, int scrollY, boolean isHumanScroll) { if (webview == null) { return; } if (scrollY <= webview.getHeight()) { ViewAnimations.ensureTranslationY(pageActions, 0); return; } int animMargin; if (oldScrollY > scrollY) { <START> int minMargin = 0; <END> int scrollDelta = oldScrollY - scrollY; int newMargin = (int) pageActions.getTranslationY() - scrollDelta; animMargin = Math.max(minMargin, newMargin); } else { int scrollDelta = scrollY - oldScrollY; int minMargin = pageActions.getHeight(); int newMargin = (int) pageActions.getTranslationY() + scrollDelta; animMargin = Math.min(minMargin, newMargin); } pageActions.setTranslationY(animMargin); }</code><technical_language>If move this line one, cases same</technical_language>

Target:
public void onScrollChanged(int oldScrollY, int scrollY, boolean isHumanScroll) { if (webView == null) { return; } if (scrollY <= webView.getHeight()) { ViewAnimations.ensureTranslationY(pageActions, 0); return; } int animMargin; int scrollDelta = scrollY - oldScrollY; int newMargin = (int) pageActions.getTranslationY() + scrollDelta; if (oldScrollY < scrollY) { int minMargin = pageActions.getHeight(); animMargin = Math.min(minMargin, newMargin); } else { int minMargin = 0; animMargin = Math.max(minMargin, newMargin); } pageActions.setTranslationY(animMargin); }
Source:
<code>public String toString() { if (getName() == null) { return getPersonId(); } else { if (getPersonId() == null) { <START> return ""; END> } else { if (getName().equals(getPersonId())) { return getName(); } else { return getName() + " <" + getPersonId() + ">"; } } } }</code><technical_language>return name in this case</technical_language>

Target:
public String toString() { if (getName() == null) { return getPersonId(); } else { if (getPersonId() == null) { return getName(); } else { if (getName().equals(getPersonId())) { return getName(); } else { return getName() + " <" + getPersonId() + ">"; } } } }
Source:
<code>public void testTextInputComp() { ComponentIdentifier identifier = OM_factories.TextField_pfr_txf; TextInputComponent textField = ConcreteComponents .createTextInputComponent(identifier); Assert.assertNotNull(textField); CAP cap1 = textField.checkEditability(true); Assert.assertNotNull(cap1); <START> CAP cap2 = textField.checkText("test", Operator.equals); END> Assert.assertNotNull(cap2); CAP cap3 = textField.inputText("test"); Assert.assertNotNull(cap3); CAP cap4 = textField.insertTextAfterIndex("test", 1); Assert.assertNotNull(cap4); CAP cap5 = textField.insertTextBeforeAfterPattern( "test", "pattern", Operator.equals, true); Assert.assertNotNull(cap5); CAP cap6 = textField.replaceText("test"); Assert.assertNotNull(cap6); CAP cap7 = textField.selectAll(); Assert.assertNotNull(cap7); CAP cap8 = textField.selectPattern("test", Operator.equals); Assert.assertNotNull(cap8); Assert.assertTrue(textField instanceof org.eclipse.jubula.toolkit.base.components.TextComponent); Assert.assertTrue(textField instanceof org.eclipse.jubula.toolkit.base.components.GraphicsComponent); Assert.assertTrue(textField instanceof org.eclipse.jubula.toolkit.base.components.TextInputComponent); }</code><technical_language>"test" a constant for this</technical_language>

Target:
public void testTextInputComp() { ComponentIdentifier identifier = OM_factories.TextField_pfr_txf; TextInputComponent textField = ConcreteComponents .createTextInputComponent(identifier); Assert.assertNotNull(textField); CAP cap1 = textField.checkEditability(true); Assert.assertNotNull(cap1); CAP cap2 = textField.checkText(TEST, Operator.equals); Assert.assertNotNull(cap2); CAP cap3 = textField.inputText(TEST); Assert.assertNotNull(cap3); CAP cap4 = textField.insertTextAfterIndex(TEST, 1); Assert.assertNotNull(cap4); CAP cap5 = textField.insertTextBeforeAfterPattern( TEST, "pattern", Operator.equals, true); Assert.assertNotNull(cap5); CAP cap6 = textField.replaceText(TEST); Assert.assertNotNull(cap6); CAP cap7 = textField.selectAll(); Assert.assertNotNull(cap7); CAP cap8 = textField.selectPattern(TEST, Operator.equals); Assert.assertNotNull(cap8); Assert.assertTrue(textField instanceof org.eclipse.jubula.toolkit.base.components.TextComponent); Assert.assertTrue(textField instanceof org.eclipse.jubula.toolkit.base.components.GraphicsComponent); Assert.assertTrue(textField instanceof org.eclipse.jubula.toolkit.base.components.TextInputComponent); }
Source:
<code><START> private static List<Throwable> runConcurrently(ConsumerWithCoreException<TaskDataStore>... consumers) <END> throws Exception { TaskDataStore store = newTaskDataStore(); CyclicBarrier barrier = new CyclicBarrier(consumers.length + 1); List<Throwable> failures = new ArrayList<>(consumers.length); List<Thread> threads = Arrays.asList(consumers) .stream() .map(c -> thread(c, store, barrier, failures).get()) .collect(toList()); threads.stream().forEach(Thread::start); barrier.await(); for (Thread thread : threads) { thread.join(); } return failures; }</code><technical_language>extract a method takes a List<Thread> for of these</technical_language>

Target:
private static List<Throwable> runConcurrently(ConsumerWithCoreException<TaskDataStore>... consumers) throws Exception { TaskDataStore store = newTaskDataStore(); CyclicBarrier barrier = new CyclicBarrier(consumers.length + 1); List<Throwable> failures = new ArrayList<>(consumers.length); List<Thread> threads = Arrays.asList(consumers) .stream() .map(c -> thread(c, store, Optional.of(barrier), failures).get()) .collect(toList()); startThreadsSimultaneously(barrier, threads); return failures; }
Source:
<code>public ApplicationModule getApplicationModule(String moduleId) throws AppCatalogException { ApplicationModuleRepository applicationModuleRepository = new ApplicationModuleRepository(); Map<String, Object> queryParameters = new HashMap<>(); queryParameters.put(DBConstants.ApplicationModule.APPLICATION_MODULE_ID, moduleId); <START> ApplicationModule applicationModule = applicationModuleRepository.select(QueryConstants.FIND_APPLICATION_MODULE, -1, 0, queryParameters).get(0); <END> return applicationModule; }</code><technical_language>Is guaranteed this return value? is risky call get(0)</technical_language>

Target:
public ApplicationModule getApplicationModule(String moduleId) throws AppCatalogException { ApplicationModuleRepository applicationModuleRepository = new ApplicationModuleRepository(); return applicationModuleRepository.get(moduleId); }
Source:
<code>public SubordinateTransaction getImportedTransaction (Xid xid) throws XAException { if (xid == null) throw new IllegalArgumentException(); AtomicReference<SubordinateTransaction> holder = _transactions.get(new SubordinateXidImple(xid)); SubordinateTransaction tx = holder == null ? null : holder.get(); if (tx == null) { return null; } try { if (tx.getStatus() == javax.transaction.Status.STATUS_ROLLEDBACK) { throw new XAException(XAException.XA_RBROLLBACK); } } catch (SystemException e) { <START> e.printStackTrace(); <END> throw new XAException(XAException.XA_RBROLLBACK); } if (tx.baseXid() == null) { tx.recover(); return tx; } else return tx; }</code><technical_language>This logged jtaxLogger.logger.warn(...)</technical_language>

Target:
public SubordinateTransaction getImportedTransaction (Xid xid) throws XAException { if (xid == null) throw new IllegalArgumentException(); AtomicReference<SubordinateTransaction> holder = _transactions.get(new SubordinateXidImple(xid)); SubordinateTransaction tx = holder == null ? null : holder.get(); if (tx == null) { return null; } try { if (tx.getStatus() == javax.transaction.Status.STATUS_ROLLEDBACK) { throw new XAException(XAException.XA_RBROLLBACK); } } catch (SystemException e) { throw new XAException(XAException.XA_RBROLLBACK); } if (tx.baseXid() == null) { tx.recover(); return tx; } else return tx; }
Source:
<code>public Response execute() { DatabaseAccessor db = null; Response response; try { db = initDB(); String hash = BCrypt.hashpw(password,BCrypt.gensalt()); db.addUser(username, hash, "SALT", privileges, name, email); response = new MinimalResponse(HttpStatusCode.OK); } catch (SQLException e) { response = new ErrorResponse(HttpStatusCode.BAD_REQUEST, "Creation of user '" + username + "' unsuccessful, user " + "already exists."); Debug.log("Reason: " + e.getMessage()); } catch (IOException e) { response = new ErrorResponse(HttpStatusCode.INTERNAL_SERVER_ERROR, "Creation of user '" + username + "' unsuccessful due to " + "temporary database problems."); } finally { <START> if (db != null) <END> db.close(); } return response; }</code><technical_language>Consider try-with-resources</technical_language>

Target:
public Response execute() { DatabaseAccessor db = null; Response response; try { db = initDB(); String hash = BCrypt.hashpw(password,BCrypt.gensalt()); db.addUser(username, hash, "SALT", privileges, name, email); response = new MinimalResponse(HttpStatusCode.OK); } catch (SQLException e) { response = new ErrorResponse(HttpStatusCode.INTERNAL_SERVER_ERROR, "Creation of user '" + username + "' unsuccessful due " + "to temporary database problems."); Debug.log("Reason: " + e.getMessage()); } catch (IOException e) { response = new ErrorResponse(HttpStatusCode.BAD_REQUEST, "Creation of user '" + username + "' unsuccessful. " + e.getMessage()); } finally { if (db != null) db.close(); } return response; }
Source:
<code>public UserDto addUser(UserDto user, Optional<String> overwriteUserConfirmationCode) { <START> assert user.getPrivateData().getDevices().orElse(Collections.emptySet()).size() == 1; <END> UserLookupService.assertValidUserFields(user, UserService.UserPurpose.USER); handleExistingUserForMobileNumber(user.getMobileNumber(), overwriteUserConfirmationCode); User userEntity = createUserEntity(user, UserSignUp.FREE); addDevicesToEntity(user, userEntity); Optional<ConfirmationCode> confirmationCode = createConfirmationCodeIfNeeded(overwriteUserConfirmationCode, userEntity); userEntity = userRepository.save(userEntity); UserDto userDto = userLookupService.createUserDtoWithPrivateData(userEntity); if (confirmationCode.isPresent()) { userUpdateService.sendConfirmationCodeTextMessage(userEntity.getMobileNumber(), confirmationCode.get(), SmsTemplate.ADD_USER_NUMBER_CONFIRMATION); } logger.info("Added new user with mobile number '{}' and ID '{}'", userDto.getMobileNumber(), userDto.getId()); return userDto; }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') Replace this assert a proper check. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public UserDto addUser(UserDto user, Optional<String> overwriteUserConfirmationCode) { assert user.getPrivateData().getDevices().orElse(Collections.emptySet()).size() == 1; UserAssertionService.assertValidUserFields(user, UserService.UserPurpose.USER); handleExistingUserForMobileNumber(user.getMobileNumber(), overwriteUserConfirmationCode); User userEntity = createUserEntity(user, UserSignUp.FREE); addDevicesToEntity(user, userEntity); Optional<ConfirmationCode> confirmationCode = createConfirmationCodeIfNeeded(overwriteUserConfirmationCode, userEntity); userEntity = userRepository.save(userEntity); UserDto userDto = userLookupService.createUserDtoWithPrivateData(userEntity); if (confirmationCode.isPresent()) { userUpdateService.sendConfirmationCodeTextMessage(userEntity.getMobileNumber(), confirmationCode.get(), SmsTemplate.ADD_USER_NUMBER_CONFIRMATION); } logger.info("Added new user with mobile number '{}' and ID '{}'", userDto.getMobileNumber(), userDto.getId()); return userDto; }
Source:
<code>private VirtualMachineTemplate registerKubernetesVersionIso(final Long zoneId, final String versionName, final String isoUrl, final String isoChecksum)throws IllegalAccessException, NoSuchFieldException, IllegalArgumentException, ResourceAllocationException { String isoName = String.format("%s-Kubernetes-Binaries-ISO", versionName); RegisterIsoCmd registerIsoCmd = new RegisterIsoCmd(); registerIsoCmd = ComponentContext.inject(registerIsoCmd); Field f = registerIsoCmd.getClass().getDeclaredField("isoName"); f.setAccessible(true); f.set(registerIsoCmd, isoName); if (zoneId != null) { f = registerIsoCmd.getClass().getDeclaredField("zoneId"); f.setAccessible(true); f.set(registerIsoCmd, zoneId); } f = registerIsoCmd.getClass().getDeclaredField("displayText"); f.setAccessible(true); f.set(registerIsoCmd, isoName); f = registerIsoCmd.getClass().getDeclaredField("bootable"); f.setAccessible(true); f.set(registerIsoCmd, false); f = registerIsoCmd.getClass().getDeclaredField("publicIso"); f.setAccessible(true); f.set(registerIsoCmd, true); f = registerIsoCmd.getClass().getDeclaredField("url"); f.setAccessible(true); f.set(registerIsoCmd, isoUrl); if (!Strings.isNullOrEmpty(isoChecksum)) { f = registerIsoCmd.getClass().getDeclaredField("checksum"); f.setAccessible(true); f.set(registerIsoCmd, isoChecksum); } f = registerIsoCmd.getClass().getDeclaredField("accountName"); f.setAccessible(true); f.set(registerIsoCmd, accountManager.getSystemAccount().getAccountName()); f = registerIsoCmd.getClass().getDeclaredField("domainId"); f.setAccessible(true); f.set(registerIsoCmd, accountManager.getSystemAccount().getDomainId()); return templateService.registerIso(registerIsoCmd); <START> } <END></code><technical_language>I mist this before, i add setters add constructor instead of this tinkering access</technical_language>

Target:
private VirtualMachineTemplate registerKubernetesVersionIso(final Long zoneId, final String versionName, final String isoUrl, final String isoChecksum)throws IllegalAccessException, NoSuchFieldException, IllegalArgumentException, ResourceAllocationException { String isoName = String.format("%s-Kubernetes-Binaries-ISO", versionName); RegisterIsoCmd registerIsoCmd = new RegisterIsoCmd(); registerIsoCmd = ComponentContext.inject(registerIsoCmd); registerIsoCmd.setIsoName(isoName); registerIsoCmd.setPublic(true); if (zoneId != null) { registerIsoCmd.setZoneId(zoneId); } registerIsoCmd.setDisplayText(isoName); registerIsoCmd.setBootable(false); registerIsoCmd.setUrl(isoUrl); if (!Strings.isNullOrEmpty(isoChecksum)) { registerIsoCmd.setChecksum(isoChecksum); } registerIsoCmd.setAccountName(accountManager.getSystemAccount().getAccountName()); registerIsoCmd.setDomainId(accountManager.getSystemAccount().getDomainId()); return templateService.registerIso(registerIsoCmd); }
Source:
<code>public void draw(final BoundingBox boundingBox, final byte zoomLevel, final Canvas canvas, final Point topLeftPoint) { if (destinationCoords == null || currentCoords == null) { return; } if (line == null) { line = AndroidGraphicFactory.INSTANCE.createPaint(); line.setStrokeWidth(width); line.setStyle(Style.STROKE); line.setColor(0xD0EB391E); } final long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize()); final Geopoint[] routingPoints = Routing.getTrack(currentCoords, destinationCoords); final ArrayList<Pair<Integer, Integer>> pixelPoints = new ArrayList<>(); <START> for (final Geopoint geopoint : routingPoints) { <END> pixelPoints.add(translateToPixels(mapSize, topLeftPoint, geopoint)); } for (int i = 1; i < pixelPoints.size(); i++) { final Pair<Integer, Integer> source = pixelPoints.get(i - 1); final Pair<Integer, Integer> destination = pixelPoints.get(i); canvas.drawLine(source.first, source.second, destination.first, destination.second, line); } }</code><technical_language>routingPoints inlined well</technical_language>

Target:
public void draw(final BoundingBox boundingBox, final byte zoomLevel, final Canvas canvas, final Point topLeftPoint) { if (destinationCoords == null || currentCoords == null) { return; } if (line == null) { line = AndroidGraphicFactory.INSTANCE.createPaint(); line.setStrokeWidth(width); line.setStyle(Style.STROKE); line.setColor(0xD0EB391E); } final long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize()); final Geopoint[] routingPoints = Routing.getTrack(currentCoords, destinationCoords); final ArrayList<Pair<Integer, Integer>> pixelPoints = new ArrayList<>(routingPoints.length); for (final Geopoint geopoint : routingPoints) { pixelPoints.add(translateToPixels(mapSize, topLeftPoint, geopoint)); } for (int i = 1; i < pixelPoints.size(); i++) { final Pair<Integer, Integer> source = pixelPoints.get(i - 1); final Pair<Integer, Integer> destination = pixelPoints.get(i); canvas.drawLine(source.first, source.second, destination.first, destination.second, line); } }
Source:
<code>public static void setupCluster() throws IOException { <START> cluster = init(inst.builder() <END> .withNodes(2) .withConfig(c -> c.with(Feature.NETWORK) .with(Feature.GOSSIP) .set("disk_failure_policy", "die")) .start()); }</code><technical_language>making this case? in C* style guide do this java convention is upper case</technical_language>

Target:
public static void setupCluster() throws IOException { CLUSTER = init(Cluster.build() .withNodes(2) .withConfig(c -> c.with(Feature.NETWORK) .with(Feature.GOSSIP) .set("disk_failure_policy", "die")) .start()); }
Source:
<code>private void handleBinaryExpression(BinaryExpression binaryExpression, SubscriptionContext ctx) { boolean shouldReport = false; <START> if (binaryExpression.leftOperand().is(Tree.Kind.NAME, Tree.Kind.QUALIFIED_EXPR) && binaryExpression.rightOperand().is(Tree.Kind.STRING_LITERAL)) { <END> shouldReport = checkBinaryExpression(binaryExpression.leftOperand()); } if (binaryExpression.rightOperand().is(Tree.Kind.NAME, Tree.Kind.QUALIFIED_EXPR) && binaryExpression.leftOperand().is(Tree.Kind.STRING_LITERAL)) { shouldReport = checkBinaryExpression(binaryExpression.rightOperand()); } if (shouldReport) { ctx.addIssue(binaryExpression, MESSAGE); } }</code><technical_language>I statically import Tree.Kind</technical_language>

Target:
private void handleBinaryExpression(BinaryExpression binaryExpression, SubscriptionContext ctx) { boolean shouldReport = false; if (binaryExpression.leftOperand() instanceof HasSymbol && binaryExpression.rightOperand().is(Tree.Kind.STRING_LITERAL)) { shouldReport = isSymbolCredential(((HasSymbol) binaryExpression.leftOperand()).symbol()); } if (binaryExpression.rightOperand() instanceof HasSymbol && binaryExpression.leftOperand().is(Tree.Kind.STRING_LITERAL)) { shouldReport = isSymbolCredential(((HasSymbol) binaryExpression.rightOperand()).symbol()); } if (shouldReport) { ctx.addIssue(binaryExpression, MESSAGE); } }
Source:
<code>void maybeHandleDelayedWriteBookieFailure() { synchronized (metadataLock) { if (delayedWriteFailedBookies.isEmpty()) { return; } <START> Map<Integer, BookieSocketAddress> toReplace = new HashMap<>(); <END> toReplace.putAll(delayedWriteFailedBookies); delayedWriteFailedBookies.clear(); handleBookieFailure(toReplace); } }</code><technical_language>existing code construct hashmap delayedWriteFailedBookies. is line code. reason do split 2 lines</technical_language>

Target:
void maybeHandleDelayedWriteBookieFailure() { synchronized (metadataLock) { if (delayedWriteFailedBookies.isEmpty()) { return; } Map<Integer, BookieSocketAddress> toReplace = new HashMap<>(delayedWriteFailedBookies); delayedWriteFailedBookies.clear(); handleBookieFailure(toReplace); } }
Source:
<code>private void abortTask(Task task, TaskStatus status) { log.warn("[{}] Task found in unexpected state, switching to ", task.getId(), task, status); task.setStatus(status); Task removed = null; try { removed = schedulingPool.removeTask(task); } catch (TaskStoreException e) { log.error("[{}] Failed during removal of Task from SchedulingPool: {}", task.getId(), task, e); } if (removed != null) { try { jmsQueueManager.reportTaskStatus(task.getId(), task.getStatus(), System.currentTimeMillis()); } catch (JMSException e) { log.error("[{}] Error trying to reportTaskStatus of to Dispatcher: {}", task.getId(), task, e); } } else { log.error("[{}] Stale Task was not removed and not reported to dispatcher.", task.getId(), task); <START> log.warn(" - This is nonsense - why we abort the Task taken from AllTasks but we can remove it from it ??"); <END> } }</code><technical_language>This message is considered continuation of previous log message, sens level</technical_language>

Target:
private void abortTask(Task task, TaskStatus status) { log.warn("[{}] Task found in unexpected state, switching to ", task.getId(), task, status); task.setStatus(status); Task removed = null; try { removed = schedulingPool.removeTask(task); } catch (TaskStoreException e) { log.error("[{}] Failed during removal of Task from SchedulingPool: {}", task.getId(), task, e); } if (removed != null) { try { jmsQueueManager.reportTaskStatus(task.getId(), task.getStatus(), System.currentTimeMillis()); } catch (JMSException e) { log.error("[{}] Error trying to reportTaskStatus of to Dispatcher: {}", task.getId(), task, e); } } else { log.error("[{}] Stale Task was not removed and not reported to dispatcher.", task.getId(), task); log.error(" - This is nonsense - why we abort the Task taken from AllTasks but we can remove it from it ??"); } }
Source:
<code>private boolean elementHasJUnit4Annotations(AnnotatedElement element) { Annotation[] annotations = element.getAnnotations(); if (annotations != null) { for (Annotation a : annotations) { final String annotationName = a.annotationType() .getName(); <START> if (annotationName.startsWith("org.junit.") && !annotationName.contains(".jupiter.")) { <END> return true; } } } return false; }</code><technical_language>I if this is focused enough JUnit 4? some future JUnit 6 annotations start org.junit. do .jupiter.. mistaken. need a list of JUnit 4 annotation names in a collection ask collection if contains observed annotation name. "doesn't-contain-jupiter" test is future proof enough</technical_language>

Target:
private boolean elementHasJUnit4Annotations(AnnotatedElement element) { Annotation[] annotations = element.getAnnotations(); if (annotations == null) { return false; } return Stream.of(annotations) .map(Annotation::annotationType) .map(Class::getName) .anyMatch(JUNIT4_ANNOTATIONS::contains); }