Skip to content

Apply conservative Rector cleanup#70

Merged
dereuromark merged 5 commits into
masterfrom
rector-cleanup-20260524
May 25, 2026
Merged

Apply conservative Rector cleanup#70
dereuromark merged 5 commits into
masterfrom
rector-cleanup-20260524

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

Applies the same conservative, behavior-neutral Rector cleanup pass as used in dereuromark/cakephp-ide-helper#452, but without committing Rector config or dependency wiring here.

  • dead-code and code-quality simplifications only
  • excludes the same unsafe / opinionated ruleset areas
  • keeps the PR scope to generated cleanup changes in src/ and tests/

This was generated with a temporary local Rector config and followed with CS fixes where needed.

Copilot AI review requested due to automatic review settings May 24, 2026 16:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Applies a conservative, behavior-intended Rector cleanup across src/ and tests/, simplifying conditionals and modernizing a few string operations while keeping the overall plugin behavior the same.

Changes:

  • Modernizes string checks/casts in a few places (e.g., str_contains, str_starts_with, explicit (string) casts).
  • Refactors some control-flow and return/assignment patterns (ternaries, simplified loops, return concatenation).
  • Minor controller view-var setting refactors (set([...])).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/TestCase/Model/Table/DatabaseLogsTableTest.php Casts summary to string before mb_strlen() in test assertion.
tests/schema.php Simplifies catch (ReflectionException $e) to catch (ReflectionException).
src/Model/Table/LazyTableTrait.php Changes SQLite “unable to open” handling to throw a chained RuntimeException.
src/Model/Table/DatabaseLogsTable.php Refactors date-expression selection logic; simplifies duplicate-removal loop; minor string casts/return refactor.
src/Model/Entity/DatabaseLog.php Replaces strpos(...) === 0 with str_starts_with(...).
src/Log/Engine/DatabaseLog.php Simplifies default model selection conditional.
src/Controller/Admin/LogsController.php Replaces set(compact(...)) with explicit array mapping.
src/Controller/Admin/DatabaseLogController.php Replaces set(compact(...)) with explicit array mapping.
src/Controller/Admin/DatabaseLogAppController.php Removes redundant ForbiddenException rethrow catch in beforeFilter().
src/Command/ShowCommand.php Uses str_contains() and adds string cast before trimming message.
src/Command/ExportCommand.php Condenses type-selection conditional into a ternary expression.
Comments suppressed due to low confidence (2)

src/Controller/Admin/DatabaseLogAppController.php:98

  • Removing the dedicated ForbiddenException catch changes behavior: a ForbiddenException thrown from the configured adminAccess gate will now be logged and replaced with the generic "admin access denied" message instead of propagating the original ForbiddenException. If preserving the gate’s intended exception/message is important, rethrow ForbiddenException before the generic Throwable handler (or narrow the catch).
		try {
			$allowed = $gate($this->request) === true;
		} catch (Throwable $e) {
			Log::warning(sprintf('DatabaseLog.adminAccess threw %s: %s', $e::class, $e->getMessage()));

			throw new ForbiddenException(__d('database_log', 'DatabaseLog admin access denied.'));
		}

src/Model/Table/DatabaseLogsTable.php:264

  • Indentation is inconsistent within this conditional block (spaces vs tabs), and the closing brace alignment becomes off relative to surrounding code. Reformat this else/elseif chain to use tabs consistently per .editorconfig.
            // MySQL
            $dateExpr = "DATE_FORMAT(created, '%Y-%m-%d %H')";
        } else {
				$dateExpr = "DATE_FORMAT(created, '%Y-%m-%d')";
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Model/Table/LazyTableTrait.php Outdated
Comment thread src/Model/Table/DatabaseLogsTable.php Outdated
Copilot AI review requested due to automatic review settings May 24, 2026 17:51
Copy link
Copy Markdown

Copilot AI left a comment

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 11 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Controller/Admin/DatabaseLogAppController.php:98

  • Removing the dedicated catch (ForbiddenException) changes behavior: if DatabaseLog.adminAccess intentionally throws ForbiddenException (e.g. with a specific message/status), it will now be caught by the Throwable handler, logged as a warning, and replaced with a generic ForbiddenException. Consider re-adding the ForbiddenException catch to rethrow it (or checking $e instanceof ForbiddenException inside the Throwable catch and rethrowing) so intentional denials aren’t treated as unexpected errors.
		try {
			$allowed = $gate($this->request) === true;
		} catch (Throwable $e) {
			Log::warning(sprintf('DatabaseLog.adminAccess threw %s: %s', $e::class, $e->getMessage()));

			throw new ForbiddenException(__d('database_log', 'DatabaseLog admin access denied.'));
		}

Copilot AI review requested due to automatic review settings May 25, 2026 03:16
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 25, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.46%. Comparing base (dd7d088) to head (ca79974).

Files with missing lines Patch % Lines
src/Model/Table/LazyTableTrait.php 0.00% 2 Missing ⚠️
src/Command/ShowCommand.php 50.00% 1 Missing ⚠️
src/Model/Table/DatabaseLogsTable.php 87.50% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #70      +/-   ##
============================================
+ Coverage     81.07%   81.46%   +0.39%     
  Complexity      186      186              
============================================
  Files            17       17              
  Lines           634      626       -8     
============================================
- Hits            514      510       -4     
+ Misses          120      116       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

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 no new comments.

@dereuromark dereuromark merged commit 93fb9ae into master May 25, 2026
20 checks passed
@dereuromark dereuromark deleted the rector-cleanup-20260524 branch May 25, 2026 03:21
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.

3 participants