Skip to content

Remove unused config variable#5965

Merged
myersCody merged 5 commits intomainfrom
dead_code
Apr 1, 2026
Merged

Remove unused config variable#5965
myersCody merged 5 commits intomainfrom
dead_code

Conversation

@myersCody
Copy link
Copy Markdown
Contributor

@myersCody myersCody commented Mar 26, 2026

Removes unused config var: Remove DEFAULT_MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY (dead code)

@myersCody myersCody requested review from a team as code owners March 26, 2026 13:39
@myersCody myersCody added the smoke-tests pr_check will run minimal required smokes. Used when changes hit multiple providers. label Mar 26, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving code maintainability by eliminating dead code. It removes an identified unused configuration variable and its associated logic from the application's configuration and data retention processing, along with updating the relevant unit tests. This cleanup streamlines the codebase by removing unnecessary components.

Highlights

  • Configuration Cleanup: The unused configuration variable DEFAULT_MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY and its corresponding class attribute MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY have been removed from koku/masu/config.py.
  • Code Refactoring: The ExpiredDataRemover class in koku/masu/processor/expired_data_remover.py was refactored to remove the line_items_month_to_keep parameter from its constructor, as it was no longer utilized.
  • Test Updates: Unit tests in koku/masu/test/processor/test_expired_data_remover.py were updated to align with the removal of the line_items_month_to_keep parameter, ensuring test suite integrity.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added the smokes-required Label to show that smokes tests should be run against these changes. label Mar 26, 2026
@myersCody myersCody changed the title Remove DEFAULT_MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY (dead code) Remove unused config variable Mar 26, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies data retention by removing the MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY configuration and its associated logic from koku/masu/config.py and koku/masu/processor/expired_data_remover.py. The related test cases in koku/masu/test/processor/test_expired_data_remover.py have been updated. A suggestion was made to consolidate the now identical test_initializer_ocp and test_initializer_azure tests into a single parameterized test for better maintainability.

Comment on lines 36 to 45
def test_initializer_ocp(self):
"""Test to init for OCP."""
remover = ExpiredDataRemover(self.schema, Provider.PROVIDER_OCP)
self.assertEqual(remover._months_to_keep, Config.MASU_RETAIN_NUM_MONTHS)
self.assertEqual(remover._line_items_months, Config.MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY)

def test_initializer_azure(self):
"""Test to init for Azure."""
remover = ExpiredDataRemover(self.schema, Provider.PROVIDER_AZURE)
self.assertEqual(remover._months_to_keep, Config.MASU_RETAIN_NUM_MONTHS)
self.assertEqual(remover._line_items_months, Config.MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Now that the assertions for _line_items_months have been removed, test_initializer_ocp and test_initializer_azure are identical. They can be consolidated into a single parameterized test to reduce code duplication and improve maintainability.

Suggested change
def test_initializer_ocp(self):
"""Test to init for OCP."""
remover = ExpiredDataRemover(self.schema, Provider.PROVIDER_OCP)
self.assertEqual(remover._months_to_keep, Config.MASU_RETAIN_NUM_MONTHS)
self.assertEqual(remover._line_items_months, Config.MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY)
def test_initializer_azure(self):
"""Test to init for Azure."""
remover = ExpiredDataRemover(self.schema, Provider.PROVIDER_AZURE)
self.assertEqual(remover._months_to_keep, Config.MASU_RETAIN_NUM_MONTHS)
self.assertEqual(remover._line_items_months, Config.MASU_RETAIN_NUM_MONTHS_LINE_ITEM_ONLY)
def test_initializer_providers(self):
"""Test to init for OCP and Azure providers."""
for provider in [Provider.PROVIDER_OCP, Provider.PROVIDER_AZURE]:
with self.subTest(provider=provider):
remover = ExpiredDataRemover(self.schema, provider)
self.assertEqual(remover._months_to_keep, Config.MASU_RETAIN_NUM_MONTHS)

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.3%. Comparing base (9e52aa2) to head (c85b91d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #5965     +/-   ##
=======================================
- Coverage   94.3%   94.3%   -0.0%     
=======================================
  Files        356     356             
  Lines      31107   31102      -5     
  Branches    3397    3396      -1     
=======================================
- Hits       29345   29337      -8     
- Misses      1143    1144      +1     
- Partials     619     621      +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@myersCody myersCody enabled auto-merge (squash) April 1, 2026 15:16
@myersCody myersCody merged commit ea95eee into main Apr 1, 2026
13 checks passed
@myersCody myersCody deleted the dead_code branch April 1, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

smoke-tests pr_check will run minimal required smokes. Used when changes hit multiple providers. smokes-required Label to show that smokes tests should be run against these changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants