Skip to content

Fix various code styles and CI issues#66

Merged
JeroenDeDauw merged 7 commits into
masterfrom
fix-ci-2
Feb 26, 2025
Merged

Fix various code styles and CI issues#66
JeroenDeDauw merged 7 commits into
masterfrom
fix-ci-2

Conversation

@alistair3149

@alistair3149 alistair3149 commented Feb 25, 2025

Copy link
Copy Markdown
Member

Follow up to #65

  • Bump minimum MW requirement to 1.39
  • Fix various code styles issues raised by CI
  • Add bootstrap file for phpstan
  • Bump phpstan from ^0.12.99 to ^2.0.2
  • Bump psalm from from ^4.10 to ^4.30.0
  • Bump mediawiki/mediawiki-codesniffer from 37.0.0 to 45.0.0
  • Allow dealerdirect/phpcodesniffer-composer-installer composer plugin

Summary by CodeRabbit

Summary by CodeRabbit

  • Documentation
    • Updated release notes for version 3.0.0 and revised platform requirements to MediaWiki 1.39 or later.
  • Chores
    • Upgraded development dependencies, including vimeo/psalm, phpstan/phpstan, and mediawiki/mediawiki-codesniffer.
    • Refined configuration settings for allowed plugins.
    • Applied minor code-style improvements in various files.

@alistair3149 alistair3149 changed the title Fix various CS and CI errors 3.0.0 release Feb 25, 2025
@alistair3149
alistair3149 marked this pull request as ready for review February 25, 2025 23:09
@coderabbitai

coderabbitai Bot commented Feb 25, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request updates documentation, configuration, and source code for a MediaWiki extension. The minimum required MediaWiki version is increased from 1.35 to 1.39, and the extension version is bumped to 3.0.0, with corresponding release notes in the README and extension files. Dependency versions in the Composer configuration are upgraded, and a new plugin is allowed. Additionally, the PHPStan configuration now loads a bootstrap file. Minor formatting adjustments are made in several source files, and the type declaration in a file fetcher, as well as control flow in a URL normalizer, are refined. Unit tests have been simplified accordingly.

Changes

File(s) Change Summary
README.md, extension.json Updated MediaWiki version requirement from 1.35 to 1.39 and bumped the extension version to 3.0.0 with a new release note in the README.
composer.json, phpstan.neon Upgraded development dependency versions (phpstan/phpstan and mediawiki/mediawiki-codesniffer), added a new allowed plugin entry, and introduced a bootstrapFiles configuration in PHPStan.
src/Domain/ContentRenderer/MarkdownRenderer.php, src/Domain/UrlNormalizer/BitbucketUrlNormalizer.php, src/EntryPoints/MediaWikiHooks.php, src/UseCases/Embed/EmbedUseCase.php Made minor formatting adjustments (spacing in lambda function declarations and catch block formatting) without altering behavior.
src/Adapters/FileFetcher/MediaWikiFileFetcher.php, src/Domain/UrlNormalizer/GitHubUrlNormalizer.php Refined the type declaration for $credentials and streamlined the control flow in URL normalization.
tests/Unit/Adapters/MediaWikiFileFetcherTest.php Simplified test assertions by replacing the $this->equalTo matcher with direct string comparisons.

Possibly related PRs

  • Fix tests and CI #65: Addresses changes related to updating MediaWiki compatibility requirements to version 1.39 and above.

Suggested reviewers

  • JeroenDeDauw
  • malberts

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
README.md (2)

103-103: Updated MediaWiki requirement in documentation.

Correctly updated the minimum MediaWiki version to 1.39 to match the change in extension.json.

For consistency with other list items in this document, consider using a dash instead of an asterisk:

-* [MediaWiki] 1.39 or later (tested up to 1.43 and master)
+- [MediaWiki] 1.39 or later (tested up to 1.43 and master)
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

103-103: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


247-249: Added appropriate release notes for version 3.0.0.

The release notes correctly document the MediaWiki requirement change.

The release date is set to 2025-02-25, which is in the future. Is this intentional or should it be updated to the actual release date?

For consistency with other list items in this document, consider using a dash instead of an asterisk in line 249:

-* Bump minimum MediaWiki requirements to 1.39 
+- Bump minimum MediaWiki requirements to 1.39 
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

249-249: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6dbf932 and fc623f9.

📒 Files selected for processing (11)
  • README.md (2 hunks)
  • composer.json (1 hunks)
  • extension.json (2 hunks)
  • phpstan.neon (1 hunks)
  • src/Adapters/FileFetcher/MediaWikiFileFetcher.php (1 hunks)
  • src/Domain/ContentRenderer/MarkdownRenderer.php (1 hunks)
  • src/Domain/UrlNormalizer/BitbucketUrlNormalizer.php (2 hunks)
  • src/Domain/UrlNormalizer/GitHubUrlNormalizer.php (1 hunks)
  • src/EntryPoints/MediaWikiHooks.php (1 hunks)
  • src/UseCases/Embed/EmbedUseCase.php (2 hunks)
  • tests/Unit/Adapters/MediaWikiFileFetcherTest.php (4 hunks)
✅ Files skipped from review due to trivial changes (5)
  • tests/Unit/Adapters/MediaWikiFileFetcherTest.php
  • src/Domain/ContentRenderer/MarkdownRenderer.php
  • src/EntryPoints/MediaWikiHooks.php
  • src/Domain/UrlNormalizer/BitbucketUrlNormalizer.php
  • src/UseCases/Embed/EmbedUseCase.php
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

103-103: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


249-249: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (8)
phpstan.neon (1)

10-11: Appropriate PHPStan bootstrap configuration added.

Adding the MediaWiki AutoLoader.php as a bootstrap file is a good practice for PHPStan analysis of extensions, especially when upgrading to PHPStan 2.0.1 as mentioned in the PR summary.

src/Domain/UrlNormalizer/GitHubUrlNormalizer.php (1)

52-52: Good improvement to control flow logic.

Converting to an if-elseif structure makes the relationship between these conditions clearer and ensures the second condition is only checked when the first is false, which is the intended behavior.

extension.json (2)

3-3: Appropriate version bump to 3.0.0.

The version increment follows semantic versioning principles, correctly indicating a major version change with breaking changes.


16-16: Appropriate MediaWiki requirement update.

Increasing the minimum MediaWiki version requirement to 1.39.0 aligns with the PR objectives and justifies the major version bump.

src/Adapters/FileFetcher/MediaWikiFileFetcher.php (1)

16-16: Improved type declaration syntax

This change properly uses the modern PHP nullable type syntax (?DomainCredentials) which better expresses that this parameter explicitly accepts null values. This is more consistent with static analysis expectations and improves code clarity.

composer.json (3)

41-41: Updated MediaWiki CodeSniffer

The upgrade from version 37.0.0 to 45.0.0 aligns with addressing the code style issues mentioned in the PR description. This is a significant version jump that likely includes new rules and checks.


45-46: Added CodeSniffer Composer installer plugin

Adding the dealerdirect/phpcodesniffer-composer-installer plugin will automatically install and configure PHP_CodeSniffer standards, making it easier to maintain consistent code style throughout the project.


40-40:

Details

❓ Verification inconclusive

Significant PHPStan upgrade

Upgrading from version 0.12.99 to 2.0.1 is a major change that could introduce breaking changes in static analysis. Ensure that the new bootstrap file mentioned in the PR description properly handles any compatibility issues.


🏁 Script executed:

#!/bin/bash
# Check if there are any PHPStan errors after the upgrade
if [ -f "phpstan.neon" ]; then
  echo "PHPStan configuration file found, examining bootstrap configuration:"
  cat phpstan.neon | grep -A 5 "bootstrap"
fi

# Check PHPStan version compatibility implications
echo "Checking for major PHPStan version changes:"
if [ -f "vendor/bin/phpstan" ]; then
  vendor/bin/phpstan --version
fi

Length of output: 393


Attention: PHPStan Upgrade Verification

The upgrade to PHPStan 2.0.1 from 0.12.99 is indeed a major change. The configuration in phpstan.neon shows that the bootstrap file (../../includes/AutoLoader.php) is still in use, which is good. However, the shell script did not find the vendor/bin/phpstan executable—which suggests that PHPStan may not be installed or available yet. Please ensure that:

  • The bootstrap file (../../includes/AutoLoader.php) in your phpstan.neon correctly handles compatibility requirements for PHPStan 2.0.1.
  • The PHPStan binary is present (e.g., after running composer install) and confirms the correct version.
  • A full run of PHPStan does not introduce new static analysis errors due to the upgrade.

@alistair3149
alistair3149 marked this pull request as draft February 25, 2025 23:33
@alistair3149
alistair3149 marked this pull request as ready for review February 25, 2025 23:45
@malberts

malberts commented Feb 26, 2025

Copy link
Copy Markdown
Contributor

In general, I think it's better to leave version number changes to a separate PR. Although we're not planning any new changes now, so not a problem here.

Comment thread src/Domain/UrlNormalizer/BitbucketUrlNormalizer.php Outdated
Comment thread README.md Outdated
@alistair3149 alistair3149 changed the title 3.0.0 release Fix various code styles and CI issues Feb 26, 2025

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
README.md (1)

103-103: MediaWiki Version Requirement Update & List Marker Consistency
The update to "* [MediaWiki] 1.39 or later (tested up to 1.43 and master)" correctly reflects the new minimum MediaWiki requirements per the PR objectives. However, according to the markdownlint recommendation (MD004), it is preferred to use a dash (-) rather than an asterisk for unordered list items. Consider updating the list marker to maintain consistency with the project's style guidelines.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

103-103: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd0cb09 and 8da880c.

📒 Files selected for processing (2)
  • README.md (2 hunks)
  • src/Domain/UrlNormalizer/BitbucketUrlNormalizer.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Domain/UrlNormalizer/BitbucketUrlNormalizer.php
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

103-103: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


249-249: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

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

247-250: Release Note Wording & List Marker Format
The addition of the release note for version 3.0.0 correctly documents the update. To maintain consistency with previous release notes and the project's guidelines, consider writing the release notes in past tense (e.g., "Bumped minimum MediaWiki requirements to 1.39"). Additionally, similar to the MediaWiki requirement bullet, updating the unordered list marker from an asterisk to a dash would address the markdownlint warning.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

249-249: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

@JeroenDeDauw
JeroenDeDauw merged commit 007ed2c into master Feb 26, 2025
@JeroenDeDauw
JeroenDeDauw deleted the fix-ci-2 branch February 26, 2025 15:10
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