Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@KachanovYev
Copy link
Contributor

@KachanovYev KachanovYev commented Jul 7, 2025

#692

Refactor assert_in_code test: use inline Java code and AST.from_string; remove Book.java file

Summary by CodeRabbit

  • Refactor

    • Updated tests to use inline Java code instead of relying on external files, improving test reliability and portability.
  • Chores

    • Removed an obsolete Java test file no longer needed for testing.

improve test by using new feature for improving tests speed.
@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

Walkthrough

The test for detecting assertion statements in Java code was refactored to use an inline string for the Java source code instead of relying on an external file. The AST is now built directly from this string, and the previously used Java file was deleted.

Changes

File(s) Change Summary
test/patterns/assert_in_code/test_assert_in_code.py Refactored test to use inline Java code string; added book_content(); removed file and path logic
test/patterns/assert_in_code/Book.java Deleted Java source file containing the Book class and assertion method

Possibly related issues

Poem

In code we trust, assertions we see,
No more file hunts—just strings set free!
The Book.java’s gone, but tests still run,
Inline and tidy, the job is done.
A rabbit hops by, with a satisfied grin,
“Refactor complete—let new tests begin!” 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a82b641 and b974b43.

📒 Files selected for processing (2)
  • test/patterns/assert_in_code/Book.java (0 hunks)
  • test/patterns/assert_in_code/test_assert_in_code.py (1 hunks)
💤 Files with no reviewable changes (1)
  • test/patterns/assert_in_code/Book.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/patterns/assert_in_code/test_assert_in_code.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: latexmk
  • GitHub Check: make
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@ivanovmg ivanovmg left a comment

Choose a reason for hiding this comment

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

@KachanovYev thank you for the PR!
Please have a look at my comments.

I also think that the PR title & description can be improved to target the actual task at hand more specifically. There is still a bunch of slow tests, so this PR does not solve the problem.

Recently we had a related conversation, where @yegor256 stated, that using filesystem for test fixtures is not that of a big deal anyway #800 (comment)

def test_assert_in_code(self):
file = Path(self.cur_file_dir, 'Book.java')
ast = AST.build_from_javalang(build_ast(file))
ast = AST.from_string(book_content())
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the moment of writing the related issue, we actually opted out from introducing from_string method towards this pattern:

ast = AST.build_from_javalang(build_ast_from_string(content))

It is likely we do not need introducing an alternative constructor from_string.

from aibolit.patterns.assert_in_code.assert_in_code import AssertInCode


def book_content() -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

I we add this test fixure, then we probably do not need Book.java file anymore.

@KachanovYev
Copy link
Contributor Author

@KachanovYev thank you for the PR! Please have a look at my comments.

I also think that the PR title & description can be improved to target the actual task at hand more specifically. There is still a bunch of slow tests, so this PR does not solve the problem.

Recently we had a related conversation, where @yegor256 stated, that using filesystem for test fixtures is not that of a big deal anyway #800 (comment)

ok
So what i must with this PR?
this issue
#692

have a 2 labels "bug" and "good title"
if issue on github did not have a full context, i can't know it.

@ivanovmg
Copy link
Contributor

@KachanovYev thank you for the PR! Please have a look at my comments.
I also think that the PR title & description can be improved to target the actual task at hand more specifically. There is still a bunch of slow tests, so this PR does not solve the problem.
Recently we had a related conversation, where @yegor256 stated, that using filesystem for test fixtures is not that of a big deal anyway #800 (comment)

ok So what i must with this PR? this issue #692

have a 2 labels "bug" and "good title" if issue on github did not have a full context, i can't know it.

@KachanovYev I suggest that you update the title and the description of your PR to more effectively convey the message on the changes you added. Then you could apply the recommendations from my side related to the way we read AST from the filepath (without introducing the new method). Furthermore, you could remove Book.java, which is not relevant anymore.
Ping me once done.

Note that this project uses PDD. Thus, it is OK to describe the issue broadly, but then implement only a part of it, while adding puzzles. It is clear that creating atomic issues on the first try is difficult and sometimes impractical. This is exactly the case here - I noticed that the tests use filesystem, reported it. It does not mean that the issue can be closed via a single PR. But you are right - I have to update the issue to reflect that it is not that relevant anymore.

@KachanovYev KachanovYev changed the title Unit tests negatively impacted by filesystem usage, causing slower run times Refactor assert_in_code test: use inline Java code and AST.from_string; remove Book.java file Jul 15, 2025
@KachanovYev KachanovYev changed the title Refactor assert_in_code test: use inline Java code and AST.from_string; remove Book.java file Refactor assert_in_code test to use inline Java and AST.from_string Jul 15, 2025
@KachanovYev KachanovYev requested a review from ivanovmg July 15, 2025 14:13
Copy link
Contributor

@ivanovmg ivanovmg left a comment

Choose a reason for hiding this comment

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

@KachanovYev thank you for applying my suggestions! It looks good to me. I suggest that you change the title of the PR, though - ast.from_string is not relevant anymore.

@KachanovYev KachanovYev changed the title Refactor assert_in_code test to use inline Java and AST.from_string Refactor assert_in_code test to use inline Java Jul 20, 2025
@KachanovYev
Copy link
Contributor Author

@KachanovYev thank you for applying my suggestions! It looks good to me. I suggest that you change the title of the PR, though - ast.from_string is not relevant anymore.

Hi
i did update of the PR tittle

@ivanovmg
Copy link
Contributor

@KachanovYev thank you for applying my suggestions! It looks good to me. I suggest that you change the title of the PR, though - ast.from_string is not relevant anymore.

Hi i did update of the PR tittle

@yegor256 it looks good to me.

@KachanovYev
Copy link
Contributor Author

@yegor256
Hi this is resolved issue.

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.