Skip to content

[#605] Introduce getId() method#606

Merged
mnovak merged 1 commit intoxtf-cz:masterfrom
mchoma:issue_605
Aug 19, 2025
Merged

[#605] Introduce getId() method#606
mnovak merged 1 commit intoxtf-cz:masterfrom
mchoma:issue_605

Conversation

@mchoma
Copy link
Copy Markdown
Contributor

@mchoma mchoma commented Aug 19, 2025

Please make sure your PR meets the following requirements:

  • Pull Request contains a description of the changes
  • Pull Request does not include fixes for multiple issues/topics
  • Code is formatted, imports ordered, code compiles and tests are passing
  • Code is self-descriptive and/or documented

Summary by Sourcery

Introduce a new getId() method and associated METADATA_ID constant in DockerImageMetadata to expose the image identifier.

New Features:

  • Introduce getId() method in DockerImageMetadata to retrieve the image id

Enhancements:

  • Add METADATA_ID constant for the metadata key

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Aug 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Extends DockerImageMetadata by introducing a METADATA_ID constant and a getId() method to expose the image ID from the metadata store.

Class diagram for updated DockerImageMetadata class

classDiagram
    class DockerImageMetadata {
        - static final String METADATA_ID
        + String getId()
        ...
    }
Loading

File-Level Changes

Change Details Files
Introduce METADATA_ID constant for image ID
  • Added static final METADATA_ID = "Id"
junit5/src/main/java/cz/xtf/junit5/model/DockerImageMetadata.java
Add getId() method to retrieve the image ID
  • Implemented getId() with JavaDoc
  • Cast metadata.get(METADATA_ID) to String
junit5/src/main/java/cz/xtf/junit5/model/DockerImageMetadata.java

Possibly linked issues


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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard 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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `junit5/src/main/java/cz/xtf/junit5/model/DockerImageMetadata.java:136` </location>
<code_context>
+     *
+     * @return Id
+     */
+    public String getId() {
+        return (String) metadata.get(METADATA_ID);
+    }
+
</code_context>

<issue_to_address>
Check for null values when retrieving the image ID.

Casting the result without a null check may cause a NullPointerException if METADATA_ID is absent. Consider returning null, using Optional<String>, or adding a null check for safer handling.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    public String getId() {
        return (String) metadata.get(METADATA_ID);
    }
=======
    public String getId() {
        Object id = metadata.get(METADATA_ID);
        return id != null ? (String) id : null;
    }
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +136 to +138
public String getId() {
return (String) metadata.get(METADATA_ID);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): Check for null values when retrieving the image ID.

Casting the result without a null check may cause a NullPointerException if METADATA_ID is absent. Consider returning null, using Optional, or adding a null check for safer handling.

Suggested change
public String getId() {
return (String) metadata.get(METADATA_ID);
}
public String getId() {
Object id = metadata.get(METADATA_ID);
return id != null ? (String) id : null;
}

Copy link
Copy Markdown
Contributor

@mnovak mnovak left a comment

Choose a reason for hiding this comment

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

LGTM, merging.

@mnovak mnovak merged commit 1879c50 into xtf-cz:master Aug 19, 2025
4 checks passed
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