#837 Fix "PIC SVPP9(5) COMP-3" when the scale factor is negative#838
#837 Fix "PIC SVPP9(5) COMP-3" when the scale factor is negative#838
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdjusts COMP-3 decimal decoding to correct decimal point placement when scaleFactor is negative (e.g., Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
JaCoCo code coverage report - 'cobol-parser'
|
JaCoCo code coverage report - 'spark-cobol'
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
cobol-parser/src/test/scala/za/co/absa/cobrix/cobol/parser/decoders/BinaryDecoderSpec.scala (1)
229-247: Strengthen regression assertions to exact matches.Using
containscan hide formatting regressions. For numeric decoder regressions, exact string equality is safer.Suggested diff
- assert (v1.contains("06547")) + assert(v1 == "06547") ... - assert (v2.contains("0.006547")) + assert(v2 == "0.006547") ... - assert (v3.contains("0.0006547")) + assert(v3 == "0.0006547") ... - assert (v4.contains("0.006547")) + assert(v4 == "0.006547") ... - assert (v5.contains("0.0006547")) + assert(v5 == "0.0006547") ... - assert (v6.contains("0.0016547")) + assert(v6 == "0.0016547")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cobol-parser/src/test/scala/za/co/absa/cobrix/cobol/parser/decoders/BinaryDecoderSpec.scala` around lines 229 - 247, The test uses contains() which can mask formatting regressions; update the assertions in the "Test COMP-3 decimal with scale factor cases" test to assert exact string equality for each decoded value returned by BCDNumberDecoders.decodeBigBCDNumber instead of contains; specifically assert that v1 == "06547", v2 == "0.006547", v3 == "0.0006547", v4 == "0.006547", v5 == "0.0006547", and v6 == "0.0016547" (use your project's preferred equality assertion helper such as assert(... == ...), assertResult, or shouldEqual).spark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/source/regression/Test17NumericConversions.scala (1)
285-321: Great regression coverage; minor test cleanup suggested.Nice end-to-end check for both COMP-3 and DISPLAY paths. You can avoid repeated collection by reading the first row once.
Suggested diff
- val actualData1 = df.collect()(0).getDecimal(0).toString - val actualData2 = df.collect()(0).getDecimal(1).toString + val row = df.collect().head + val actualData1 = row.getDecimal(0).toString + val actualData2 = row.getDecimal(1).toString🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@spark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/source/regression/Test17NumericConversions.scala` around lines 285 - 321, The test repeatedly calls df.collect()(0) to extract decimals into actualData1 and actualData2; change to collect the first row once (e.g., val row = df.collect()(0) or df.first()) and then derive actualData1 = row.getDecimal(0).toString and actualData2 = row.getDecimal(1).toString to avoid duplicate collection and improve efficiency; update references to df.collect()(0).getDecimal(...) accordingly (symbols: actualData1, actualData2, df.collect()(0).getDecimal).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@cobol-parser/src/test/scala/za/co/absa/cobrix/cobol/parser/decoders/BinaryDecoderSpec.scala`:
- Around line 229-247: The test uses contains() which can mask formatting
regressions; update the assertions in the "Test COMP-3 decimal with scale factor
cases" test to assert exact string equality for each decoded value returned by
BCDNumberDecoders.decodeBigBCDNumber instead of contains; specifically assert
that v1 == "06547", v2 == "0.006547", v3 == "0.0006547", v4 == "0.006547", v5 ==
"0.0006547", and v6 == "0.0016547" (use your project's preferred equality
assertion helper such as assert(... == ...), assertResult, or shouldEqual).
In
`@spark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/source/regression/Test17NumericConversions.scala`:
- Around line 285-321: The test repeatedly calls df.collect()(0) to extract
decimals into actualData1 and actualData2; change to collect the first row once
(e.g., val row = df.collect()(0) or df.first()) and then derive actualData1 =
row.getDecimal(0).toString and actualData2 = row.getDecimal(1).toString to avoid
duplicate collection and improve efficiency; update references to
df.collect()(0).getDecimal(...) accordingly (symbols: actualData1, actualData2,
df.collect()(0).getDecimal).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce297ac8-256f-4e0e-9896-c3826e25df4f
📒 Files selected for processing (4)
cobol-parser/src/main/scala/za/co/absa/cobrix/cobol/parser/decoders/BCDNumberDecoders.scalacobol-parser/src/test/scala/za/co/absa/cobrix/cobol/parser/copybooks/ParseCopybookFeaturesSpec.scalacobol-parser/src/test/scala/za/co/absa/cobrix/cobol/parser/decoders/BinaryDecoderSpec.scalaspark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/source/regression/Test17NumericConversions.scala
Closes #837
For
bytes:
Before
After
Summary by CodeRabbit
Bug Fixes
Tests