Skip to content

Health report, report diff fixes#1254

Merged
milanmajchrak merged 23 commits into
dtq-devfrom
ufal/health-report-checks-fix
Jun 12, 2026
Merged

Health report, report diff fixes#1254
milanmajchrak merged 23 commits into
dtq-devfrom
ufal/health-report-checks-fix

Conversation

@Kasinhou

@Kasinhou Kasinhou commented Feb 23, 2026

Copy link
Copy Markdown

Problem description

Followed issues:
https://github.com/dataquest-dev/dspace-customers/issues/430
#1250

Manual Testing (if applicable)

Copilot review

  • Requested review from Copilot

Summary by CodeRabbit

  • New Features

    • Select multiple checks with repeatable -c for health reports
    • List and compare reports by report ID in report-diff; enhanced summary, key-changes table, and skipped-checks reporting
  • Improvements

    • Unified help option (-h) and clearer CLI semantics; report output now includes persisted report ID and writes to a report file (-r)
    • Human-readable size diffs, improved email/error handling, and more robust option validation
  • Tests

    • Expanded integration tests for CLI behaviors, validations, listing, and comparisons
  • Refactor

    • Removed legacy report runner and deprecated report-filtering/query paths
  • Chores

    • Removed legacy launcher healthcheck command

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Health Report and Report Diff CLI tooling in CLARIN-DSpace to improve comparison correctness when reports contain different check selections and to align CLI option handling/help output.

Changes:

  • Remove the legacy healthcheck CLI command from launcher.xml and rely on the Spring script-service based health-report.
  • Update report-diff to normalize report JSON to the intersection of check names, add a “Skipped Checks” section, and make key-field mappings independent of check ordering via selector-based paths.
  • Standardize help flags to -h/--help and update tests/fixtures accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
dspace/config/launcher.xml Removes legacy healthcheck command entry.
dspace-api/src/test/java/org/dspace/scripts/ReportDiffIT.java Updates help flag usage and adds coverage for skipped checks / name-based comparisons.
dspace-api/src/main/resources/report-diff-fields.json Switches from index-based paths to selector-by-check-name paths.
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiffScriptConfiguration.java Changes -i to -h and clarifies -c semantics for filtering comparisons.
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Implements intersection normalization, skipped-check reporting, and selector-based field resolution.
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReportScriptConfiguration.java Changes help flag to -h, supports multiple -c values, and renames output option to -r.
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java Implements multi-check -c parsing, help renaming, and output option rename.

Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace/config/launcher.xml
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
@Paurikova2

Paurikova2 commented Feb 25, 2026

Copy link
Copy Markdown
Problem (from issue) Class + Method Changed Test Name
1328 -i/--info renamed to -h/--help in health-report HealthReport#setup, HealthReport#internalRun, HealthReport#printHelp HealthReportIT#testHelpOption
1328 -h/--help option declared for health-report CLI HealthReportScriptConfiguration#getOptions HealthReportIT#testHelpOption
1328 -o/--output renamed to -r/--report; field fileNamereportFile HealthReport#setup, HealthReport#internalRun HealthReportIT#testReportFileSaved
1328 -r/--report option declared in CLI options HealthReportScriptConfiguration#getOptions HealthReportIT#testReportFileSaved
1328 -c accepts multiple values (List<Integer> replaces single int); uses getOptionValues HealthReport#setup HealthReportIT#testMultipleChecks, HealthReportIT#testLicenseCheck
1328 -c declared as multi-value with setArgs(Integer.MAX_VALUE) HealthReportScriptConfiguration#getOptions HealthReportIT#testMultipleChecks
1328 Validate -c: out-of-range index → logError + throw ParseException HealthReport#setup HealthReportIT#testInvalidCheckOutOfRange
1328 Validate -c: non-integer value → logError + throw ParseException HealthReport#setup HealthReportIT#testInvalidCheckNonInteger
1328 Validate -f: value ≤ 0 → logError + throw ParseException HealthReport#setup HealthReportIT#testInvalidForDaysZero
1328 Validate -f: non-integer value → logError + throw ParseException HealthReport#setup HealthReportIT#testInvalidForDaysNonInteger
1328 printCommandlineOptions updated to use getOptionValues for multi-value -c HealthReport#printCommandlineOptions HealthReportIT#testMultipleChecks
1328 -i/--info renamed to -h/--help in report-diff ReportDiff#setup, ReportDiff#internalRun, ReportDiff#printHelp ReportDiffIT#testHelpInformation
1328 -h/--help option declared for report-diff CLI ReportDiffScriptConfiguration#getOptions ReportDiffIT#testHelpInformation
1328 Legacy healthcheck CLI command removed from launcher dspace/config/launcher.xml
1334 Reports with different check lists produced null values — normalize both to intersection of check names ReportDiff#normalizeReportsToIntersection ReportDiffIT#testSkippedChecksSection, ReportDiffIT#testIntersectionComparisonNoNullsForCommonChecks
1334 Checks absent from one report silently ignored — "Skipped Checks" section added ReportDiff#generateReportComparison ReportDiffIT#testSkippedChecksSection, ReportDiffIT#testIntersectionComparisonNoNullsForCommonChecks
1334 -c in report-diff filtered by check name, not position, after normalization ReportDiff#normalizeReportsToIntersection ReportDiffIT#testCompareSpecificCheck
1334 report-diff-fields.json paths used numeric indices (/checks/0/…) breaking resolution when check order changed — replaced with name selectors (/checks/[name=Item summary]/…) report-diff-fields.json ReportDiffIT#testEnhancedKeyChangesTable, ReportDiffIT#testProfessionalReportFormat, ReportDiffIT#testSizeDifferenceFormatting
1334 resolveFieldPath did not support name-selector syntax — added XPath-like [attr=value] segment resolution ReportDiff#resolveFieldPath, ReportDiff#splitPathSegments ReportDiffIT#testEnhancedKeyChangesTable, ReportDiffIT#testProfessionalReportFormat, ReportDiffIT#testSizeDifferenceFormatting
1334 Key Changes table showed null for fields when one report had fewer checks — skip fields missing in either normalized report ReportDiff#generateEnhancedKeyChangesTable ReportDiffIT#testIntersectionComparisonNoNullsForCommonChecks, ReportDiffIT#testEnhancedKeyChangesTable

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/test/java/org/dspace/scripts/HealthReportIT.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
@Paurikova2 Paurikova2 linked an issue Mar 5, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java:385

  • displayReportDates() also assumes the newest report is at the end of findAll() (reverses index via allReports.size() - 1 - i). Since findAll() is unordered, the listing and max-entry truncation can be inconsistent. Prefer querying reports already ordered by lastModified/id DESC and applying the limit at the query level.
            List<ReportResult> allReports = reportResultService.findAll(context);
            // Determine how many reports to process, respecting maxEntries if it's within valid range
            long limitCount = (maxEntries > 0 && maxEntries < allReports.size()) ? maxEntries : allReports.size();
            Map<String, List<DateWithArgs>> reportDatesMap = new HashMap<>();
            for (long i = 0; i < limitCount; i++) {
                // the newest report is at the end of the list, so we reverse the index
                ReportResult report = allReports.get(allReports.size() - 1 - (int) i);
                String formattedDate = FORMATTER.format(report.getLastModified()

dspace-api/src/test/java/org/dspace/scripts/HealthReportIT.java:272

  • This test picks the "latest" ReportResult via findAll(context).get(size - 1), but ReportResultDAO inherits AbstractHibernateDAO.findAll() which has no ORDER BY. This can make the test flaky if the DB returns rows in a different order or other reports exist. Sort by lastModified/id explicitly (or add a dedicated query for the most recent report) before asserting on latest.getArgs().
                context.reloadEntity(eperson);
                List<ReportResult> allReports = reportResultService.findAll(context);
                ReportResult latest = allReports.get(allReports.size() - 1);

                assertThat(handler.getErrorMessages(), empty());
                assertThat(latest.getArgs(), containsString("-c: 2"));
                assertThat(latest.getArgs(), containsString("-c: 3"));

Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/test/java/org/dspace/scripts/HealthReportIT.java Outdated
@kuchtiak-ufal

Copy link
Copy Markdown
Collaborator

Regarding incompatible reports, comparing the report-diff, I got the following results (example):

dspace@074ee81d33a2:/dspace/bin$ ./dspace report-diff -s 19 -t 24

The script has started
No common checks found between the two reports for comparison.
CLARIN DSpace: Repository Health Report Diff

Section 1: Executive Summary

Report Type: healthcheck
Source Report: ID 19 at 2026-05-25 10:41:27.655
Target Report: ID 24 at 2026-05-25 11:51:03.66
Report Period: 1 hour 9 minutes 36 seconds

Key Changes Between Reports

No significant changes detected between reports.

Section 2: Skipped Checks

The following checks could not be compared because they were not present in both reports.

Only in source report (ID 19):
  - Item summary

Only in target report (ID 24):
  - General Information

Section 3: Detailed Change Log

Changes Summary
- Total operations: 0
- Fields modified: 0

No differences found.
The script has completed

I think, all the information started from Section 3: is not needed to show.

The report-diff, for incompatible reports, may be shorter:

The script has started
No common checks found between the two reports for comparison.
CLARIN DSpace: Repository Health Report Diff

Section 1: Executive Summary

Report Type: healthcheck
Source Report: ID 19 at 2026-05-25 10:41:27.655
Target Report: ID 24 at 2026-05-25 11:51:03.66
Report Period: 1 hour 9 minutes 36 seconds

Section 2: Skipped Checks

The following checks could not be compared because they were not present in both reports.

Only in source report (ID 19):
  - Item summary

Only in target report (ID 24):
  - General Information

The script has completed

Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 983764fc-55c6-499a-b580-0077024aa2d5

📥 Commits

Reviewing files that changed from the base of the PR and between 4dbc684 and 1b538e4.

📒 Files selected for processing (3)
  • dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java
  • dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
  • dspace-api/src/test/java/org/dspace/scripts/ReportDiffIT.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java
  • dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
  • dspace-api/src/test/java/org/dspace/scripts/ReportDiffIT.java

📝 Walkthrough

Walkthrough

The PR modernizes DSpace health reporting and comparison scripts: HealthReport supports repeatable -c selections, -r output files, and persists ID-prefixed JSON reports; ReportDiff uses report IDs (-s/-t) with listing, defaults, intersection-based normalization, selector field resolution, and improved key-change formatting. Supporting DAOs, config, REST wiring, and tests updated.

Changes

HealthReport CLI and Report Persistence

Layer / File(s) Summary
HealthReport CLI option definitions
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReportScriptConfiguration.java
CLI option configuration updated to support -h/--help, repeatable -c/--check, -f/--for, -r/--report, and -e/--email using Option.builder.
HealthReport CLI parsing and validation
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java (lines 102–159)
setup() moved option parsing here: early-exit on -h, collect/validate multi-value -c against number of checks, validate positive integer -f, and read -r into reportFile.
HealthReport execution, filtering, and persistence
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java (lines 170–224)
Check loop filters by specificChecks, builds text and JSON payloads, persists ReportResult, constructs finalReport prefixed with stored ID, writes finalReport to reportFile, and sends finalReport via email with explicit exception logging.
HealthReport help and option display
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java (lines 237–287)
printHelp() and printCommandlineOptions() rewritten to document -h/-r and to deduplicate option keys and print all values for repeatable options.
HealthReport integration tests
dspace-api/src/test/java/org/dspace/scripts/HealthReportIT.java
Updated default header expectation and added tests for help, multiple -c usage, invalid -c/-f validation, report file saving, and storing args containing repeated -c values.

ReportDiff CLI Modernization and Comparison Logic

Layer / File(s) Summary
ReportDiff CLI option definitions
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiffScriptConfiguration.java
Options redefined: -h/--help, -l/--list with -m/--max, repeatable -c/--check, -s/--source, -t/--target, and -e/--email.
ReportDiff argument parsing and state setup
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (lines 171–272)
setup()/internalRun() parse new options, branch on help/list, default missing IDs via latest-reports logic, validate report IDs, and route to compareReports.
ReportDiff report listing and display
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (lines 373–451)
displayReportDates() now lists "Available Reports Summary" with `ID
ReportDiff comparison setup and normalization
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (lines 586–711)
compareReports fetches reports by ID, normalizeReportsToIntersection computes common check-name intersection, optionally filters by -c, and returns normalized JSON plus skipped-check lists.
ReportDiff comparison output generation
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (lines 726–830)
generateReportComparison now includes source/target IDs in the executive summary, early-returns when no common checks (emitting "Skipped Checks"), otherwise builds enhanced key-changes table and detailed changelog, and short-circuits when no differences.
ReportDiff key changes table and formatting
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (lines 985–1215)
Added selector-based field resolution (bracket attribute selectors and array indices), byte-format helpers, revised difference calculation (Added/Removed/Changed), and ID-based table headers. Legacy JSON path helpers removed.
ReportDiff integration tests
dspace-api/src/test/java/org/dspace/scripts/ReportDiffIT.java
Help/listing tests adapted to -h/-l/-m; comparisons moved to -s/-t IDs; many fixtures and assertions updated for named check paths, size-delta formatting, skipped-checks, missing-field robustness, and CLI fallback/warning behaviors.

ReportResult Service API Cleanup

Layer / File(s) Summary
Service and DAO interface cleanup
dspace-api/src/main/java/org/dspace/content/service/ReportResultService.java, dspace-api/src/main/java/org/dspace/content/dao/ReportResultDAO.java
Removed findByLastModifiedAndCheckType(Context, Date, int) from interfaces; findByLastModified(Context, Date) remains.
Service implementation cleanup
dspace-api/src/main/java/org/dspace/content/ReportResultServiceImpl.java, dspace-api/src/main/java/org/dspace/content/dao/impl/ReportResultDAOImpl.java
Removed corresponding implementations of the type-filtered lookup method.

Configuration and Integration Updates

Layer / File(s) Summary
Report diff field configuration
dspace-api/src/main/resources/report-diff-fields.json
fieldMappings and fieldOrder changed from numeric check indices (/checks/0) to named selector paths (/checks/[name=...]); directory size labels no longer include “(bytes)”.
REST script execution integration
dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ScriptRestRepository.java
runDSpaceScript captures initialize() return and early-exits when StepResult.Exit, invoking handler completion without scheduling long-running work.
Launcher configuration cleanup
dspace/config/launcher.xml
Removed legacy healthcheck command entry from launcher.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • dataquest-dev/DSpace#1040: Related — touches report persistence and ReportResult DAO/service contracts that intersect with removed/changed lookup methods.
  • dataquest-dev/DSpace#986: Related — both change health-report JSON generation/consumption and structured check payload handling.
  • dataquest-dev/DSpace#863: Related — changes to configured checks (names/ordering) that affect which checks HealthReport loads and runs.

Suggested labels

REVIEW-done

Suggested reviewers

  • milanmajchrak
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and off-topic; it provides only issue references and a checklist link without explaining the actual problem, analysis, or the substantial implementation changes (CLI restructuring, API removals, field path updates). Expand the description to include a 'Problem description' section explaining the issues being addressed, 'Analysis' covering the major changes (health-report CLI, report-diff ID-based comparison, API removals), and details on manual testing performed.
Docstring Coverage ⚠️ Warning Docstring coverage is 51.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic; it uses non-descriptive terms like 'fixes' that don't clearly convey the main scope or intent of the substantial changeset involving health-report CLI rewrites, report-diff ID-based comparison, and API removals. Provide a more specific title that highlights the primary changes, such as 'Refactor health-report and report-diff CLI to use IDs and support multi-check filtering' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (1)

342-386: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Line length exceeds 120 characters in multiple places.

Lines 369-370 and 377-378 exceed the 120-character maximum. Consider breaking these into separate lines or extracting the message strings.

📏 Suggested reformat for lines 369-370
             if (Objects.isNull(sourceReportId)) {
-                handler.logInfo("Only '-t' was specified; '-s' will be set to the latest report from the "
-                        + "database.");
+                handler.logInfo("Only '-t' was specified; '-s' will be set to the latest report "
+                        + "from the database.");

As per coding guidelines, maintain maximum 120 character line length in Java code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java` around
lines 342 - 386, In defaultReportIds, several handler.logInfo calls (the
messages for "Only '-t' was specified; '-s' will be set..." and "Only '-s' was
specified; '-t' will be set...") exceed the 120-char limit; shorten them by
splitting the long literal into two concatenated string literals or assign the
message to a local String variable and break it across lines (or use
String.format) before passing it to handler.logInfo so each source line stays
under 120 characters while keeping the same message semantics and using the
existing symbols sourceReportId, targetReportId, handler.logInfo, and
defaultReportIds.

Source: Coding guidelines

♻️ Duplicate comments (2)
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (1)

519-526: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update Javadoc to reflect ID-based comparison.

The Javadoc at line 520 still refers to "specified from and to dates," but the method now uses sourceReportId and targetReportId (IDs, not dates). Update the description to match the current implementation.

📝 Suggested Javadoc update
     /**
-     * Compare two reports based on the specified `from` and `to` dates.
+     * Compare two reports based on the specified source and target report IDs.
      * If the reports are not found, log an appropriate message.
      * If the reports are found, generate a comparison report showing the differences.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java` around
lines 519 - 526, Update the Javadoc on the compareReports method in class
ReportDiff to reflect that comparison is performed using report IDs rather than
date ranges: change the description to say it compares two reports identified by
sourceReportId and targetReportId, explains behavior when reports are missing
and that comparison uses the intersection of check names present in both
reports, and update the `@param` tags to describe sourceReportId and
targetReportId (IDs of the reports) and keep the existing `@param` context
description unchanged.
dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiffScriptConfiguration.java (1)

42-46: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Line length exceeds 120 characters.

Lines 43-44 exceed the 120-character maximum specified in the coding guidelines. Consider breaking the description string into multiple concatenated parts or reformatting the builder chain.

📏 Suggested reformat
-            Option checkOption = Option.builder("c").longOpt("check").hasArgs()
-                    .desc(String.format("Filter comparison to one or more specific checks by index (0 to %d). " +
-                            "Repeat the flag (e.g. -c 1 -c 3) to compare multiple checks from both reports.",
-                            HealthReport.getNumberOfChecks() - 1))
-                    .type(String.class)
-                    .build();
+            Option checkOption = Option.builder("c")
+                    .longOpt("check")
+                    .hasArgs()
+                    .desc(String.format(
+                            "Filter comparison to one or more specific checks by index (0 to %d). "
+                                    + "Repeat the flag (e.g. -c 1 -c 3) to compare multiple checks.",
+                            HealthReport.getNumberOfChecks() - 1))
+                    .type(String.class)
+                    .build();

As per coding guidelines, maintain maximum 120 character line length in Java code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiffScriptConfiguration.java`
around lines 42 - 46, The description string for the Option checkOption (created
via Option.builder("c").longOpt("check").hasArgs()) exceeds 120 characters;
split the desc(...) argument into multiple concatenated string literals or
separate method call segments so no source line is longer than 120 chars (e.g.,
break after a sentence or before the String.format call parameters), keeping the
same call chain and still using HealthReport.getNumberOfChecks() - 1 to compute
the upper index.

Source: Coding guidelines

🧹 Nitpick comments (5)
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java (3)

156-248: ⚡ Quick win

Missing Javadoc for public method.

The internalRun() method is public (inherited as public from DSpaceRunnable) but lacks Javadoc documentation. As per coding guidelines, all public methods in Java files must have Javadoc comments.

📝 Add Javadoc
+    /**
+     * Execute the health report generation.
+     * Runs selected checks, persists results, writes output file (if requested), and sends email (if requested).
+     * `@throws` Exception if an error occurs during report generation
+     */
     `@Override`
     public void internalRun() throws Exception {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java`
around lines 156 - 248, Add a Javadoc comment for the public method
internalRun() in class HealthReport: document purpose, thrown exceptions,
important parameters/state (e.g., use of Context, reportFile, emails) and
side-effects (persists ReportResult, writes file, sends email), and include
`@throws` Exception to match the signature; place the comment immediately above
the internalRun() method declaration so it satisfies the project's public-method
Javadoc requirement.

Source: Coding guidelines


250-265: ⚡ Quick win

Missing Javadoc for public method.

The printHelp() method is public (inherited as public from DSpaceRunnable) but lacks Javadoc documentation. As per coding guidelines, all public methods in Java files must have Javadoc comments.

📝 Add Javadoc
+    /**
+     * Print help information for the health report script.
+     * Displays available options, defaults, and the list of available checks.
+     */
     `@Override`
     public void printHelp() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java`
around lines 250 - 265, Add a Javadoc comment for the public method printHelp()
in class HealthReport: describe that it prints help/usage information for the
health report CLI, mention it overrides DSpaceRunnable.printHelp(), note that it
reads the configured "healthcheck.last_n_days" and lists available checks, and
include `@Override` and an `@since` or `@see` tag if project conventions require it;
place the Javadoc immediately above the public void printHelp() declaration so
the method is properly documented.

Source: Coding guidelines


271-292: ⚡ Quick win

Missing Javadoc for private helper method.

While the coding guideline focuses on public methods, adding Javadoc to printCommandlineOptions() would improve maintainability, especially given its role in persisting report arguments.

📝 Add Javadoc
+    /**
+     * Format command line options as a readable string.
+     * Deduplicates repeated option keys and includes all values for multi-value options.
+     * This method is used to record the options used when generating the report.
+     * `@return` formatted string of command line options
+     */
     private String printCommandlineOptions() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java`
around lines 271 - 292, Add a Javadoc comment to the private helper method
printCommandlineOptions() describing its purpose (formatting and returning the
currently parsed command-line options for inclusion in the health report), its
behavior (iterates over CommandLine options, handles multi-valued options and
de-duplicates by option key), the fact that it has no parameters, and what it
returns (a formatted String of options); attach this Javadoc directly above the
printCommandlineOptions() method signature to improve maintainability and
clarity.
dspace-api/src/main/java/org/dspace/app/healthreport/HealthReportScriptConfiguration.java (1)

33-58: ⚡ Quick win

Missing Javadoc for public method.

The getOptions() method is public but lacks Javadoc documentation. As per coding guidelines, all public methods in Java files must have Javadoc comments.

📝 Add Javadoc
+    /**
+     * Get the CLI options for the health report script.
+     * `@return` Options configured options for the script
+     */
     `@Override`
     public Options getOptions() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@dspace-api/src/main/java/org/dspace/app/healthreport/HealthReportScriptConfiguration.java`
around lines 33 - 58, Add a Javadoc block above the public method getOptions()
in class HealthReportScriptConfiguration describing its purpose (builds and
returns CLI Options for the health report script), the fact it caches the
Options instance, the return type (Options), and any behavior notes (which flags
are added, e.g. -h/--help, -e/--email, -c/--check, -f/--for, -r/--report);
include `@return` describing the returned Options and `@since/`@author tags if your
project requires them.

Source: Coding guidelines

dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java (1)

317-322: 💤 Low value

Dead code: XOR validation is unreachable after defaultReportIds().

The check at lines 318-322 validates that both sourceReportId and targetReportId are set (neither is null while the other isn't). However, this method is only called after defaultReportIds() has already executed (line 256), which fills any missing ID. After defaultReportIds(), either both IDs are set or both remain null (if insufficient reports exist in the DB), so the XOR condition will never be true.

Consider removing lines 318-322 or moving this validation earlier in the flow (before defaultReportIds()) if you want to enforce that users must supply both IDs explicitly.

♻️ Option 1: Remove dead XOR check
     private boolean validateReportIdSelection() {
-        if ((Objects.isNull(sourceReportId) && Objects.nonNull(targetReportId))
-                || (Objects.nonNull(sourceReportId) && Objects.isNull(targetReportId))) {
-            handler.logError("Both 'source' and 'target' report IDs must be specified.");
-            return false;
-        }
-
         if (Objects.nonNull(sourceReportId) && sourceReportId <= 0) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java` around
lines 317 - 322, The XOR null-check in validateReportIdSelection() (the
conditional that logs via handler.logError when exactly one of
sourceReportId/targetReportId is null) is dead after defaultReportIds()
populates missing IDs; either remove that XOR branch from
validateReportIdSelection() or call validateReportIdSelection() before
defaultReportIds() so the XOR check can catch user-supplied-only cases. Update
the call site around defaultReportIds()/validateReportIdSelection() accordingly
and keep the handler.logError usage (or remove it if you choose deletion) to
ensure behavior remains consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java`:
- Around line 342-386: In defaultReportIds, several handler.logInfo calls (the
messages for "Only '-t' was specified; '-s' will be set..." and "Only '-s' was
specified; '-t' will be set...") exceed the 120-char limit; shorten them by
splitting the long literal into two concatenated string literals or assign the
message to a local String variable and break it across lines (or use
String.format) before passing it to handler.logInfo so each source line stays
under 120 characters while keeping the same message semantics and using the
existing symbols sourceReportId, targetReportId, handler.logInfo, and
defaultReportIds.

---

Duplicate comments:
In `@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java`:
- Around line 519-526: Update the Javadoc on the compareReports method in class
ReportDiff to reflect that comparison is performed using report IDs rather than
date ranges: change the description to say it compares two reports identified by
sourceReportId and targetReportId, explains behavior when reports are missing
and that comparison uses the intersection of check names present in both
reports, and update the `@param` tags to describe sourceReportId and
targetReportId (IDs of the reports) and keep the existing `@param` context
description unchanged.

In
`@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiffScriptConfiguration.java`:
- Around line 42-46: The description string for the Option checkOption (created
via Option.builder("c").longOpt("check").hasArgs()) exceeds 120 characters;
split the desc(...) argument into multiple concatenated string literals or
separate method call segments so no source line is longer than 120 chars (e.g.,
break after a sentence or before the String.format call parameters), keeping the
same call chain and still using HealthReport.getNumberOfChecks() - 1 to compute
the upper index.

---

Nitpick comments:
In `@dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java`:
- Around line 156-248: Add a Javadoc comment for the public method internalRun()
in class HealthReport: document purpose, thrown exceptions, important
parameters/state (e.g., use of Context, reportFile, emails) and side-effects
(persists ReportResult, writes file, sends email), and include `@throws` Exception
to match the signature; place the comment immediately above the internalRun()
method declaration so it satisfies the project's public-method Javadoc
requirement.
- Around line 250-265: Add a Javadoc comment for the public method printHelp()
in class HealthReport: describe that it prints help/usage information for the
health report CLI, mention it overrides DSpaceRunnable.printHelp(), note that it
reads the configured "healthcheck.last_n_days" and lists available checks, and
include `@Override` and an `@since` or `@see` tag if project conventions require it;
place the Javadoc immediately above the public void printHelp() declaration so
the method is properly documented.
- Around line 271-292: Add a Javadoc comment to the private helper method
printCommandlineOptions() describing its purpose (formatting and returning the
currently parsed command-line options for inclusion in the health report), its
behavior (iterates over CommandLine options, handles multi-valued options and
de-duplicates by option key), the fact that it has no parameters, and what it
returns (a formatted String of options); attach this Javadoc directly above the
printCommandlineOptions() method signature to improve maintainability and
clarity.

In
`@dspace-api/src/main/java/org/dspace/app/healthreport/HealthReportScriptConfiguration.java`:
- Around line 33-58: Add a Javadoc block above the public method getOptions() in
class HealthReportScriptConfiguration describing its purpose (builds and returns
CLI Options for the health report script), the fact it caches the Options
instance, the return type (Options), and any behavior notes (which flags are
added, e.g. -h/--help, -e/--email, -c/--check, -f/--for, -r/--report); include
`@return` describing the returned Options and `@since/`@author tags if your project
requires them.

In `@dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java`:
- Around line 317-322: The XOR null-check in validateReportIdSelection() (the
conditional that logs via handler.logError when exactly one of
sourceReportId/targetReportId is null) is dead after defaultReportIds()
populates missing IDs; either remove that XOR branch from
validateReportIdSelection() or call validateReportIdSelection() before
defaultReportIds() so the XOR check can catch user-supplied-only cases. Update
the call site around defaultReportIds()/validateReportIdSelection() accordingly
and keep the handler.logError usage (or remove it if you choose deletion) to
ensure behavior remains consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34707414-4957-4bfc-8053-9a5cda1c39df

📥 Commits

Reviewing files that changed from the base of the PR and between 2f03408 and 94e53d2.

📒 Files selected for processing (13)
  • dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java
  • dspace-api/src/main/java/org/dspace/app/healthreport/HealthReportScriptConfiguration.java
  • dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
  • dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiffScriptConfiguration.java
  • dspace-api/src/main/java/org/dspace/content/ReportResultServiceImpl.java
  • dspace-api/src/main/java/org/dspace/content/dao/ReportResultDAO.java
  • dspace-api/src/main/java/org/dspace/content/dao/impl/ReportResultDAOImpl.java
  • dspace-api/src/main/java/org/dspace/content/service/ReportResultService.java
  • dspace-api/src/main/resources/report-diff-fields.json
  • dspace-api/src/test/java/org/dspace/scripts/HealthReportIT.java
  • dspace-api/src/test/java/org/dspace/scripts/ReportDiffIT.java
  • dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ScriptRestRepository.java
  • dspace/config/launcher.xml
💤 Files with no reviewable changes (4)
  • dspace-api/src/main/java/org/dspace/content/ReportResultServiceImpl.java
  • dspace-api/src/main/java/org/dspace/content/service/ReportResultService.java
  • dspace-api/src/main/java/org/dspace/content/dao/ReportResultDAO.java
  • dspace-api/src/main/java/org/dspace/content/dao/impl/ReportResultDAOImpl.java

Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
try (Context context = new Context()) {
defaultDate(context);
// If at least one of -s/-t is missing, fill missing values from latest reports.
if (Objects.isNull(sourceReportId) || Objects.isNull(targetReportId)) {

@kuchtiak-ufal kuchtiak-ufal Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor comment:
May be shorter version:

if (sourceReportId == null || tergetReportId == null) {
...
)

Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/app/reportdiff/ReportDiff.java Outdated
…ecks section, validate report IDs before defaulting

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@milanmajchrak milanmajchrak merged commit 3dc9cec into dtq-dev Jun 12, 2026
11 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.

UFAL/Health report bugs and improvements

5 participants