jhanley634 / dojo-blackboard

An HTMX webserver for the Dojo's Tuesday night python meetups.
MIT License
3 stars 1 forks source link

31 tuesday talk #50

Closed jhanley634 closed 1 week ago

jhanley634 commented 1 week ago

Summary by Sourcery

Enhance the line counting logic by improving the handling of shebang lines and supporting custom comment patterns in Bash scripts. Refactor the code to use more efficient data structures and expand the test coverage to include a wider range of file types. Update the documentation to clarify the types of line counts.

Enhancements:

Documentation:

Tests:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This PR enhances the source line counter (SLOC) implementation by improving language support, refactoring the comment handling logic, and adding new test cases. The changes focus on making the code more robust and supporting additional file types while maintaining compatibility with the cloc tool's counting methodology.

Updated class diagram for line counting classes

classDiagram
    class LineCounter {
        +__init__(in_file: Path)
        +__str__() str
        +_get_line_types(lines: list[str]) Iterable[LineType]
        +expand_comments(lines: Iterable[str]) Iterable[str]
        +_get_non_blank_lines(lines: Iterable[str]) Iterable[str]
        +_do_shebang(lines: list[str]) Iterable[str]
    }

    class BashLineCounter {
        +__init__(in_file: Path, comment_pattern: str = r"^\\s*#")
        +expand_comments(lines: Iterable[str]) Iterable[str]
    }
    LineCounter <|-- BashLineCounter

    class PythonLineCounter {
        +expand_comments(lines: Iterable[str]) Iterable[str]
    }
    LineCounter <|-- PythonLineCounter

    class ClocCounts {
        <<data>>
    }

    class TestCloc {
        +test_last_line_is_blank()
        +test_empty_intersection()
        +test_count_diverse_file_types()
        +SUPPORTED_LANGUAGES: frozenset
        +HASH_MEANS_COMMENT_LANGUAGES: frozenset
        +SKIP_LANGUAGE: frozenset
        +SKIP: frozenset
    }

File-Level Changes

Change Details Files
Enhanced comment handling and line processing logic
  • Moved shebang handling to a separate _do_shebang method
  • Made expand_comments an instance method instead of static
  • Improved handling of blank lines at end of file
  • Refactored line type generators to use Iterable instead of Generator
src/count/sloc.py
Added support for additional file types and comment styles
  • Added support for .bat files with REM and :: comments
  • Added support for .ini files with ; comments
  • Introduced configurable comment pattern for BashLineCounter
  • Added new supported file extensions like .Dockerfile, .cmake, .toml
src/count/tests/sloc_test.py
Improved test coverage and file handling
  • Added test for files with blank last line
  • Expanded file type testing beyond .p* extensions
  • Added SKIP_LANGUAGE set for unsupported file types
  • Improved error messages in cloc parsing
src/count/tests/sloc_test.py
src/count/cloc.py
Updated documentation and presentation
  • Added explanation of the three count types (blank, comment, code)
  • Added section on recurring themes
  • Updated demo section with GitHub links
talks/2024-11-12-sloc.md

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. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a 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. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).