Skip to content

Feedback#1

Open
github-classroom[bot] wants to merge 1 commit intofeedbackfrom
main
Open

Feedback#1
github-classroom[bot] wants to merge 1 commit intofeedbackfrom
main

Conversation

@github-classroom
Copy link

@github-classroom github-classroom bot commented Jan 4, 2026

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to the default branch since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to the default branch since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to the default branch. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @vilmaollas

@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 4, 2026

🤖 AI Feedback

🕒 Posted on 2026-01-04T18:44:22.916Z

What's Working Well:

  • The WarehouseAnalyzer class implements all required methods with correct method signatures and basic logic for filtering, analytics, shipping optimization, discount calculations, and inventory summaries.
  • Proper use of Java streams, BigDecimal for monetary values, and LocalDate for expiration-based logic.

Areas for Improvement:

  • Issue: In calculateWeightedAveragePriceByCategory, the method treats weights as double and uses Optional.ofNullable(s.weight()).orElse(0.0). Since Shippable.weight() returns Double (object), but BigDecimal.valueOf(w) can't accept null, this leads to NullPointerException.

    • Suggestion: Add a null check before using weight() to ensure safe conversion.
    • File: src/main/java/com/example/WarehouseAnalyzer.java, line in calculateWeightedAveragePriceByCategory.
  • Issue: In findProductsExpiringWithinDays, the code checks !exp.isBefore(today) and !exp.isAfter(end). This misses the inclusive behavior for end.

    • Suggestion: Change end comparison to !exp.isAfter(end.plusDays(1)) or use !exp.isAfter(end) and adjust end to be inclusive.
    • File: src/main/java/com/example/WarehouseAnalyzer.java, method findProductsExpiringWithinDays.

Summary:

Logic is mostly sound, but watch for potential NullPointerExceptions with nullable weights and off-by-one errors in date comparisons. Pay special attention to handling optional values safely.


Previous Feedback

🕒 Posted on 2026-01-04T18:43:45.248Z

What's Working Well

  • The WarehouseAnalyzer class is mostly well-structured and implements the required business logic for advanced warehouse operations.
  • Uses appropriate data types like BigDecimal for prices and handles rounding correctly in most cases.
  • Good use of Java features like streams and Optional in many places.

Areas for Improvement

  1. Price Outliers Calculation /src/main/java/com/example/WarehouseAnalyzer.java:126

    • Issue: The current implementation uses population variance (sum / n) but test expectations align with sample standard deviation logic which can cause mismatches in outlier detection. Additionally, all price conversions to double may introduce precision issues.
    • Suggestion: Ensure the standard deviation calculation matches the expected statistical approach. Consider using BigDecimal arithmetic for mean and variance to maintain precision.
  2. Expiration Discount BigDecimal Rounding /src/main/java/com/example/WarehouseAnalyzer.java:189

    • Issue: BigDecimal objects created from double (e.g., new BigDecimal("0.50")) is correct, but the rounding mode is applied after multiplication. Move rounding configuration to the BigDecimal constructor's second argument for clarity and correctness (though it works here).
    • Suggestion: Ensure rounding is handled with RoundingMode.HALF_UP consistently, especially if chaining operations.
  3. Shipping Group Optimization Weight Handling /src/main/java/com/example/WarehouseAnalyzer.java:147

    • Issue: Uses Objects.requireNonNullElse(b.weight(), 0.0)弟弟 in sorting, but this defaults null weights instead of asserting they are non-null as per the Shippable interface contract. This may mask implementation issues.
    • Suggestion: Ensure all Shippable products have non-null weights and remove the defaulting logic to make the contract more explicit.
  4. Weighted Average Calculation /src/main/java/com/example/WarehouseAnalyzer.java:111

    • Issue: The fallback to arithmetic mean when weightSum == 0 may not reflect test expectations if the products are expected to always have weights when used in weighted averages.
    • Suggestion: Confirm the test scenarios where weightSum == 0 and handle those cases as per expected behavior (arithmetic mean is likely fine per the problem statement).

Summary

The implementation of WarehouseAnalyzer is mostly correct and satisfies the advanced test requirements. Pay attention to statistical calculation precision and ensure contracts like non-null weights in Shippable are honored. The most important takeaway is to align the standard deviation calculation with the expected approach to ensure correct outlier detection.


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.

0 participants