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

Suppress virtual method call from the constructor warning for AddCategory call #849

Conversation

laimis
Copy link
Contributor

@laimis laimis commented May 3, 2023

Continuation of fixes with virtual calls being made from constructors. The issue originally reported by SonarCloud scans: https://sonarcloud.io/project/issues?resolved=false&rules=csharpsquid%3AS1699&id=apache_lucenenet and referenced in this issue: #670

This takes care of what should be the last issue in this area. We already modified DirectoryTaxonomyWriter to accept a factory for index writer and now the last remaining virtual call it makes is to AddCategory in case an empty/new taxonomy directory is being created.

There does not appear to be an easy way to translate this into a factory that makes a logical sense.

I considered adding a private AddCategory method that constructor and AddCategory could call, but it seemed like it would prevent the subclasses to completely intercept and modify the root category AddCategory call. Instead, went with the comments to warn the users about what is happening. I think a subclass has an option to do something like capture an attempt to add root category (easy to detect if it is root by ID), and save it to be written later (e.g. post constructor run from its own constructor).

@laimis laimis requested a review from NightOwl888 May 3, 2023 18:00
@laimis laimis merged commit 33b40ab into apache:master May 4, 2023
@laimis laimis deleted the directory-taxonomy-writer-ignore-for-add-category branch May 17, 2023 18:34
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