Skip to content
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

Update forkrun.bash #52

Open
wants to merge 1 commit into
base: forkrun_testing
Choose a base branch
from
Open

Update forkrun.bash #52

wants to merge 1 commit into from

Conversation

jkool702
Copy link
Owner

@jkool702 jkool702 commented Nov 29, 2024

consolidate variables for flags and file descriptors into two bash associative arrays (flagsA and fdA)

Summary by Sourcery

Enhancements:

  • Consolidate variables for flags and file descriptors into two bash associative arrays, 'flagsA' and 'fdA', to improve code organization and readability.

consolidate variables for flags and file descriptors into two bash associative arrays (`flagsA` and `fdA`)
Copy link
Contributor

sourcery-ai bot commented Nov 29, 2024

Reviewer's Guide by Sourcery

The changes consolidate flag and file descriptor variables into two bash associative arrays (flagsA and fdA) to improve code organization and maintainability. The implementation involves replacing individual variables with array references throughout the code while maintaining the same functionality.

Class diagram for associative arrays flagsA and fdA

classDiagram
    class flagsA {
        bool optParse
        bool nLinesAuto
        bool readBytes
        bool readBytesExact
        bool substituteString
        bool substituteStringID
        bool nOrder
        bool nullDelimiter
        bool subshellRun
        bool stdinRun
        bool pipeRead
        bool rmTmpDir
        bool exportOrder
        bool noFunc
        bool unescape
        bool inotify
        bool fallocate
        bool FORCE_allowCarriageReturns
        bool FORCE_allowUnsafeNullDelimiter
        bool doneIndicator
        bool nQueue
        bool continue
    }
    class fdA {
        int stdin0
        int stderr
        int write
        int read
        int read0
        int nOrder
        int nOrder0
        int nAuto
        int nAuto0
        int inotify
        int inotify0
        int nQueue
        int continue
        int stdout
    }
    note for flagsA "Associative array for flag variables"
    note for fdA "Associative array for file descriptor variables"
Loading

File-Level Changes

Change Details Files
Introduced two bash associative arrays to consolidate variables
  • Added flagsA array to store boolean flags
  • Added fdA array to store file descriptors
  • Declared arrays as local -A variables
forkrun.bash
Migrated flag variables to flagsA array
  • Replaced individual flag variables with flagsA array references
  • Updated flag initialization and assignments
  • Maintained flag naming convention by using the original names as array keys
forkrun.bash
Migrated file descriptor variables to fdA array
  • Replaced individual fd_ variables with fdA array references
  • Updated file descriptor initialization and assignments
  • Maintained fd naming convention by using the original names as array keys
forkrun.bash
Updated code references to use the new array structure
  • Modified conditional statements to use array references
  • Updated error messages and debug output to use array references
  • Adjusted file descriptor redirection syntax to use array references
forkrun.bash

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @jkool702 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding documentation comments explaining the purpose and structure of the new flagsA and fdA associative arrays
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

local -i PID0 nLines nLinesCur nLinesNew nLinesMax nRead nWait nOrder0 nBytesRead nQueue nQueueLast nQueueMin nQueueLastCount nCPU v9 kkMax kkCur kk kkProcs verboseLevel pLOAD_max pAdd
local -a A p_PID runCmd outHave outPrint pLOADA
local -A flagsA fdA
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider simplifying the flag handling by using either scoped boolean variables or a more concise array access pattern.

The change to use an associative array for flags has made the code more complex and harder to read. While grouping related flags can be beneficial, the current implementation with verbose ${flagsA['key']} syntax scattered throughout adds unnecessary cognitive overhead.

Consider one of these cleaner approaches:

  1. Using properly scoped boolean variables with a clear naming convention:
local -b flag_nLinesAuto=false
local -b flag_readBytes=false
  1. Or if using an array, use a more concise access pattern:
# At the start, create local references
local -n f=flagsA  # Create a reference
: "${f[nLinesAuto]:=false}"
: "${f[readBytes]:=false}"

# Then use the shorter form in the code
if ${f[nLinesAuto]}; then
  ...
fi

This maintains the benefits of grouping related flags while being more readable and maintainable.

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.

1 participant