auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private SsMediaSource(SsManifest manifest, Uri manifestUri, DataSource.Factory manifestDataSourceFactory, ParsingLoadable.Parser<? extends SsManifest> manifestParser, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) { Assertions.checkState(manifest == null || !manifest.isLive); this.manifest = manifest; <START> this.manifestUri = manifestUri == null ? null : lastPathSegment.contains("manifest") && lastPathSegment.contains("(") && lastPathSegment.contains(")")) ? manifestUri : lastPathSegment.equals("manifest") ? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest"); <END> this.manifestDataSourceFactory = manifestDataSourceFactory; this.manifestParser = manifestParser; this.chunkSourceFactory = chunkSourceFactory; this.minLoadableRetryCount = minLoadableRetryCount; this.livePresentationDelayMs = livePresentationDelayMs; this.eventDispatcher = new EventDispatcher(eventHandler, eventListener); mediaPeriods = new ArrayList<>(); }</code><technical_language>this compile? is lastPathSegment? defined anywhere. - convinced logic. matches kinds of random things, "xy)(manifest". Util.toLowerInvariant(manifestUri.getLastPathSegment()).matches("XXX") "XXX" is a regular expression more describes consider a match</technical_language>

Target:
private SsMediaSource(SsManifest manifest, Uri manifestUri, DataSource.Factory manifestDataSourceFactory, ParsingLoadable.Parser<? extends SsManifest> manifestParser, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) { Assertions.checkState(manifest == null || !manifest.isLive); this.manifest = manifest; String lastPathSegment = Util.toLowerInvariant(manifestUri.getLastPathSegment()); this.manifestUri = manifestUri == null ? null : lastPathSegment.equals("manifest") ? manifestUri : lastPathSegment.matches("manifest\\(.*\\)") ? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest"); this.manifestDataSourceFactory = manifestDataSourceFactory; this.manifestParser = manifestParser; this.chunkSourceFactory = chunkSourceFactory; this.minLoadableRetryCount = minLoadableRetryCount; this.livePresentationDelayMs = livePresentationDelayMs; this.eventDispatcher = new EventDispatcher(eventHandler, eventListener); mediaPeriods = new ArrayList<>(); }
Source:
<code>public DynamicUrlContentPresenter get() { if (presenter == null) { presenter = new DynamicUrlContentPresenter(getEventBus(), <START> new DynamicUrlContentView(), this, <END> slot); presenter.bind(); } presenter.setContentUrl(contentUrl); return presenter; }</code><technical_language>instantiate GWT View directly. Please add Provider<DynamicUrlContentView> parameter DynamicUrlContentProxy constructor. Note need define explicit binding in PresenterModule, GIN's default is "non-singleton" for just-in-time bindings</technical_language>

Target:
public DynamicUrlContentPresenter get() { if (presenter == null) { presenter = new DynamicUrlContentPresenter(contentUrl, getEventBus(), viewProvider.get(), this, slot); presenter.bind(); } return presenter; }
Source:
<code>void fillChunks() throws InterruptedException { try { PutChunk chunkToFill; if (!chunkFillingCompleted && !operationCompleted) { do { if (channelReadBuffer == null) { channelReadBuffer = chunkFillerChannel.getNextChunk(0); } if (channelReadBuffer != null) { chunkToFill = getChunkToFill(); if (chunkToFill == null) { break; } bytesFilledSoFar += chunkToFill.fillFrom(channelReadBuffer); if (!channelReadBuffer.hasRemaining()) { chunkFillerChannel.resolveOldestChunk(null); channelReadBuffer = null; } } else { break; } } while (bytesFilledSoFar < blobSize); if (bytesFilledSoFar == blobSize) { chunkFillingCompleted = true; } } } catch (InterruptedException e) { <START> throw e; <END> } catch (Exception e) { logger.error("Unexpected error caught in PutOperation fillChunks; ignoring.", e); routerMetrics.unexpectedErrorCount.inc(); setOperationException(new RouterException("PutOperation fillChunks encountered unexpected error", e, RouterErrorCode.UnexpectedInternalError)); } }</code><technical_language>why</technical_language>

Target:
void fillChunks() { try { PutChunk chunkToFill; if (!chunkFillingCompleted && !operationCompleted) { do { if (channelReadBuffer == null) { channelReadBuffer = chunkFillerChannel.getNextChunk(0); } if (channelReadBuffer != null) { chunkToFill = getChunkToFill(); if (chunkToFill == null) { break; } bytesFilledSoFar += chunkToFill.fillFrom(channelReadBuffer); if (!channelReadBuffer.hasRemaining()) { chunkFillerChannel.resolveOldestChunk(null); channelReadBuffer = null; } } else { break; } } while (bytesFilledSoFar < blobSize); if (bytesFilledSoFar == blobSize) { chunkFillingCompleted = true; } } } catch (Exception e) { setOperationExceptionAndComplete(new RouterException("PutOperation fillChunks encountered unexpected error", e, RouterErrorCode.UnexpectedInternalError)); } }
Source:
<code>K replacementTerm() { if (remainingCells.size() == 1) { <START> return KVariable(var.name(), var.att().remove("sort")); <END> } throw KEMException.compilerError("Unsupported cell fragment with types: " + remainingCells, var); }</code><technical_language>a lot of places strings instead of constants. Please fix all</technical_language>

Target:
K replacementTerm() { if (remainingCells.size() == 1) { return KVariable(var.name(), var.att().remove(Attribute.SORT_KEY)); } throw KEMException.compilerError("Unsupported cell fragment with types: " + remainingCells, var); }
Source:
<code>private static String formatDoubleAsCpuCost(double value) { if (value == Double.NEGATIVE_INFINITY) { return "-INF"; } <START> else if (value == Double.POSITIVE_INFINITY) { <END> return "+INF"; } else if(!isNaN(value)) { String formattedValue = DataSize.succinctDataSize(value, BYTE).toString(); return formattedValue.substring(0, formattedValue.length() - 1); } return "?"; }</code><technical_language>redundant else (here & below)</technical_language>

Target:
private static String formatDoubleAsCpuCost(double value) { return formatDoubleAsDataSize(value).replaceAll("B$", ""); }
Source:
<code>public ColumnPartSerde read(ByteBuffer buffer, ColumnBuilder builder) { final boolean isSingleValued = buffer.get() == 0x0; final GenericIndexed<String> dictionary = GenericIndexed.read(buffer, GenericIndexed.stringStrategy); final VSizeIndexedInts singleValuedColumn; final VSizeIndexed multiValuedColumn; builder.setType(ValueType.STRING); if (isSingleValued) { singleValuedColumn = VSizeIndexedInts.readFromByteBuffer(buffer); multiValuedColumn = null; builder.setHasMultipleValues(false) .setDictionaryEncodedColumn(new DictionaryEncodedColumnSupplier(dictionary, singleValuedColumn, null)); } else { singleValuedColumn = null; multiValuedColumn = VSizeIndexed.readFromByteBuffer(buffer); builder.setHasMultipleValues(true) .setDictionaryEncodedColumn(new DictionaryEncodedColumnSupplier(dictionary, null, multiValuedColumn)); } GenericIndexed<ImmutableConciseSet> bitmaps = GenericIndexed.read( buffer, ConciseCompressedIndexedInts.objectStrategy ); GenericIndexed<ImmutableRTree> spatialIndex = null; <START> if (buffer.hasRemaining()) { <END> spatialIndex = GenericIndexed.read( buffer, IndexedRTree.objectStrategy ); } builder.setBitmapIndex(new BitmapIndexColumnPartSupplier(bitmaps, dictionary)); builder.setSpatialIndex(new SpatialIndexColumnPartSupplier(spatialIndex)); return new DictionaryEncodedColumnPartSerde( dictionary, singleValuedColumn, multiValuedColumn, bitmaps, spatialIndex ); }</code><technical_language>I agree adding this DictionaryEncodedColumn. I a new class for this type of column..</technical_language>

Target:
public ColumnPartSerde read(ByteBuffer buffer, ColumnBuilder builder) { final boolean isSingleValued = buffer.get() == 0x0; final GenericIndexed<String> dictionary = GenericIndexed.read(buffer, GenericIndexed.stringStrategy); final VSizeIndexedInts singleValuedColumn; final VSizeIndexed multiValuedColumn; builder.setType(ValueType.STRING); if (isSingleValued) { singleValuedColumn = VSizeIndexedInts.readFromByteBuffer(buffer); multiValuedColumn = null; builder.setHasMultipleValues(false) .setDictionaryEncodedColumn(new DictionaryEncodedColumnSupplier(dictionary, singleValuedColumn, null)); } else { singleValuedColumn = null; multiValuedColumn = VSizeIndexed.readFromByteBuffer(buffer); builder.setHasMultipleValues(true) .setDictionaryEncodedColumn(new DictionaryEncodedColumnSupplier(dictionary, null, multiValuedColumn)); } GenericIndexed<ImmutableConciseSet> bitmaps = GenericIndexed.read( buffer, ConciseCompressedIndexedInts.objectStrategy ); builder.setBitmapIndex(new BitmapIndexColumnPartSupplier(bitmaps, dictionary)); ImmutableRTree spatialIndex = null; if (buffer.hasRemaining()) { spatialIndex = ByteBufferSerializer.read( buffer, IndexedRTree.objectStrategy ); builder.setSpatialIndex(new SpatialIndexColumnPartSupplier(spatialIndex)); } return new DictionaryEncodedColumnPartSerde( dictionary, singleValuedColumn, multiValuedColumn, bitmaps, spatialIndex ); }
Source:
<code><START> private boolean copyFile(File src, File dest) throws IOException { <END> InputStream destInput = null; OutputStream srcOutput = null; destInput = new FileInputStream(src); srcOutput = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = destInput.read(buffer)) > 0) { srcOutput.write(buffer, 0, length); } destInput.close(); srcOutput.close(); return true; }</code><technical_language>copyFile shoudn't return a boolean. return false I see.. If failure, expects exception caught</technical_language>

Target:
private void copyFile(File src, File dest) { InputStream destInput = null; OutputStream srcOutput = null; try { destInput = new FileInputStream(src); srcOutput = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = destInput.read(buffer)) != -1) { srcOutput.write(buffer, 0, length); } } catch (FileNotFoundException e) { openErroDialog(Messages.PerfSaveSession_failure_title, Messages.PerfSaveSession_failure_msg, dest.toString()); } catch (IOException e) { openErroDialog(Messages.PerfSaveSession_failure_title, Messages.PerfSaveSession_failure_msg, dest.toString()); } finally { closeResource(destInput, dest.getName()); closeResource(srcOutput, src.getName()); } }
Source:
<code>public Long evaluate(TransactionContext txnCtx, Input<Object>... args) { assert args.length == 2 : String.format(Locale.ENGLISH, "number of arguments must be 2, got %d instead", args.length); String zoneStr = (String) args[0].value(); if (zoneStr == null || zoneStr.isBlank()) { <START> throw new IllegalArgumentException(String.format(Locale.ENGLISH, <END> "invalid argument to %s: zone cannot be null or blanc", NAME)); } ZoneId zoneId = null; try { zoneId = ZoneId.of(zoneStr); } catch (DateTimeException e) { throw new IllegalArgumentException(String.format(Locale.ENGLISH, "invalid argument to %s: %s", NAME, zoneStr)); } Number utcTimestamp = (Number) args[1].value(); if (utcTimestamp == null) { throw new IllegalArgumentException(String.format(Locale.ENGLISH, "invalid argument to %s: timestamp cannot be null", NAME)); } Instant instant = Instant.ofEpochMilli(utcTimestamp.longValue()); ZoneId srcZoneId = paramHadTimezone ? zoneId : UTC; ZoneId dstZoneId = paramHadTimezone ? UTC : zoneId; ZonedDateTime zonedDateTime = instant.atZone(srcZoneId).withZoneSameLocal(dstZoneId); return zonedDateTime.toEpochSecond() * 1000; }</code><technical_language>In PostgreSQL a zone null results in null result</technical_language>

Target:
public Long evaluate(TransactionContext txnCtx, Input<Object>... args) { assert args.length == 2 : String.format(Locale.ENGLISH, "number of arguments must be 2, got %d instead", args.length); String zoneStr = (String) args[0].value(); if (zoneStr == null) { return null; } ZoneId zoneId; try { zoneId = ZoneId.of(zoneStr); } catch (DateTimeException e) { throw new IllegalArgumentException(String.format(Locale.ENGLISH, " time zone \"%s\" not recognized", zoneStr)); } Number utcTimestamp = (Number) args[1].value(); if (utcTimestamp == null) { return null; } Instant instant = Instant.ofEpochMilli(utcTimestamp.longValue()); boolean paramHadTimezone = info.returnType() == DataTypes.TIMESTAMP; ZoneId srcZoneId = paramHadTimezone ? zoneId : UTC; ZoneId dstZoneId = paramHadTimezone ? UTC : zoneId; ZonedDateTime zonedDateTime = instant.atZone(srcZoneId).withZoneSameLocal(dstZoneId); return zonedDateTime.toEpochSecond() * 1000; }
Source:
<code>public void endSuccessfully() { super.endSuccessfully(); if (getParameters().getImportAsTemplate()) { Guid newTemplateId = createTemplate(); if (newTemplateId != null) { attachDiskToTemplate(newTemplateId); } } updateDiskStatus(ImageStatus.OK); <START> getReturnValue().setSucceeded(true); <END> }</code><technical_language>please change setSucceeded</technical_language>

Target:
public void endSuccessfully() { super.endSuccessfully(); if (getParameters().getImportAsTemplate()) { Guid newTemplateId = createTemplate(); if (newTemplateId != null) { attachDiskToTemplate(newTemplateId); } } updateDiskStatus(ImageStatus.OK); setSucceeded(true); }
Source:
<code>public QueryRunner( ClientSession session, boolean debug, Optional<HostAndPort> socksProxy, Optional<HostAndPort> httpProxy, Optional<String> keystorePath, Optional<String> keystorePassword, Optional<String> truststorePath, Optional<String> truststorePassword, Optional<String> user, Optional<String> password, Optional<String> kerberosPrincipal, Optional<String> kerberosRemoteServiceName, Optional<String> kerberosConfigPath, Optional<String> kerberosKeytabPath, Optional<String> kerberosCredentialCachePath, boolean kerberosUseCanonicalHostname) { this.session = new AtomicReference<>(requireNonNull(session, "session is null")); this.debug = debug; this.sslSetup = builder -> setupSsl(builder, keystorePath, keystorePassword, truststorePath, truststorePassword); OkHttpClient.Builder builder = new OkHttpClient.Builder(); setupTimeouts(builder, 30, SECONDS); setupCookieJar(builder); setupSocksProxy(builder, socksProxy); setupHttpProxy(builder, httpProxy); setupBasicAuth(builder, session, user, password); <START> if (kerberosRemoteServiceName.isPresent()) { <END> checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using Kerberos requires SSL to be enabled"); setupKerberos( builder, kerberosRemoteServiceName.get(), kerberosUseCanonicalHostname, kerberosPrincipal, kerberosConfigPath.map(File::new), kerberosKeytabPath.map(File::new), kerberosCredentialCachePath.map(File::new)); } this.httpClient = builder.build(); }</code><technical_language>please extract adding this check a separate commit, especially requires thought</technical_language>

Target:
public QueryRunner( ClientSession session, boolean debug, Optional<HostAndPort> socksProxy, Optional<HostAndPort> httpProxy, Optional<String> keystorePath, Optional<String> keystorePassword, Optional<String> truststorePath, Optional<String> truststorePassword, Optional<String> user, Optional<String> password, Optional<String> kerberosPrincipal, Optional<String> kerberosRemoteServiceName, Optional<String> kerberosConfigPath, Optional<String> kerberosKeytabPath, Optional<String> kerberosCredentialCachePath, boolean kerberosUseCanonicalHostname) { this.session = new AtomicReference<>(requireNonNull(session, "session is null")); this.debug = debug; this.sslSetup = builder -> setupSsl(builder, keystorePath, keystorePassword, truststorePath, truststorePassword); OkHttpClient.Builder builder = new OkHttpClient.Builder(); setupTimeouts(builder, 30, SECONDS); setupCookieJar(builder); setupSocksProxy(builder, socksProxy); setupHttpProxy(builder, httpProxy); setupBasicAuth(builder, session, user, password); if (kerberosRemoteServiceName.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using Kerberos requires HTTPS to be enabled"); setupKerberos( builder, kerberosRemoteServiceName.get(), kerberosUseCanonicalHostname, kerberosPrincipal, kerberosConfigPath.map(File::new), kerberosKeytabPath.map(File::new), kerberosCredentialCachePath.map(File::new)); } this.httpClient = builder.build(); }
Source:
<code>private void throwCheckFailedException(Iterable<Class<?>> exceptionsThrown, Iterable<Class<?>> allowedExceptions) { throw newIllegalStateException( <START> "Method %s#%s throws prohibited exception types: %s. " + <END> "The allowed exception types for this method are: %s", method.getDeclaringClass() .getCanonicalName(), method.getName(), iterableToString(exceptionsThrown), iterableToString(allowedExceptions) ); }</code><technical_language>Please . syntax instead of #</technical_language>

Target:
private void throwCheckFailedException(Iterable<Class<?>> exceptionsThrown, Iterable<Class<?>> allowedExceptions) { throw newIllegalStateException( "Method %s.%s throws prohibited exception types: %s. " + "The allowed exception types for this method are: %s", method.getDeclaringClass() .getCanonicalName(), method.getName(), iterableToString(exceptionsThrown), iterableToString(allowedExceptions) ); }
Source:
<code>public static void main(String[] args) { SplashScreen.getInstance().post("Java Runtime " + System.getProperty("java.version") + " loaded"); handlePrintUsageRequest(args); handleLaunchArguments(args); try (final TerasologyEngine engine = new TerasologyEngine(createSubsystemList())) { if (!writeSaveGamesEnabled) { CoreRegistry.get(Config.class).getTransients().setWriteSaveGamesEnabled(writeSaveGamesEnabled); } <START> CoreRegistry.get(Config.class).getNetwork().setServerPort(serverPort); <END> if (isHeadless) { engine.subscribeToStateChange(new HeadlessStateChangeListener()); engine.run(new StateHeadlessSetup()); } else { if (loadLastGame) { engine.submitTask("loadGame", new Runnable() { @Override public void run() { GameManifest gameManifest = getLatestGameManifest(); if (gameManifest != null) { engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE)); } } }); } SplashScreen.getInstance().close(); engine.run(new StateMainMenu()); } } catch (Throwable e) { if (!GraphicsEnvironment.isHeadless()) { reportException(e); } } finally { SplashScreen.getInstance().close(); } }</code><technical_language>This effectively override config setting if -serverPort command line parameter is set. This moved handleLaunchArguments method. still, changes Config written file shutdown, happen. add entry TransientConfig (those values stored permanently) read base Config entry command line</technical_language>

Target:
public static void main(String[] args) { SplashScreen.getInstance().post("Java Runtime " + System.getProperty("java.version") + " loaded"); handlePrintUsageRequest(args); handleLaunchArguments(args); try (final TerasologyEngine engine = new TerasologyEngine(createSubsystemList())) { Config config = CoreRegistry.get(Config.class); if (!writeSaveGamesEnabled) { config.getTransients().setWriteSaveGamesEnabled(writeSaveGamesEnabled); } if (serverPort != -1) { config.getTransients().setServerPort(serverPort); } if (isHeadless) { engine.subscribeToStateChange(new HeadlessStateChangeListener()); engine.run(new StateHeadlessSetup()); } else { if (loadLastGame) { engine.submitTask("loadGame", new Runnable() { @Override public void run() { GameManifest gameManifest = getLatestGameManifest(); if (gameManifest != null) { engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE)); } } }); } SplashScreen.getInstance().close(); engine.run(new StateMainMenu()); } } catch (Throwable e) { if (!GraphicsEnvironment.isHeadless()) { reportException(e); } } finally { SplashScreen.getInstance().close(); } }
Source:
<code>public byte[] toBytes() { byte[] buf = null; switch (version) { case VERSION_0: int size = 2 * Short.BYTES + 2 * Long.BYTES; <START> if(latestBlobId != null) { <END> size += latestBlobId.length(); } buf = new byte[size]; ByteBuffer bufWrap = ByteBuffer.wrap(buf); bufWrap.putShort(version); bufWrap.putLong(latestUploadTime); bufWrap.putLong(bytesRead); if (latestBlobId != null) { bufWrap.putShort((short) latestBlobId.length()); bufWrap.put(latestBlobId.getBytes()); } else { bufWrap.putShort((short) 0); } break; case VERSION_3: size = 3 * Short.BYTES + 2 * Long.BYTES; if(latestBlobId != null) { size += latestBlobId.length(); } buf = new byte[size]; bufWrap = ByteBuffer.wrap(buf); bufWrap.putShort(version); bufWrap.putShort((short) type.ordinal()); bufWrap.putLong(latestUploadTime); bufWrap.putLong(bytesRead); if (latestBlobId != null) { bufWrap.putShort((short) latestBlobId.length()); bufWrap.put(latestBlobId.getBytes()); } else { bufWrap.putShort((short) 0); } break; default: throw new IllegalStateException("Unknown version: " + version); } return buf; }</code><technical_language>space paren</technical_language>

Target:
public byte[] toBytes() { byte[] buf = null; switch (version) { case VERSION_0: int size = 3 * Short.BYTES + 2 * Long.BYTES; if (latestBlobId != null) { size += latestBlobId.length(); } buf = new byte[size]; ByteBuffer bufWrap = ByteBuffer.wrap(buf); bufWrap.putShort(version); bufWrap.putShort((short) type.ordinal()); bufWrap.putLong(latestUploadTime); bufWrap.putLong(bytesRead); if (latestBlobId != null) { bufWrap.putShort((short) latestBlobId.length()); bufWrap.put(latestBlobId.getBytes()); } else { bufWrap.putShort((short) 0); } break; default: throw new IllegalStateException("Unknown version: " + version); } return buf; }
Source:
<code>private void endCommand() { List<VM> listVms = getVmsForDiskId(); for (VM vm : listVms) { getVmStaticDAO().incrementDbGeneration(vm.getId()); } <START> disk = getDiskDao().get((Guid) getParameters().getEntityId()); <END> Backend.getInstance().EndAction(VdcActionType.RemoveImage, getParameters().getImagesParameters().get(0)); setSucceeded(true); }</code><technical_language>consider of getDisk() logic exported contains line</technical_language>

Target:
private void endCommand() { List<VM> listVms = getVmsForDiskId(); for (VM vm : listVms) { getVmStaticDAO().incrementDbGeneration(vm.getId()); } getDisk(); Backend.getInstance().EndAction(VdcActionType.RemoveImage, getParameters().getImagesParameters().get(0)); setSucceeded(true); }
Source:
<code>public void andTest() throws Exception { AndClauseInTrigger clause = new AndClauseInTrigger( new EqualsClauseInTrigger("alias", "f1", "a"), <START> new EqualsClauseInTrigger("alias", "f2", 1)); <END> Parcel parcel = Parcel.obtain(); clause.writeToParcel(parcel, 0); parcel.setDataPosition(0); AndClauseInTrigger deserializedClause = AndClauseInTrigger.CREATOR.createFromParcel(parcel); Assert.assertTrue(Arrays.equals( clause.getClauses().toArray(), deserializedClause.getClauses().toArray())); }</code><technical_language>Adding types of clauses is more fine:)</technical_language>

Target:
public void andTest() throws Exception { AndClauseInTrigger clause = new AndClauseInTrigger( new EqualsClauseInTrigger("alias", "f1", "a"), new NotEqualsClauseInTrigger( new EqualsClauseInTrigger("alias", "f2", 1)), RangeClauseInTrigger.greaterThan("alias", "f3", 23), RangeClauseInTrigger.lessThan("alias", "f3", 230), RangeClauseInTrigger.range("alias", "f4", 11, true, 23, false)); Parcel parcel = Parcel.obtain(); clause.writeToParcel(parcel, 0); parcel.setDataPosition(0); AndClauseInTrigger deserializedClause = AndClauseInTrigger.CREATOR.createFromParcel(parcel); Assert.assertTrue(Arrays.equals( clause.getClauses().toArray(), deserializedClause.getClauses().toArray())); }
Source:
<code>public Void visitStatisticsWriterNode(StatisticsWriterNode node, Set<Symbol> boundSymbols) { node.getSource().accept(this, boundSymbols); <START> return null; <END> }</code><technical_language>validate if symbols StatisticAggregationsDescriptor present in child output symbols</technical_language>

Target:
public Void visitStatisticsWriterNode(StatisticsWriterNode node, Set<Symbol> boundSymbols) { node.getSource().accept(this, boundSymbols); StatisticAggregationsDescriptor<Symbol> descriptor = node.getDescriptor(); Set<Symbol> dependencies = ImmutableSet.<Symbol>builder() .addAll(descriptor.getGrouping().values()) .addAll(descriptor.getColumnStatistics().values()) .addAll(descriptor.getTableStatistics().values()) .build(); List<Symbol> outputSymbols = node.getSource().getOutputSymbols(); checkDependencies(dependencies, dependencies, "Invalid node. Dependencies (%s) not in source plan output (%s)", dependencies, outputSymbols); return null; }
Source:
<code>public boolean isUserDefined() { return Arrays.asList( <START> context.getNode(ContentType.PREF_USER_DEFINED) <END> .get(ContentType.PREF_USER_DEFINED, ContentType.EMPTY_STRING) .split(ContentType.PREF_USER_DEFINED__SEPARATOR)) .contains(contentType.getId()); }</code><technical_language>utility function for this repeated block of code</technical_language>

Target:
public boolean isUserDefined() { return Arrays.asList(ContentTypeManager.getUserDefinedContentTypeIds(context)).contains(contentType.getId()); }
Source:
<code>public void addService(Object... service) { for (Object svc : service) { services.put(svc.getClass().getAnnotation(Path.class).value(), svc); } updateMetadata(); <START> Arrays.stream(service).forEach(svc -> { <END> if (log.isDebugEnabled()) { log.debug("Added microservice: " + svc); } }); }</code><technical_language>wrap loop log.isDebugEnabled() java if(log.isDebugEnabled()) { Arrays.stream(service).forEach(svc -> log.debug("Added microservice {}. ", svc)); }</technical_language>

Target:
public void addService(Object... service) { for (Object svc : service) { services.put(svc.getClass().getAnnotation(Path.class).value(), svc); } updateMetadata(); if (log.isDebugEnabled()) { Arrays.stream(service).forEach(svc -> log.debug("Added microservice: {}.", svc)); } }
Source:
<code>public void concurrentModificationEmptyAsyncRealmObject() { final Realm realm = looperThread.realm; Dog dog1 = new Dog(); dog1.setName("Dog 1"); Dog dog2 = new Dog(); dog2.setName("Dog 2"); realm.beginTransaction(); dog1 = realm.copyToRealm(dog1); dog2 = realm.copyToRealm(dog2); realm.commitTransaction(); final WeakReference<RealmObjectProxy> weakReference1 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog1); final WeakReference<RealmObjectProxy> weakReference2 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog2); final RealmQuery<Dog> dummyQuery = RealmQuery.createQuery(realm, Dog.class); <START> looperThread.realm.handlerController.emptyAsyncRealmObject.put(weakReference1, dummyQuery); <END> final CountDownLatch dogAddFromBg = new CountDownLatch(1); Iterator<Map.Entry<WeakReference<RealmObjectProxy>, RealmQuery<? extends RealmModel>>> iterator = looperThread.realm.handlerController.emptyAsyncRealmObject.entrySet().iterator(); AtomicBoolean fireOnce = new AtomicBoolean(true); while (iterator.hasNext()) { Dog next = (Dog) iterator.next().getKey().get(); if (fireOnce.compareAndSet(true, false)) { new Thread() { @Override public void run() { looperThread.realm.handlerController.emptyAsyncRealmObject.put(weakReference2, dummyQuery); dogAddFromBg.countDown(); } }.start(); TestHelper.awaitOrFail(dogAddFromBg); } assertEquals("Dog 1", next.getName()); } looperThread.testComplete(); }</code><technical_language>realm instead of looperthread.realm, in multiple places</technical_language>

Target:
public void concurrentModificationEmptyAsyncRealmObject() { RealmConfiguration config = configFactory.createConfiguration(); final Realm realm = Realm.getInstance(config); Dog dog1 = new Dog(); dog1.setName("Dog 1"); Dog dog2 = new Dog(); dog2.setName("Dog 2"); realm.beginTransaction(); dog1 = realm.copyToRealm(dog1); dog2 = realm.copyToRealm(dog2); realm.commitTransaction(); final WeakReference<RealmObjectProxy> weakReference1 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog1); final WeakReference<RealmObjectProxy> weakReference2 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog2); final RealmQuery<Dog> dummyQuery = RealmQuery.createQuery(realm, Dog.class); realm.handlerController.emptyAsyncRealmObject.put(weakReference1, dummyQuery); final CountDownLatch dogAddFromBg = new CountDownLatch(1); Iterator<Map.Entry<WeakReference<RealmObjectProxy>, RealmQuery<? extends RealmModel>>> iterator = realm.handlerController.emptyAsyncRealmObject.entrySet().iterator(); AtomicBoolean fireOnce = new AtomicBoolean(true); while (iterator.hasNext()) { Dog next = (Dog) iterator.next().getKey().get(); if (fireOnce.compareAndSet(true, false)) { new Thread() { @Override public void run() { realm.handlerController.emptyAsyncRealmObject.put(weakReference2, dummyQuery); dogAddFromBg.countDown(); } }.start(); TestHelper.awaitOrFail(dogAddFromBg); } assertEquals("Dog 1", next.getName()); assertFalse(iterator.hasNext()); } realm.close(); }
Source:
<code>public static Archive<?> deploy() { WebArchive war = TestUtil.prepareArchive(RestClientProxyTest.class.getSimpleName()); war.addClass(RestClientProxyTest.class); war.addClass(HelloResource.class); war.addClass(HeaderPropagator.class); war.addPackage(HelloResource.class.getPackage()); war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); war.addClass(PortProviderUtil.class); war.addClass(Category.class); war.addClass(MicroProfileDependent.class); <START> war.addClass(NotForBootableJar.class); <END> war.addClasses(TestParamConverter.class, TestParamConverterProvider.class); war.addAsManifestResource(new StringAsset("Dependencies: org.eclipse.microprofile.restclient,org.jboss.resteasy.resteasy-rxjava2 services\n"), "MANIFEST.MF"); return TestUtil.finishContainerPrepare(war, null); }</code><technical_language>is this annotation added here</technical_language>

Target:
public static Archive<?> deploy() { WebArchive war = TestUtil.prepareArchive(RestClientProxyTest.class.getSimpleName()); war.addClass(RestClientProxyTest.class); war.addClass(HelloResource.class); war.addClass(HeaderPropagator.class); war.addPackage(HelloResource.class.getPackage()); war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); war.addClass(PortProviderUtil.class); war.addClass(Category.class); war.addClass(MicroProfileDependent.class); war.addClasses(TestParamConverter.class, TestParamConverterProvider.class); war.addAsManifestResource(new StringAsset("Dependencies: org.eclipse.microprofile.restclient,org.jboss.resteasy.resteasy-rxjava2 services\n"), "MANIFEST.MF"); return TestUtil.finishContainerPrepare(war, null); }
Source:
<code><START> private void handleBlockExit(ExplodedGraph.ProgramPoint programPosition) { <END> CFG.Block block = programPosition.block; if (block.terminator() != null) { switch (block.terminator().kind()) { case IF_STATEMENT: handleBranch(block, ((IfStatementTree) block.terminator()).condition()); return; case CONDITIONAL_OR: case CONDITIONAL_AND: handleBranch(block, ((BinaryExpressionTree) block.terminator()).leftOperand()); return; case CONDITIONAL_EXPRESSION: handleBranch(block, ((ConditionalExpressionTree) block.terminator()).condition()); return; case FOR_STATEMENT: ForStatementTree forStatement = (ForStatementTree) block.terminator(); if (forStatement.condition() != null) { handleBranch(block, forStatement.condition(), false); return; } } } for (CFG.Block successor : block.successors()) { enqueue(new ExplodedGraph.ProgramPoint(successor, 0), programState); } }</code><technical_language>![MAJOR](<LINK_1> Cyclomatic Complexity of this method "handleBlockExit" is 13 is greater 10 authorized. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
private void handleBlockExit(ExplodedGraph.ProgramPoint programPosition) { CFG.Block block = programPosition.block; Tree terminator = block.terminator(); if (terminator != null) { switch (terminator.kind()) { case IF_STATEMENT: handleBranch(block, ((IfStatementTree) terminator).condition()); return; case CONDITIONAL_OR: case CONDITIONAL_AND: handleBranch(block, ((BinaryExpressionTree) terminator).leftOperand()); return; case CONDITIONAL_EXPRESSION: handleBranch(block, ((ConditionalExpressionTree) terminator).condition()); return; case FOR_STATEMENT: ForStatementTree forStatement = (ForStatementTree) terminator; if (forStatement.condition() != null) { handleBranch(block, forStatement.condition(), false); return; } default: } } for (CFG.Block successor : block.successors()) { enqueue(new ExplodedGraph.ProgramPoint(successor, 0), programState); } }
Source:
<code>private static List<DivType> getDivTypesByFileTypes(List<FileType> fileTypes) { List<DivType> divTypes = new ArrayList<>(); int counter = 1; for (FileType file : fileTypes) { DivType div = objectFactory.createDivType(); div.setID("PHYS_" + String.format("%04d", counter)); div.setORDER(BigInteger.valueOf(counter)); <START> div.setORDERLABEL("uncounted"); <END> div.setTYPE(getPhysicalDivTypeByFileType(file)); DivType.Fptr divTypeFptr = objectFactory.createDivTypeFptr(); divTypeFptr.setFILEID(file); div.getFptr().add(divTypeFptr); divTypes.add(div); counter++; } return divTypes; }</code><technical_language>Setting ORERLABEL hard coded uncounted is wrong if setting in kitodo_config.properties is set different. Add a TODO for this hard coded value</technical_language>

Target:
private static List<DivType> getDivTypesByFileTypes(List<FileType> fileTypes) { List<DivType> divTypes = new ArrayList<>(); int counter = 1; for (FileType file : fileTypes) { DivType div = objectFactory.createDivType(); div.setID("PHYS_" + String.format("%04d", counter)); div.setORDER(BigInteger.valueOf(counter)); div.setORDERLABEL(Config.getParameter("MetsEditorDefaultPagination")); div.setTYPE(getPhysicalDivTypeByFileType(file)); DivType.Fptr divTypeFptr = objectFactory.createDivTypeFptr(); divTypeFptr.setFILEID(file); div.getFptr().add(divTypeFptr); divTypes.add(div); counter++; } return divTypes; }
Source:
<code>private String getDstRef(Repository repo, boolean launchFetch) { if (launchFetch) { String realName = getRealBranchName(repo); String name = BRANCH_NAME_PATTERN.matcher(realName).replaceAll(""); StoredConfig config = repo.getConfig(); String remote = config.getString(CONFIG_BRANCH_SECTION, name, CONFIG_KEY_REMOTE); String merge = config.getString(CONFIG_BRANCH_SECTION, name, CONFIG_KEY_MERGE); if (remote == null || merge == null) return HEAD; String mergeBranchName = merge.substring( <START> merge.lastIndexOf("/"), merge.length()); END> return R_REMOTES + remote + mergeBranchName; } else return HEAD; }</code><technical_language>I this is correct for branches path segment, for hierarchical branch names "refs/heads/feature/xyz" yields wrong results, for this example end mergeBranchName = "/xyz" instead of "/feature/xyz". variable name is a bit misleading this starts a leading slash common for a branch name</technical_language>

Target:
private String getDstRef(Repository repo, boolean launchFetch) { if (launchFetch) { String realName = getRealBranchName(repo); String name = BRANCH_NAME_PATTERN.matcher(realName).replaceAll(""); StoredConfig config = repo.getConfig(); String remote = config.getString(CONFIG_BRANCH_SECTION, name, CONFIG_KEY_REMOTE); String merge = config.getString(CONFIG_BRANCH_SECTION, name, CONFIG_KEY_MERGE); if (remote == null || merge == null) return HEAD; String mergeBranchName = merge.replace(R_HEADS, ""); return R_REMOTES + remote + "/" + mergeBranchName; } else return HEAD; }
Source:
<code>public void saveValue(String metricId, Number value, long timeStamp) { LogWriter logWriter = context.getService(LogWriter.class); try { metricId = URLEncoder.encode(metricId, "UTF-8"); logWriter.log(sessionId, taskId + File.separatorChar + METRIC_MARKER + File.separatorChar + metricId, context.getId().getIdentifier(), new MetricLogEntry(timeStamp, metricId, value)); } catch (UnsupportedEncodingException e) { <START> log.error("Can't save metric value with id="+metricId, e); <END> } }</code><technical_language>spaces</technical_language>

Target:
public void saveValue(String metricId, Number value, long timeStamp) { LogWriter logWriter = context.getService(LogWriter.class); try { metricId = URLEncoder.encode(metricId, "UTF-8"); logWriter.log(sessionId, taskId + File.separatorChar + METRIC_MARKER + File.separatorChar + metricId, context.getId().getIdentifier(), new MetricLogEntry(timeStamp, metricId, value)); } catch (UnsupportedEncodingException e) { log.error("Can't save metric value with id={}", metricId, e); } }
Source:
<code>public static void restoreSystemProperties() { <START> System.setProperty("org.uberfire.nio.git.daemon.enabled", gitDaemonEnabled); <END> System.setProperty("org.uberfire.nio.git.ssh.enabled", gitSshEnabled); }</code><technical_language>here: System.clearProperty(..) instead of complicating tests restore previous values</technical_language>

Target:
public static void restoreSystemProperties() { System.clearProperty("org.uberfire.nio.git.daemon.enabled"); System.clearProperty("org.uberfire.nio.git.ssh.enabled"); }
Source:
<code>public Future<Void> send(final ByteBuffer buffer) { LOG.info("Sending"); LOG.info("local address {}", session.channel().localAddress()); LOG.info("remote address {}", session.channel().remoteAddress()); final BinaryWebSocketFrame frame = new BinaryWebSocketFrame(Unpooled.copiedBuffer(buffer)); LOG.info("Frame: {}", frame); final ChannelFuture future = session.channel().write(frame); future.addListener(new GenericProgressiveFutureListener<ProgressiveFuture<Void>>() { @SuppressWarnings("PMD.CommentRequired") @Override public void operationProgressed(final ProgressiveFuture future, final long progress, final long total) { <START> LOG.info("huh? {}, {}", progress, total); <END> } @Override public void operationComplete(final ProgressiveFuture future) { LOG.info("COMPELTE"); } }); return future; }</code><technical_language>change "huh?" "current progress in sending message"</technical_language>

Target:
public Future<Void> send(final ByteBuffer buffer) { LOG.info("Sending"); LOG.info("local address {}", session.channel().localAddress()); LOG.info("remote address {}", session.channel().remoteAddress()); final BinaryWebSocketFrame frame = new BinaryWebSocketFrame(Unpooled.copiedBuffer(buffer)); LOG.info("Frame: {}", frame); final ChannelFuture future = session.channel().write(frame); future.addListener(new GenericProgressiveFutureListener<ProgressiveFuture<Void>>() { @SuppressWarnings("PMD.CommentRequired") @Override public void operationProgressed(final ProgressiveFuture future, final long progress, final long total) { LOG.info("current progress in sending message {}, {}", progress, total); } @Override public void operationComplete(final ProgressiveFuture future) { LOG.info("COMPELTE"); } }); return future; }
Source:
<code>public Long getPropertyLongObject(String propertyFileName, String propertyName, Long defaultValue) throws <START> PropertyAccessException { <END> PropertiesConfiguration properties = propertyFilesHashmap.get(propertyFileName); if (properties != null && properties.containsKey(propertyName)) { try { return properties.getLong(propertyName, defaultValue); } catch (ConversionException ex) { throw new PropertyAccessException("Could not convert property value to long for: " + propertyName, ex); } } throw new PropertyAccessException(getErrorMessage(propertyFileName, propertyName)); }</code><technical_language>throwing exception if defaultValue</technical_language>

Target:
public Long getPropertyLongObject(String propertyFileName, String propertyName, Long defaultValue) { PropertiesConfiguration properties = propertyFilesHashmap.get(propertyFileName); if (properties != null && properties.containsKey(propertyName)) { try { return properties.getLong(propertyName, defaultValue); } catch (ConversionException ex) { LOG.error("Could not convert property value to long for: ", propertyName, ex); } } return defaultValue; }
Source:
<code>public String getDescription(Object element) { StringBuilder result = new StringBuilder(getText(element)); if (element instanceof RefNode) { Ref ref = ((RefNode) element).getObject(); String branchName = Repository.shortenRefName(ref.getName()); result = new StringBuilder(branchName); } if (element instanceof RepositoryGroupNode) { RepositoryGroup group = ((RepositoryGroupNode) element).getGroup(); result.append(" (").append(group.getRepositoryDirectories().size()) <START> .append(")"); END> } else if (element instanceof RepositoryTreeNode) { if (((RepositoryTreeNode) element) .getType() != RepositoryTreeNodeType.REPO) { Repository repo = ((RepositoryTreeNode) element) .getRepository(); result.append(" [").append(GitLabels.getPlainShortLabel(repo)) .append(']'); } } return result.toString(); }</code><technical_language>append(')') here; avoids need for NON-NLS</technical_language>

Target:
public String getDescription(Object element) { StringBuilder result = new StringBuilder(getText(element)); if (element instanceof RefNode) { Ref ref = ((RefNode) element).getObject(); String branchName = Repository.shortenRefName(ref.getName()); result = new StringBuilder(branchName); } if (element instanceof RepositoryGroupNode) { RepositoryGroup group = ((RepositoryGroupNode) element).getGroup(); result.append(" (").append(group.getRepositoryDirectories().size()) .append(')'); } else if (element instanceof RepositoryTreeNode) { if (((RepositoryTreeNode) element) .getType() != RepositoryTreeNodeType.REPO) { Repository repo = ((RepositoryTreeNode) element) .getRepository(); result.append(" [").append(GitLabels.getPlainShortLabel(repo)) .append(']'); } } return result.toString(); }
Source:
<code>public void stop() { if (manager != null) { manager.stop(); manager = null; sysInjector = null; sshInjector = null; httpInjector = null; if (webPluginDir != null) { try { <START> FileUtils.delete(webPluginDir, FileUtils.RECURSIVE); <END> } catch (IOException e) { } } } }</code><technical_language>necessary, remove this</technical_language>

Target:
public void stop() { if (manager != null) { manager.stop(); manager = null; sysInjector = null; sshInjector = null; httpInjector = null; } }
Source:
<code>private static void updateJsonArrayDataNodesRackAware(JSONArray dataNodeJsonArray, int dataNodeCount, String hostname, int basePort, int sslPort, int numRacks, HardwareState hardwareState, JSONArray disks) throws JSONException { for (int i = dataNodeJsonArray.length(); i < dataNodeCount; ++i) { dataNodeJsonArray.put( <START> getJsonDataNode(hostname, basePort + i, sslPort + i, i % numRacks, 64, hardwareState, disks)); <END> } }</code><technical_language>a constant beginning of this file? apply in places</technical_language>

Target:
private static void updateJsonArrayDataNodesRackAware(JSONArray dataNodeJsonArray, int dataNodeCount, String hostname, int basePort, int sslPort, int numRacks, HardwareState hardwareState, JSONArray disks) throws JSONException { for (int i = dataNodeJsonArray.length(); i < dataNodeCount; ++i) { dataNodeJsonArray.put( getJsonDataNode(hostname, basePort + i, sslPort + i, i % numRacks, DEFAULT_XID, hardwareState, disks)); } }
Source:
<code>public void testGetAlertCountWithMultipleAlert() throws JsonProcessingException { Assert.assertEquals(0, alertRepo.getAlertCount()); final Transaction transaction = Ebean.beginTransaction(); try { final models.ebean.Alert ebeanAlert1 = new models.ebean.Alert(); <START> ebeanAlert1.setNagiosExtension(TEST_NAGIOS_EXTENSIONS); <END> ebeanAlert1.setName(TEST_NAME); ebeanAlert1.setOperator(TEST_OPERATOR); ebeanAlert1.setPeriod(TEST_PERIOD_IN_SECONDS); ebeanAlert1.setStatistic(TEST_STATISTIC); ebeanAlert1.setQuantityValue(TEST_QUANTITY_VALUE); ebeanAlert1.setQuantityUnit(TEST_QUANTITY_UNIT); ebeanAlert1.setCluster(TEST_CLUSTER); ebeanAlert1.setUuid(UUID.randomUUID()); ebeanAlert1.setMetric(TEST_METRIC); ebeanAlert1.setContext(TEST_CONTEXT); ebeanAlert1.setService(TEST_SERVICE); Ebean.save(ebeanAlert1); final models.ebean.Alert ebeanAlert2 = new models.ebean.Alert(); ebeanAlert2.setNagiosExtension(TEST_NAGIOS_EXTENSIONS); ebeanAlert2.setName(TEST_NAME); ebeanAlert2.setOperator(TEST_OPERATOR); ebeanAlert2.setPeriod(TEST_PERIOD_IN_SECONDS); ebeanAlert2.setStatistic(TEST_STATISTIC); ebeanAlert2.setQuantityValue(TEST_QUANTITY_VALUE); ebeanAlert2.setQuantityUnit(TEST_QUANTITY_UNIT); ebeanAlert2.setCluster(TEST_CLUSTER); ebeanAlert2.setUuid(UUID.randomUUID()); ebeanAlert2.setMetric(TEST_METRIC); ebeanAlert2.setContext(TEST_CONTEXT); ebeanAlert2.setService(TEST_SERVICE); Ebean.save(ebeanAlert2); transaction.commit(); } finally { transaction.end(); } Assert.assertEquals(2, alertRepo.getAlertCount()); }</code><technical_language>If a some of patterns for creating instances for test provide a TestBeanFactory allows creation of instances default random values in fields. Tests set fields care about</technical_language>

Target:
public void testGetAlertCountWithMultipleAlert() throws JsonProcessingException { Assert.assertEquals(0, alertRepo.getAlertCount()); final Transaction transaction = Ebean.beginTransaction(); try { final models.ebean.Alert ebeanAlert1 = TestBeanFactory.createEbeanAlert(); ebeanAlert1.setUuid(UUID.randomUUID()); Ebean.save(ebeanAlert1); final models.ebean.Alert ebeanAlert2 = TestBeanFactory.createEbeanAlert(); ebeanAlert2.setUuid(UUID.randomUUID()); Ebean.save(ebeanAlert2); transaction.commit(); } finally { transaction.end(); } Assert.assertEquals(2, alertRepo.getAlertCount()); }
Source:
<code>private static SerialPort connect(String portName, int baudRate) { try { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if ( portIdentifier.isCurrentlyOwned() ) { System.err.println("Error: Port currently in use"); } else { <START> CommPort commPort = portIdentifier.open(portName, 2000); <END> if ( commPort instanceof SerialPort ) { SerialPort serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(baudRate,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); return serialPort; } } } catch (Exception e) { System.err.println("Error: Unable to connect to port" + portName); } return null; }</code><technical_language>remove magic number, a static final int defined top of file instead</technical_language>

Target:
private static SerialPort connect(String portName, int baudRate) { try { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if ( portIdentifier.isCurrentlyOwned() ) { System.err.println("Error: Port currently in use"); } else { CommPort commPort = portIdentifier.open(portName, TIMEOUT); if ( commPort instanceof SerialPort ) { SerialPort serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(baudRate,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); return serialPort; } } } catch (Exception e) { System.err.println("Error: Unable to connect to port" + portName); } return null; }
Source:
<code>public double calculateStandardizedValue(final long meterValue, final ScalerUnitResponse scalerUnitResponse) { final ScalerUnit scalerUnit = scalerUnitResponse.getScalerUnit(); final double multiplier = this.getMultiplierToOsgpUnit(scalerUnit.getDlmsUnit()); final double power = scalerUnit.getScaler() == 0 ? 1 : Math.pow(10, scalerUnit.getScaler()); final double calculated = round((meterValue / power) * multiplier, this.fraction_digits); <START> LOGGER.debug(String.format("calcualted %s from %s using %s", calculated, meterValue, scalerUnit)); <END> return calculated; }</code><technical_language>LOGGER.debug("calculated {}", calculated, meterValue, scalerUnit); typo in "calculated"</technical_language>

Target:
public double calculateStandardizedValue(final long meterValue, final ScalerUnitResponse scalerUnitResponse) { final ScalerUnit scalerUnit = scalerUnitResponse.getScalerUnit(); final double multiplier = this.getMultiplierToOsgpUnit(scalerUnit.getDlmsUnit()); final double power = scalerUnit.getScaler() == 0 ? 1 : Math.pow(10, scalerUnit.getScaler()); final double calculated = round((meterValue / power) * multiplier, this.fractionDigits); LOGGER.debug(String.format("calculated %s from %s using %s", calculated, meterValue, scalerUnit)); return calculated; }