aws-powertools/powertools-lambda-python

Tech debt: remove duplicated code in data class

leandrodamascena opened this issue · 5 comments

Why is this needed?

The data_classes module contains instances of duplicated code, which can lead to increased maintenance effort, potential bugs, and reduced code clarity. This issue proposes refactoring the module to eliminate redundant code by consolidating shared logic and improving overall code quality.

Which area does this relate to?

Event Source Data Classes

Suggestion

No response

Acknowledgment

Hi @ericbn! I'm assigning this issue to you.

Oi @leandrodamascena. Cool, thanks! I wish there was a linter that would check this automatically, but I’m not aware of any. I just manually checked a few base classes.

EDIT: Actually I’ll give this a try locally: https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/duplicate-code.html

Ei @ericbn! We have some report about code duplication here: https://sonarcloud.io/component_measures?metric=duplicated_lines&selected=aws-powertools_powertools-lambda-python%3Aaws_lambda_powertools&id=aws-powertools_powertools-lambda-python

The reason that we don't add a linter to check code duplication is because sometimes it's necessary for some reason. I think make sense we try to reduce the number of duplicated code, if possible.

Cool, I see now. I've used pylint locally to double check overriding code that is duplicate and updated the PR.

I see there's potential to refactor ClaimsOverrideDetails, ClaimsAndScopeOverrideDetails and TokenClaimsAndScopeOverrideDetails to have one or two common bases. But can we merge #6289 first?

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.