Skip to content

Conversation

@yutaro-sakamoto
Copy link
Contributor

This pull request implements create command of cobj-idx.
The following is a usage of this new command.

cobj-idx create <indexed file> --size=<record size> --key=<key information>
    Create a new indexed file.
    The record size and key information are specified by the options.
    By default, this command does not overwrite the indexed file.
    To overwrite the indexed file, use the --new option.
    Example) cobj-idx create test.idx --size=100 --key=2,2:5,4:d15,5
             File name: test.idx
             Record size: 100
             Primary key: 2-3
             Alternate key (No Duplicates):5-8
             Alternate key (Duplicates): 15-19

yutaro-sakamoto and others added 30 commits May 15, 2025 01:52
…ser_util/indexed_file/IndexedFileUtilMain.java

Co-authored-by: Copilot <[email protected]>
…ser_util/indexed_file/IndexedFileUtilMain.java

Co-authored-by: Copilot <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new "create" command to the cobj-idx tool including tests, Java command parsing, and file creation logic.

  • Implements the creation of an indexed file with key and record size validations.
  • Updates tests and build scripts (Makefile.in and Makefile.am) to include the new create command functionality.
  • Enhances the Java code to validate command line arguments and key formats for file creation.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/cobj-idx.src/create.at New tests covering the basic create command and error cases for missing or invalid arguments.
tests/cobj-idx.at, Makefile.in, Makefile.am Updated to include the new create.at dependency.
IndexedFileUtilMain.java New branch for handling the create command including parsing, validation, and file creation logic.
CobolFileKeyInfo.java New helper class to encapsulate key information.
libcobj/Makefile.in, Makefile.am Updated to include CobolFileKeyInfo in the build.
Comments suppressed due to low confidence (2)

libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/user_util/indexed_file/IndexedFileUtilMain.java:261

  • The regex used in parseKeyOptions is complex; consider adding inline comments to document the expected key format for improved readability and maintainability.
Pattern pattern = Pattern.compile("[1-9][0-9]*,[1-9][0-9]*(:d?[1-9][0-9]*,[1-9][0-9]*)*");

libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/user_util/indexed_file/IndexedFileUtilMain.java:747

  • The boundary check using 'recordSize + 1' is not immediately clear; please add a comment explaining the rationale behind this condition to aid future maintenance.
if (keyInfo.offset <= 0 || keyInfo.size <= 0 || keyInfo.offset + keyInfo.size > recordSize + 1) {

@yutaro-sakamoto yutaro-sakamoto marked this pull request as ready for review May 27, 2025 08:24
@yutaro-sakamoto yutaro-sakamoto merged commit 76cb6a9 into opensourcecobol:develop May 29, 2025
154 checks passed
@yutaro-sakamoto yutaro-sakamoto mentioned this pull request May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants