-
Notifications
You must be signed in to change notification settings - Fork 96
Add support for writing VB (variable block) COBOL files #867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -145,11 +145,21 @@ object CobolParametersValidator { | |||||||||||||||||||||||||||||||||||||||||||||||||
| def validateParametersForWriting(readerParameters: ReaderParameters): Unit = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val issues = new ListBuffer[String] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (readerParameters.recordFormat != RecordFormat.FixedLength && readerParameters.recordFormat != RecordFormat.VariableLength) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| issues += s"Only '${RecordFormat.FixedLength}' and '${RecordFormat.VariableLength}' values for 'record_format' are supported for writing, " + | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (readerParameters.recordFormat != RecordFormat.FixedLength && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| readerParameters.recordFormat != RecordFormat.VariableLength && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| readerParameters.recordFormat != RecordFormat.VariableBlock) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| issues += s"Only '${RecordFormat.FixedLength}', '${RecordFormat.VariableLength}' and '${RecordFormat.VariableBlock}' values for 'record_format' are supported for writing, " + | ||||||||||||||||||||||||||||||||||||||||||||||||||
| s"provided value: '${readerParameters.recordFormat}'" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (readerParameters.recordFormat == RecordFormat.VariableBlock) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val hasBlockLength = readerParameters.bdw.exists(_.blockLength.nonEmpty) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val hasRecordsPerBlock = readerParameters.bdw.exists(_.recordsPerBlock.nonEmpty) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!hasBlockLength && !hasRecordsPerBlock) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| issues += "Writing 'VB' records requires either 'records_per_block' or 'block_length' to be specified" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+155
to
+160
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Reject non-positive VB blocking values. This branch checks only option presence. It accepts Validate each defined value as positive and add tests for zero and negative values. Proposed fix if (readerParameters.recordFormat == RecordFormat.VariableBlock) {
+ readerParameters.bdw.foreach { bdw =>
+ bdw.blockLength.foreach { value =>
+ if (value <= 0) {
+ issues += "'block_length' must be a positive integer"
+ }
+ }
+ bdw.recordsPerBlock.foreach { value =>
+ if (value <= 0) {
+ issues += "'records_per_block' must be a positive integer"
+ }
+ }
+ }
val hasBlockLength = readerParameters.bdw.exists(_.blockLength.nonEmpty)
val hasRecordsPerBlock = readerParameters.bdw.exists(_.recordsPerBlock.nonEmpty)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (readerParameters.occursMappings.nonEmpty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| issues += "OCCURS mapping option ('occurs_mappings') is not supported for writing" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: AbsaOSS/cobrix
Length of output: 6603
🏁 Script executed:
Repository: AbsaOSS/cobrix
Length of output: 1503
🏁 Script executed:
Repository: AbsaOSS/cobrix
Length of output: 32804
Document the VB writer blocking behavior.
block_lengthandrecords_per_blockboth drive VB output, and both are required together for reading and exclusion, butREADME.mdstill lists them only underFBand omits the variable-record VB section. Update the options table/example text so users know either option is accepted forrecord_format = VBand only one may be specified.🤖 Prompt for AI Agents