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

Refactor TableGrepFilter to reduce NPath complexity #1646

Merged
merged 4 commits into from
Aug 10, 2024

Conversation

sualeh
Copy link
Collaborator

@sualeh sualeh commented Aug 8, 2024

Refactor TableGrepFilter to reduce NPath complexity in the test method.

  • Extract nested conditional logic into private methods checkIncludeForTables, checkIncludeForColumns, and checkIncludeForDefinitions
  • Update test method to call the new private methods and combine their results
  • Ensure invertMatch flag and logging functionality remain intact in the test method
  • Add unit tests in TableGrepFilterTest to verify the refactored test method
    • Test inclusion rules for tables, columns, and definitions
    • Test invertMatch flag functionality
    • Test logging functionality for excluded tables

Refactor `TableGrepFilter` to reduce NPath complexity in the `test` method.

* Extract nested conditional logic into private methods `checkIncludeForTables`, `checkIncludeForColumns`, and `checkIncludeForDefinitions`
* Update `test` method to call the new private methods and combine their results
* Ensure `invertMatch` flag and logging functionality remain intact in the `test` method
* Add unit tests in `TableGrepFilterTest` to verify the refactored `test` method
  * Test inclusion rules for tables, columns, and definitions
  * Test `invertMatch` flag functionality
  * Test logging functionality for excluded tables
@sualeh
Copy link
Collaborator Author

sualeh commented Aug 10, 2024

✨✨ Here's an AI-assisted sketch of how you might approach this issue saved by @sualeh using Copilot Workspace v0.23

Topic

Reduce the NPath complexity of TableGrepFilter

Before
  • schemacrawler-api/src/main/java/schemacrawler/filter/TableGrepFilter.java has a high NPath complexity in the test method (lines 70-133)
  • The test method in TableGrepFilter contains multiple nested conditional statements
  • The test method checks for inclusion rules for tables, columns, and definitions
  • The test method has an invertMatch flag that inverts the inclusion result
  • The test method logs excluded tables at a fine level
  • The test method returns a boolean indicating whether a table should be included based on the inclusion rules
After
  • Refactor test method in schemacrawler-api/src/main/java/schemacrawler/filter/TableGrepFilter.java to reduce NPath complexity by extracting nested conditional logic into separate methods.
  • Create private methods checkIncludeForTables, checkIncludeForColumns, and checkIncludeForDefinitions to handle respective inclusion checks.
  • Update test method to call the new private methods and combine their results.
  • Ensure invertMatch flag and logging functionality remain intact in the test method.
  • Add unit tests to verify the refactored test method in TableGrepFilter.
Plan
  • schemacrawler-api/src/main/java/schemacrawler/filter/TableGrepFilter.java (CHANGE)
    • Extract nested conditional logic into private methods checkIncludeForTables, checkIncludeForColumns, and checkIncludeForDefinitions
    • Update test method to call the new private methods and combine their results
    • Ensure invertMatch flag and logging functionality remain intact in the test method
Sketch of implementation

View the changes

Details

Code analyzed at 7ae32d3

@sualeh
Copy link
Collaborator Author

sualeh commented Aug 10, 2024

✨✨ Here's an AI-assisted sketch of how you might approach this issue saved by @sualeh using Copilot Workspace v0.23

Topic

Reduce the NPath complexity of TableGrepFilter

Before
  • schemacrawler-api/src/main/java/schemacrawler/filter/TableGrepFilter.java has a high NPath complexity in the test method (lines 70-133)
  • The test method in TableGrepFilter contains multiple nested conditional statements
  • The test method checks for inclusion rules for tables, columns, and definitions
  • The test method has an invertMatch flag that inverts the inclusion result
  • The test method logs excluded tables at a fine level
  • The test method returns a boolean indicating whether a table should be included based on the inclusion rules
After
  • Refactor test method in schemacrawler-api/src/main/java/schemacrawler/filter/TableGrepFilter.java to reduce NPath complexity by extracting nested conditional logic into separate methods.
  • Create private methods checkIncludeForTables, checkIncludeForColumns, and checkIncludeForDefinitions to handle respective inclusion checks.
  • Update test method to call the new private methods and combine their results.
  • Ensure invertMatch flag and logging functionality remain intact in the test method.
  • Add unit tests to verify the refactored test method in TableGrepFilter.
Plan
  • schemacrawler-api/src/main/java/schemacrawler/filter/TableGrepFilter.java (CHANGE)
    • Extract nested conditional logic into private methods checkIncludeForTables, checkIncludeForColumns, and checkIncludeForDefinitions
    • Update test method to call the new private methods and combine their results
    • Ensure invertMatch flag and logging functionality remain intact in the test method
Sketch of implementation

View the changes

Details

Code analyzed at 7ae32d3

@sualeh sualeh merged commit 1c9e323 into main Aug 10, 2024
42 of 44 checks passed
@sualeh sualeh deleted the sualeh/refactor-tablegrepfilter branch August 10, 2024 00:56
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