Skip to content

refactor: Modernize and optimize check_structure.py script - #7521

Open
geniruphin-junior wants to merge 1 commit into
TheAlgorithms:masterfrom
geniruphin-junior:patch-1
Open

refactor: Modernize and optimize check_structure.py script#7521
geniruphin-junior wants to merge 1 commit into
TheAlgorithms:masterfrom
geniruphin-junior:patch-1

Conversation

@geniruphin-junior

Copy link
Copy Markdown

Description

This Pull Request modernizes and optimizes the check_structure.py script by leveraging modern Python 3.10+ practices, improving memory consumption, and enforcing clean code standards.

Changes Made

  • Architecture: Encapsulated the execution logic inside a proper main() function instead of running it raw under the __main__ block.
  • Memory Optimization: Converted _find_misplaced_java_files to return an Iterator (generator expression) instead of building a full list in memory, which scales better as the repository grows.
  • Clean Code & Readability:
    • Simplified the parent directory lookup by using java_file.parents directly.
    • Used any() for a cleaner and more idiomatic path validation logic.
    • Extracted hardcoded paths into a tuple constant (VALID_PATHS).
  • CI/CD Best Practices: Redirected error outputs to sys.stderr instead of standard stdout, and added clear visual feedback ( / ) with file counters for better logs readability.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • The script runs without any bugs or regressions

@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.24%. Comparing base (fd2858e) to head (03af606).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #7521 +/- ##
============================================
- Coverage 80.25% 80.24% -0.01% + Complexity 7358 7357 -1 
============================================
Files 810 810 Lines 23787 23787 Branches 4678 4678 ============================================
- Hits 19091 19089 -2 
Misses 3940 3940 - Partials 756 758 +2 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prashantpiyush1111prashantpiyush1111 left a comment

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.

Nice refactor overall. One suggestion: could you keep the inline comments and docstrings in English for consistency with the rest of the repository? The implementation looks good, but using a single language throughout the codebase makes maintenance easier.

@DenizAltunkapan

Copy link
Copy Markdown
Member

i agree with @prashantpiyush1111

Sign up for freeto 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.

4 participants

@geniruphin-junior@codecov-commenter@DenizAltunkapan@prashantpiyush1111