aglinxinyuan commented on code in PR #4919:
URL: https://github.com/apache/texera/pull/4919#discussion_r3193724895


##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/lineChart/LineChartOpDesc.scala:
##########
@@ -64,7 +64,9 @@ class LineChartOpDesc extends PythonOperatorDescriptor {
     )
 
   def createPlotlyFigure(): PythonTemplateBuilder = {
-    val linesPart = lines.asScala
+    val configuredLines = Option(lines).getOrElse(new 
util.ArrayList[LineConfig]())
+    assert(configuredLines.asScala.nonEmpty, "At least one line must be 
configured")
+    val linesPart = configuredLines.asScala

Review Comment:
   Style nit (optional, not a blocker): the default-value + null-guard + 
non-empty assertion is slightly belt-and-braces. Since `lines` is an external 
mutable field, the contract that matters is just "non-null and non-empty," 
which collapses to a single assertion at the top:
   
   ```scala
   def createPlotlyFigure(): PythonTemplateBuilder = {
     assert(lines != null && !lines.isEmpty, "At least one line must be 
configured")
     val linesPart = lines.asScala.map { ... }
   ```
   
   That avoids the unused empty-list allocation on the null path and the double 
`.asScala` wrap. The current form is correct — just a bit easier to read this 
way.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to