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

Add callback functions to mark the start and end of an NsiqCppStyle session #33

Closed
mosherubin opened this issue Jun 26, 2022 · 1 comment

Comments

@mosherubin
Copy link
Collaborator

mosherubin commented Jun 26, 2022

Requested Functionality

Add two new rule callback functions to notify a user rule when NsiqCppStyle is about to start/end its session.

Technical Background

In NsiqCppStyle, a session is defined as the time range beginning just before the first source file is processed, and ending right after the last file is processed. Within this time range, NsiqCppStyle may have processed multiple projects (processing of a single file or an entire directory tree). There is always only one session for a given run of NsiqCppStyle.

Currently, NsiqCppStyle has two sets of callbacks to notify a user rule when processing events start and/or end:

for targetPath in targetPaths:
    if targetPath is a file:
        FileStartRule()
        <process the file>
        FileEndRule()
    else:
        # targetPath is a directory ("project")
        for (each file in the directory tree):
            FileStartRule()
            <process the file>
            FileEndRule()
    ProjectRules()

In a recent user rule I wrote, I needed to "setup" and "teardown" global data at the start and end of the session: at session start I defined required data structures, while at session end I wrote out the accumulated information to an external JSON file.

The request is to define new rule callback functions to notify a user rule when the session starts and ends (e.g., SessionStartRule and SessionEndRule). When implemented, rule writers will have three types of time range notifications to work with:

SessionStartRule()
for targetPath in targetPaths:
    if targetPath is a file:
        FileStartRule()
        <process the file>
        FileEndRule()
    else:
        # targetPath is a directory ("project")
        for (each file in the directory tree):
            FileStartRule()
            <process the file>
            FileEndRule()
    ProjectRules()
SessionEndRule()

(I have already implemented the above, and hope to create a pull request with the changes in the near future.)

@mosherubin
Copy link
Collaborator Author

I believe you can close this issue. It was implemented in #35 and used in #41.

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

No branches or pull requests

2 participants