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

Signed-off-by: Cristian Rivera [email protected] #48

Merged
merged 7 commits into from
Feb 5, 2024

Conversation

crisrivlop
Copy link
Contributor

Resume

Here is an small change for SQLReference detection. Actually SQLReference is only read in the main scope of programs and modules. If there are SQL Sentences called in procedures without any other native sentence (for example: DCL-F or DLC-DS xxx EXTNAME(xxxx)) there is no detection of those SQL sentences. That's why there is a concatenation between the cache.sqlReferences and the sqlReferences from cache.procedures.scope.

Test Repo

I am using the following repo to test this new functionality: Example using source orbit, from this repo the following 2 impact analysis were extracted.

Impact Analysis from main

Impact Analysis

Touched objects:

  • 📁 EMPLOYEE.FILE: qddssrc/employee.table

EMPLOYEE.FILE

Click to expand
  • 📁 EMPLOYEE.FILE (qddssrc/employee.table)

Changes to this object have no impact.

Messages

No messages to show.


Project Listing

Click to expand
- Object Type Path Warnings Parents Children
📁 DEPTS FILE qddssrc/depts.table 0 0
📁 EMPLOYEE FILE qddssrc/employee.table 0 0
📦 EMPSEL SRVPGM qrpglesrc/empsel.bnd
1$(APP_BNDDIR).BNDDIR
1EMPSEL.MOD.MODULE
⛏️ EMPSEL.MOD MODULE qrpglesrc/empsel.mod.sqlrpgle
1EMPSEL.SRVPGM
0
🛠️ MYPGM PGM qrpglesrc/mypgm.pgm.sqlrpgle 0
1PGM2.PGM
🛠️ PGM2 PGM qrpglesrc/pgm2.pgm.sqlrpgle
1MYPGM.PGM
0
  • Parents are objects that depend on this object.
  • Children are objects that this object depends on.

Impact Analysis from pull request changes

Impact Analysis

Touched objects:

  • 📁 EMPLOYEE.FILE: qddssrc/employee.table

EMPLOYEE.FILE

Click to expand
  • 📁 EMPLOYEE.FILE (qddssrc/employee.table)
    • ⛏️ EMPSEL.MOD.MODULE (qrpglesrc/empsel.mod.sqlrpgle)
      • 📦 EMPSEL.SRVPGM (qrpglesrc/empsel.bnd)
        • 📒 $(APP_BNDDIR).BNDDIR (no source)
    • 🛠️ PGM2.PGM (qrpglesrc/pgm2.pgm.sqlrpgle)
      • 🛠️ MYPGM.PGM (qrpglesrc/mypgm.pgm.sqlrpgle)

Messages

No messages to show.


Project Listing

Click to expand
- Object Type Path Warnings Parents Children
📁 DEPTS FILE qddssrc/depts.table
1EMPSEL.MOD.MODULE
0
📁 EMPLOYEE FILE qddssrc/employee.table
2EMPSEL.MOD.MODULE, PGM2.PGM
0
📦 EMPSEL SRVPGM qrpglesrc/empsel.bnd
1$(APP_BNDDIR).BNDDIR
1EMPSEL.MOD.MODULE
⛏️ EMPSEL.MOD MODULE qrpglesrc/empsel.mod.sqlrpgle
1EMPSEL.SRVPGM
2EMPLOYEE.FILE, DEPTS.FILE
🛠️ MYPGM PGM qrpglesrc/mypgm.pgm.sqlrpgle 0
1PGM2.PGM
🛠️ PGM2 PGM qrpglesrc/pgm2.pgm.sqlrpgle
1MYPGM.PGM
1EMPLOYEE.FILE
  • Parents are objects that depend on this object.
  • Children are objects that this object depends on.

@crisrivlop crisrivlop force-pushed the main branch 2 times, most recently from 81d3007 to 7eedd68 Compare February 3, 2024 01:17
@worksofliam worksofliam self-assigned this Feb 3, 2024
@worksofliam
Copy link
Member

Hi @crisrivlop!

First off, thanks so much for your PR! Your change makes sense at a glance and was a complete oversight to me. Here is my review:

  • Sadly, your change should ensure that it doesn't break any of the existing test cases. You can actually run the test runner from your own device with npm run test. Please don't change the existing tests.
  • You don't have to, but I recommend adding additional tests to provide this change will continue to work in the future.
  • You don't need to include the author in the comments. Git is tracking that for us, and you will appear in the contributor list.
  • The large comment you provided is good, but doesn't make sense in the code. It is more appropriate for this is project to either include that comment in the commit message or in the PR.

Copy link
Member

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

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

Please see my above comment. Thank you!

@crisrivlop
Copy link
Contributor Author

crisrivlop commented Feb 5, 2024

Hi @worksofliam!

Thanks for your quick response. I made all the requested changes.

  1. Now npm run test works fine. In order to keep the original test cases I added 1 test files.
    1.. sqlReference.test.ts: Contains a simple example showing the new mechanic of sql detection from the procedure scope. It has 2 scenarios: using the sqlreference analysis and without it.
  2. At the same time to isolate this functionality, a new cli option was added -sa/--scope-analysis. This was made to keep the consistency of the current scenarios.
so -bf imd -sa -l qddssrc/employee.table

I appreciate your help with your feedback!

@worksofliam
Copy link
Member

@crisrivlop Great work here! Thank you greatly for your test case!

I am also finding additional edge cases that I have not covered (my bad!), so with your permission do you mind if I also add some commits to your PR? I also think there are ways to make it simpler.

Let me know if you're okay with that.

@crisrivlop
Copy link
Contributor Author

Hi! @worksofliam, yes sure it is ok for me :)

@worksofliam
Copy link
Member

@crisrivlop

I have made my commit. Do a pull and let me know what you think.

Here is the gist of my changes:

  • I removed your additional CLI parameter and target methods. They are not needed after my fix.
  • I realized the issue you found actually exists for file definitions, variables and structs. So instead of looping through only sqlReferences, we now check every scope correctly.
  • Your test case is now passing correctly without the need of the flag, as well as all the other tests.

@crisrivlop
Copy link
Contributor Author

It seems to be a better solution and is solving more issues than SQL references. So we can continue with the change :)

@worksofliam
Copy link
Member

Thanks @crisrivlop ! I will publish a new version of the CLI today with this fix.

I am grateful for your PR!

@worksofliam worksofliam merged commit 5bb10cb into IBM:main Feb 5, 2024
4 checks passed
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