Skip to content

Added the McLogCleaner-Plugin#99

Open
JuggleGaming wants to merge 7 commits intopelican-dev:mainfrom
JuggleGaming:mclogcleaner
Open

Added the McLogCleaner-Plugin#99
JuggleGaming wants to merge 7 commits intopelican-dev:mainfrom
JuggleGaming:mclogcleaner

Conversation

@JuggleGaming
Copy link
Contributor

@JuggleGaming JuggleGaming commented Feb 9, 2026

McLogCleaner

McLogCleaner automatically deletes all .log.gz files from the server’s logs folder.

Note: latest.yml will always remain intact and is never deleted.

Usage

To use this plugin, add mclogcleaner as a feature to the egg you want to run it with.

Log Deletion Options

When you click Delete logs, a dropdown menu appears where you can choose the minimum age (in days) of log files to delete:

  • Logs older than 7 days
  • Logs older than 30 days
  • All logs (regardless of age)
  • A custom age in days

Summary by CodeRabbit

  • New Features

    • Added McLogCleaner plugin to simplify Minecraft server log cleanup.
    • Supports cleanup modes: older than 7 days, older than 30 days, all logs, or a custom duration.
    • Adds a header action to initiate cleanup with interactive options and user notifications.
    • Preserves latest.log during cleanup.
  • Documentation

    • Added McLogCleaner documentation and setup guide with usage and configuration options.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Adds a new McLogCleaner plugin that provides a Filament header action to list and delete Minecraft .log.gz files on a server, plus plugin manifest, provider, config placeholder, feature-detection enum, and user-facing README documentation.

Changes

Cohort / File(s) Summary
Documentation & Manifest
README.md, mclogcleaner/README.md, mclogcleaner/plugin.json
Add plugin manifest and documentation describing purpose, usage, and available deletion modes.
Configuration
mclogcleaner/config/logcleaner.php
Add placeholder PHP config file returning an array for LogCleaner settings.
Plugin Core & Provider
mclogcleaner/src/McLogCleanerPlugin.php, mclogcleaner/src/Providers/McLogCleanerPluginProvider.php
Add plugin class implementing Filament Plugin interface and a service provider that registers the McLogCleanAction as a header action.
Filament Action
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php
Add modal Filament action to select deletion mode (7/30/custom/all), list files via server API, filter .log.gz files by parsed date, and request deletion; includes error handling and notifications.
Feature Detection Enum
mclogcleaner/src/Enums/EggFeature.php
Add enum with helpers to detect the mclogcleaner egg feature on a Server model.

Sequence Diagram

sequenceDiagram
    actor Admin as Admin
    participant Filament as Filament UI
    participant Action as McLogCleanAction
    participant API as Server API
    participant FS as Server Filesystem

    Admin->>Filament: Trigger "Clean Logs"
    Filament->>Action: Open modal & submit mode
    Action->>Action: Resolve server & compute threshold
    Action->>API: GET /client/servers/:id/files?directory=/logs
    API->>FS: List /logs files
    FS-->>API: Return file list
    API-->>Action: Return listing
    Action->>Action: Filter `.log.gz` by parsed date > threshold
    alt files to delete found
        Action->>API: POST /client/servers/:id/files/delete (paths)
        API->>FS: Delete files
        FS-->>API: Deletion result
        API-->>Action: Success
        Action->>Filament: Notify success (n deleted)
    else none found
        Action->>Filament: Notify success (none found)
    end
    Filament-->>Admin: Show result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • lajczi
  • rmartinoscar

Poem

🐰 I nibbled through logs by moonlit gleam,

Removed old crumbs so servers dream,
Seven, thirty, or custom days gone,
McLogCleaner hops at dawn — logs drawn! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Added the McLogCleaner-Plugin' accurately summarizes the main change—introducing a new plugin called McLogCleaner that automatically deletes log files from Minecraft servers.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🤖 Fix all issues with AI agents
In `@mclogcleaner/plugin.json`:
- Around line 1-15: The plugin ID in plugin.json ("id": "mclogcleaner") does not
match the value returned by McLogCleanerPlugin::getId() (which returns
'logcleaner'); update one of them so both IDs are identical—either change the
"id" field in plugin.json to "logcleaner" or modify McLogCleanerPlugin::getId()
to return "mclogcleaner"—so that registration/lookup uses the same unique
identifier.

In `@mclogcleaner/README.md`:
- Line 5: Update the README.md line that currently reads "latest.yml" (the
literal string "latest.yml") — replace it with "latest.log" to reflect the
correct Minecraft log filename, or remove the note entirely since the cleaner
only deletes ".log.gz" files and therefore already preserves latest.log; ensure
the change targets the README.md sentence mentioning "latest.yml".

In `@mclogcleaner/src/Enums/CheckEgg.php`:
- Around line 1-8: Pint flagged a class_definition style issue and the enum name
CheckEgg is verb-like; run ./vendor/bin/pint to auto-fix formatting in
JuggleGaming\McLogCleaner\Enums\CheckEgg.php, then rename the enum CheckEgg to a
noun (suggestions: ServerFeature or EggFeature) and update all references/usages
(type hints, imports, switch/case and serialization keys) to the new name (e.g.,
ServerFeature) so the codebase remains consistent and linting passes.
- Line 14: The assignment in CheckEgg.php directly accesses
$server->egg->features which can throw when egg is null; change the access to
use PHP's null-safe operator so the code reads the egg relation safely (use
$server->egg?->features) and keep the existing fallback to an empty array with
the null-coalescing operator so $features becomes the egg's features when
present or [] when not.

In `@mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php`:
- Around line 137-145: In the catch block inside McLogCleanAction where you call
report($e) and build the Notification (the
Notification::make()->title(...)->body($e->getMessage())->danger()->send()
sequence), replace the direct use of $e->getMessage() with a generic,
user-facing message (e.g. "An error occurred while cleaning logs. Please try
again or contact support.") so internal details are not exposed; keep the
report($e) call unchanged so full error details remain logged for debugging.
Ensure the Notification body no longer references $e or any exception
properties.
- Around line 28-31: Filament::getTenant() returns Model|null but code in the
hidden callback and the action callback uses Server-specific properties
($server->node and $server->uuid), causing PHPStan errors; update both spots
(the anonymous hidden closure and the action callback in McLogCleanAction) to
either cast/assert the tenant as Server (e.g., /** `@var` Server $server */ before
use) or perform an early null check/return to ensure $server is a Server before
accessing ->node or ->uuid so PHPStan knows the type and null safety is
guaranteed.
- Around line 149-155: The extractLogDate function can call
Carbon::createFromFormat which may return false for invalid dates; update
extractLogDate to capture the result of Carbon::createFromFormat('Y-m-d',
$matches[1]) into a variable, check that the result is a valid Carbon instance
(or truthy) before calling ->startOfDay(), and return null if the parse returned
false/invalid; reference the extractLogDate method and the
Carbon::createFromFormat call when applying this guard.

In `@mclogcleaner/src/McLogCleanerPlugin.php`:
- Around line 10-17: Update the plugin ID and PSR-12 brace placement: change
getId() to return "mclogcleaner" so it matches plugin.json, and reformat the
empty methods register(Panel $panel) and boot(Panel $panel) to use PSR-12 style
braces (opening brace on its own line) with no stray space before the empty
block braces; ensure the method signatures remain register(Panel $panel): void
and boot(Panel $panel): void and keep types intact.

In `@mclogcleaner/src/Providers/McLogCleanerPluginProvider.php`:
- Around line 10-18: The class and method opening braces in
McLogCleanerPluginProvider violate PSR-12 (class_attribute) — move the class
opening brace and each method's opening brace onto their own lines and adjust
indentation/spacing to match PSR-12; update the class declaration for
McLogCleanerPluginProvider so the "{" is on the next line and do the same for
the register() and boot() methods, ensuring consistent one-tab (or PSR-12
configured) indentation and blank lines between methods.
🧹 Nitpick comments (4)
mclogcleaner/config/logcleaner.php (1)

1-5: Empty config file is unused.

No config values are referenced anywhere in the plugin code — options like default mode, day thresholds, and max custom days are hardcoded in McLogCleanAction.php. Consider either populating this with configurable values that the action reads, or removing the file to avoid dead scaffolding.

mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (2)

43-63: Select option keys use mixed types — consider using string keys consistently.

The mode Select mixes integer keys (7, 30, -1) with a string key ('custom'). While the current cast logic at Lines 69–79 handles this correctly, Filament Select values are always submitted as strings. Using consistent string keys (e.g., '7', '30', 'all', 'custom') would make the type handling more explicit and less fragile.


115-121: "No logs found" notification uses success style — consider info or warning.

When no logs match the selection, a ->success() notification is sent (Line 119). This could be misleading since nothing was actually accomplished. Using ->info() or ->warning() would better convey the outcome.

📝 Proposed fix
                 if (empty($logsToDelete)) {
                     Notification::make()
                         ->title('McLogCleaner')
                         ->body('No logs matching your selection were found.')
-                        ->success()
+                        ->info()
                         ->send();
                     return;
                 }
mclogcleaner/src/Enums/CheckEgg.php (1)

7-27: Single-case enum is over-engineered for a feature flag check.

This enum has exactly one case and two static methods — it's effectively a static helper class. If you don't plan to add more feature cases, a simple static method (e.g., on a ServerFeature utility class) would be clearer. If you do plan to extend this with additional egg features, the enum approach is fine — just consider renaming it to reflect that broader purpose.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9a53e3 and 452d118.

📒 Files selected for processing (8)
  • README.md
  • mclogcleaner/README.md
  • mclogcleaner/config/logcleaner.php
  • mclogcleaner/plugin.json
  • mclogcleaner/src/Enums/CheckEgg.php
  • mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php
  • mclogcleaner/src/McLogCleanerPlugin.php
  • mclogcleaner/src/Providers/McLogCleanerPluginProvider.php
🧰 Additional context used
🧬 Code graph analysis (3)
mclogcleaner/src/McLogCleanerPlugin.php (1)
mclogcleaner/src/Providers/McLogCleanerPluginProvider.php (2)
  • register (12-14)
  • boot (16-16)
mclogcleaner/src/Providers/McLogCleanerPluginProvider.php (2)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (1)
  • McLogCleanAction (17-156)
mclogcleaner/src/McLogCleanerPlugin.php (2)
  • register (15-15)
  • boot (17-17)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (1)
mclogcleaner/src/Enums/CheckEgg.php (1)
  • serverSupportsLogCleaner (23-26)
🪛 GitHub Actions: Lint
mclogcleaner/src/McLogCleanerPlugin.php

[error] 1-1: Pint linting issue: function_declaration, braces_posi

mclogcleaner/src/Enums/CheckEgg.php

[error] 1-1: Pint linting issue: class_definition

mclogcleaner/src/Providers/McLogCleanerPluginProvider.php

[error] 1-1: Pint linting issue: class_attribute

mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

[error] 1-1: Pint linting issue: no_unus

🪛 GitHub Check: PHPStan (8.2)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

[failure] 125-125:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 124-124:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 83-83:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 82-82:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 30-30:
Parameter #1 $server of static method JuggleGaming\McLogCleaner\Enums\CheckEgg::serverSupportsLogCleaner() expects App\Models\Server, Illuminate\Database\Eloquent\Model|null given.

🪛 GitHub Check: PHPStan (8.3)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

[failure] 125-125:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 124-124:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 83-83:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 82-82:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 30-30:
Parameter #1 $server of static method JuggleGaming\McLogCleaner\Enums\CheckEgg::serverSupportsLogCleaner() expects App\Models\Server, Illuminate\Database\Eloquent\Model|null given.

🪛 GitHub Check: PHPStan (8.4)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

[failure] 125-125:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 124-124:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 83-83:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 82-82:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 30-30:
Parameter #1 $server of static method JuggleGaming\McLogCleaner\Enums\CheckEgg::serverSupportsLogCleaner() expects App\Models\Server, Illuminate\Database\Eloquent\Model|null given.

🪛 GitHub Check: PHPStan (8.5)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

[failure] 125-125:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 124-124:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 83-83:
Access to an undefined property Illuminate\Database\Eloquent\Model::$uuid.


[failure] 82-82:
Access to an undefined property Illuminate\Database\Eloquent\Model::$node.


[failure] 30-30:
Parameter #1 $server of static method JuggleGaming\McLogCleaner\Enums\CheckEgg::serverSupportsLogCleaner() expects App\Models\Server, Illuminate\Database\Eloquent\Model|null given.

🪛 PHPMD (2.15.0)
mclogcleaner/src/McLogCleanerPlugin.php

[warning] 15-15: Avoid unused parameters such as '$panel'. (undefined)

(UnusedFormalParameter)


[warning] 17-17: Avoid unused parameters such as '$panel'. (undefined)

(UnusedFormalParameter)

🔇 Additional comments (1)
README.md (1)

27-27: LGTM!

Plugin entry is correctly placed in alphabetical order and follows the existing format.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

{
$server->loadMissing('egg');

$features = $server->egg->features ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Null-safe access needed on $server->egg.

If the server has no associated egg (relation returns null), $server->egg->features will trigger a deprecation warning in PHP 8.2+ and a TypeError in PHP 9. Use the null-safe operator:

Proposed fix
-        $features = $server->egg->features ?? [];
+        $features = $server->egg?->features ?? [];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$features = $server->egg->features ?? [];
$features = $server->egg?->features ?? [];
🤖 Prompt for AI Agents
In `@mclogcleaner/src/Enums/CheckEgg.php` at line 14, The assignment in
CheckEgg.php directly accesses $server->egg->features which can throw when egg
is null; change the access to use PHP's null-safe operator so the code reads the
egg relation safely (use $server->egg?->features) and keep the existing fallback
to an empty array with the null-coalescing operator so $features becomes the
egg's features when present or [] when not.

@JuggleGaming JuggleGaming marked this pull request as draft February 9, 2026 13:38
@JuggleGaming JuggleGaming marked this pull request as draft February 9, 2026 13:38
@JuggleGaming JuggleGaming marked this pull request as ready for review February 9, 2026 14:12
@JuggleGaming
Copy link
Contributor Author

I guess it is ready for review. I am not getting how to fix the issue with this blank line... but this shouldn`t be any problem for the endresult - this plugin.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@mclogcleaner/src/Enums/EggFeature.php`:
- Around line 13-15: The current access of $server->egg->features can throw a
null dereference if $server->egg is null; update the access to use PHP's
nullsafe operator so the expression becomes $server->egg?->features ?? [] (keep
the existing $server->loadMissing('egg') call and assign to $features) to safely
fallback to an empty array when no egg is present; locate the code around the
$server->loadMissing('egg') call and replace the direct property access to
egg->features with the nullsafe form.

In `@mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php`:
- Line 1: The Pint lint error is caused by style issues in McLogCleanAction.php;
run the auto-fixer to correct formatting by executing ./vendor/bin/pint
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (or run Pint
across the project) and commit the updated file; if you prefer manual fixes,
open McLogCleanAction.php (class McLogCleanAction) and apply Pint's suggested
formatting (fix PHP open tag/whitespace and PSR-style formatting) so the file
passes CI.
🧹 Nitpick comments (2)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (2)

100-120: Edge case: files without a parseable date are silently skipped when using age-based filtering.

When $days > 0, files whose names don't match the YYYY-MM-DD pattern (e.g., a manually renamed log) will have extractLogDate return null and be excluded from deletion (Line 111-112). This is a safe default, but worth noting — users selecting "older than 7 days" might not realize some .log.gz files are being skipped because they lack a date in the filename.

Consider adding a note in the modal description or documenting this behavior.


88-94: Add explicit timeouts to daemon HTTP calls to prevent indefinite hangs.

The two Http::daemon() calls at lines 89 and 131 lack explicit timeouts. If the daemon becomes unresponsive, the request will block until PHP's default timeout is reached. Add .timeout() to each call to fail fast.

Proposed fix
-                $files = Http::daemon($server->node)
+                $files = Http::daemon($server->node)->timeout(15)
                     ->get("/api/servers/{$server->uuid}/files/list-directory", [
-                Http::daemon($server->node)
+                Http::daemon($server->node)->timeout(15)
                     ->post("/api/servers/{$server->uuid}/files/delete", [
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 452d118 and 6ccf949.

📒 Files selected for processing (5)
  • mclogcleaner/README.md
  • mclogcleaner/src/Enums/EggFeature.php
  • mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php
  • mclogcleaner/src/McLogCleanerPlugin.php
  • mclogcleaner/src/Providers/McLogCleanerPluginProvider.php
✅ Files skipped from review due to trivial changes (1)
  • mclogcleaner/README.md
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-04T11:13:45.197Z
Learnt from: HarlequinSin
Repo: pelican-dev/plugins PR: 67
File: subdomains/src/Models/Subdomain.php:49-65
Timestamp: 2026-01-04T11:13:45.197Z
Learning: In Subdomain model creating hook at subdomains/src/Models/Subdomain.php, the code uses setRelation('server', Filament::getTenant()) because the model hasn't been saved yet and load() won't work during creation. This is intentional for Filament-context creation.

Applied to files:

  • mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php
🧬 Code graph analysis (3)
mclogcleaner/src/Providers/McLogCleanerPluginProvider.php (2)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (1)
  • McLogCleanAction (17-164)
mclogcleaner/src/McLogCleanerPlugin.php (2)
  • register (15-18)
  • boot (20-23)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (1)
mclogcleaner/src/Enums/EggFeature.php (1)
  • serverSupportsLogCleaner (24-27)
mclogcleaner/src/McLogCleanerPlugin.php (1)
mclogcleaner/src/Providers/McLogCleanerPluginProvider.php (2)
  • register (12-15)
  • boot (17-20)
🪛 GitHub Actions: Lint
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

[error] 1-1: Pint lint/style issue detected in McLogCleanAction.php during --test (exit code 1). Likely a blank line/style problem (exact issue not fully shown in log).

🪛 PHPMD (2.15.0)
mclogcleaner/src/McLogCleanerPlugin.php

[warning] 15-15: Avoid unused parameters such as '$panel'. (undefined)

(UnusedFormalParameter)


[warning] 20-20: Avoid unused parameters such as '$panel'. (undefined)

(UnusedFormalParameter)

🔇 Additional comments (4)
mclogcleaner/src/McLogCleanerPlugin.php (1)

8-24: LGTM!

The plugin class correctly implements the Plugin interface with the matching ID 'mclogcleaner'. The unused $panel parameters are required by the interface contract.

mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (2)

46-57: Select option keys may behave unexpectedly as string types.

Filament Select values are strings when submitted. The integer keys 7, 30, -1 on Lines 50-52 will be received as '7', '30', '-1' in $data['mode']. The current handling on Lines 76-86 correctly accounts for this via the (int) cast, so this works — just noting it for awareness in case the mode-handling logic is refactored later.


156-163: LGTM — Carbon::createFromFormat false-guard is in place.

The guard on Line 160 correctly handles the case where createFromFormat returns false for an invalid date string.

mclogcleaner/src/Providers/McLogCleanerPluginProvider.php (1)

12-15: The code follows the established pattern in this codebase. All plugins (pastefox-share, mclogs-uploader, user-creatable-servers) register header actions in register(), not boot(). This is the consistent convention for the plugin system, and no change is needed.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +13 to +15
$server->loadMissing('egg');

$features = $server->egg->features ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Potential null dereference when $server->egg is null.

If a server has no associated egg, $server->egg returns null and $server->egg->features will throw a "property access on null" error in PHP 8+. The ?? operator does not prevent this — it only handles the case where the entire expression evaluates to null without error. Use the nullsafe operator instead.

🛡️ Proposed fix
-        $features = $server->egg->features ?? [];
+        $features = $server->egg?->features ?? [];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$server->loadMissing('egg');
$features = $server->egg->features ?? [];
$server->loadMissing('egg');
$features = $server->egg?->features ?? [];
🤖 Prompt for AI Agents
In `@mclogcleaner/src/Enums/EggFeature.php` around lines 13 - 15, The current
access of $server->egg->features can throw a null dereference if $server->egg is
null; update the access to use PHP's nullsafe operator so the expression becomes
$server->egg?->features ?? [] (keep the existing $server->loadMissing('egg')
call and assign to $features) to safely fallback to an empty array when no egg
is present; locate the code around the $server->loadMissing('egg') call and
replace the direct property access to egg->features with the nullsafe form.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php`:
- Around line 69-74: The action callback passed to $this->action (the closure
starting with function (array $data) in McLogCleanAction.php) should not return
a value; remove the "return true;" and instead just exit the closure (e.g., use
plain "return;" or let the function fall through) so the action callback is
void, leaving the boolean return only for the visibility callback (the hidden
closure referenced earlier).
🧹 Nitpick comments (2)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (2)

100-120: Consider validating filenames to prevent path-traversal via crafted .log.gz entries.

A file named ../../etc/important.log.gz would pass the str_ends_with check and be sent as logs/../../etc/important.log.gz to the delete endpoint. While the listing comes from the daemon (trusted), adding a basename() guard is inexpensive defense-in-depth.

Proposed fix
                 $logsToDelete = collect($files)
-                    ->filter(fn ($file) => str_ends_with($file['name'], '.log.gz'))
+                    ->filter(fn ($file) => isset($file['name'])
+                        && str_ends_with($file['name'], '.log.gz')
+                        && basename($file['name']) === $file['name'])

57-57: Replace deprecated reactive() with live()

In Filament v3, ->reactive() has been replaced by ->live(). While reactive() may still work for backward compatibility, live() is the recommended approach going forward.

live() also supports options for fine-tuning reactivity: ->live(onBlur: true) to re-render on blur or ->live(debounce: 500) to debounce updates.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ccf949 and e605074.

📒 Files selected for processing (1)
  • mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php
🧰 Additional context used
🧬 Code graph analysis (1)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (1)
mclogcleaner/src/Enums/EggFeature.php (1)
  • serverSupportsLogCleaner (24-27)
🔇 Additional comments (2)
mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php (2)

28-35: Previous review feedback has been addressed.

The PHPStan type-narrowing with instanceof Server, the generic error message in the catch block, and the Carbon::createFromFormat false-guard are all properly implemented now.

Also applies to: 144-152, 156-163


37-67: Modal form setup looks good.

The confirmation modal, select options, and conditional custom_days input are well-structured.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +69 to +74
$this->action(function (array $data) {
/** `@var` Server|null $server */
$server = Filament::getTenant();
if (!$server instanceof Server) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Action callback should not return a value.

Line 73: return true; is semantically incorrect in a Filament action callback, which expects void. The hidden callback (line 28) correctly returns a boolean because it controls visibility, but the action callback should simply bail out.

Proposed fix
         $this->action(function (array $data) {
             /** `@var` Server|null $server */
             $server = Filament::getTenant();
             if (!$server instanceof Server) {
-                return true;
+                return;
             }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$this->action(function (array $data) {
/** `@var` Server|null $server */
$server = Filament::getTenant();
if (!$server instanceof Server) {
return true;
}
$this->action(function (array $data) {
/** `@var` Server|null $server */
$server = Filament::getTenant();
if (!$server instanceof Server) {
return;
}
🤖 Prompt for AI Agents
In `@mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php` around
lines 69 - 74, The action callback passed to $this->action (the closure starting
with function (array $data) in McLogCleanAction.php) should not return a value;
remove the "return true;" and instead just exit the closure (e.g., use plain
"return;" or let the function fall through) so the action callback is void,
leaving the boolean return only for the visibility callback (the hidden closure
referenced earlier).

@JuggleGaming
Copy link
Contributor Author

vendor/bin/pint --test results in a pass for me on my server therefore i do not understand what the problem is here in github...

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.

1 participant