Skip to content

Raise warnings for unused configuration keys #139

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

Open
wants to merge 4 commits into
base: core-update
Choose a base branch
from

Conversation

EmilyBourne
Copy link

@EmilyBourne EmilyBourne commented May 26, 2025

Raise warnings for unused configuration keys. Raise more explicit warnings for deprecated keys to help with migrating to v2.

Summary by Sourcery

Add deprecation warnings for unused and legacy configuration keys in both project and global validation, and propagate project-level warnings into the global validator

Enhancements:

  • Warn about deprecated project configuration keys during validation
  • Warn about deprecated global configuration keys during validation
  • Aggregate project sub-config warnings in the global validator

Chores:

  • Remove obsolete deprecated config check comment in plugin initialization

Copy link

sourcery-ai bot commented May 26, 2025

Reviewer's Guide

Extends configuration validation to surface deprecation warnings for unused or legacy keys in both project-level and global configs, and removes an outdated comment from the plugin initializer.

Sequence Diagram for MkDoxyConfig Validation and Warning Aggregation

sequenceDiagram
    participant C as Caller
    participant MC as MkDoxyConfig
    participant SFC as SuperClassConfig
    participant PSchema as ProjectSchemaItem
    participant POT as ProjectOptionType

    C->>+MC: validate()
    MC->>+SFC: super().validate()
    SFC-->>-MC: (failed_super, warnings_super)
    MC->>MC: Calculate unused_keys for MkDoxyConfig
    loop For each global unused legacy key k
        MC->>MC: Add warning for k to warnings_super
    end
    Note over MC: warnings_super now contains global config warnings.
    MC->>PSchema: Access 'projects' from self._schema
    PSchema-->>MC: Project schema entry (s)
    MC->>POT: Access s.option_type.warnings
    Note over POT: These warnings are from validated MkDoxyConfigProject instances
    POT-->>MC: project_warnings
    MC->>MC: Extend own warnings with project_warnings
    MC-->>-C: (final_failed, final_warnings)
Loading

Updated Class Diagram for MkDoxyConfig and MkDoxyConfigProject

classDiagram
    class Config {
        +validate() : tuple
    }
    class MkDoxyConfigProject {
      +validate() : tuple
    }
    class MkDoxyConfig {
      +projects : list~MkDoxyConfigProject~
      +validate() : tuple
    }
    Config <|-- MkDoxyConfigProject
    Config <|-- MkDoxyConfig
    MkDoxyConfig "1" o-- "*" MkDoxyConfigProject : has projects
Loading

File-Level Changes

Change Details Files
Enhanced MkDoxyConfigProject.validate to warn on deprecated configuration keys
  • Override validate() and call super().validate()
  • Compute unused_keys by diffing current keys against schema
  • Generate warnings for legacy project keys mapping old names to new
  • Return updated failed and warnings tuples
mkdoxy/doxy_config.py
Enhanced MkDoxyConfig.validate to warn on deprecated keys and include sub-config warnings
  • Override validate() and call super().validate()
  • Compute unused_keys by diffing keys against schema
  • Generate warnings for legacy global keys mapping old names to new
  • Append warnings from the 'projects' sub-config
  • Return updated failed and warnings tuples
mkdoxy/doxy_config.py
Removed obsolete deprecated-config check comment
  • Deleted the '# check deprecated config here' comment from plugin init
mkdoxy/plugin.py

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

@EmilyBourne
Copy link
Author

@JakubAndrysek This should fix the missing warnings. It is now also raising a warning for save-api -> custom_api_folder. I wasn't expecting the name to be so different. With the correct key the option works. So as far as our project is concerned we would be happy for you to merge #126 once this is merged in

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