Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpcs: enable: Generic.Files.LineLength.TooLong #150

Merged
merged 33 commits into from
Feb 8, 2025

Conversation

Universal-Omega
Copy link
Owner

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Mar 22, 2022

Codecov Report

Merging #150 (8c8f04e) into master (7c2bc69) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##             master    #150      +/-   ##
===========================================
- Coverage      8.50%   8.47%   -0.04%     
  Complexity     1558    1558              
===========================================
  Files            22      22              
  Lines          4326    4343      +17     
===========================================
  Hits            368     368              
- Misses         3958    3975      +17     
Impacted Files Coverage Δ
includes/Parse.php 0.00% <0.00%> (ø)
maintenance/createTemplate.php 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c2bc69...8c8f04e. Read the comment docs.

@Universal-Omega Universal-Omega marked this pull request as draft July 13, 2022 15:26
if ( Config::getSetting( 'runFromProtectedPagesOnly' ) === true && $title && !$restrictionStore->isProtected( $title, 'edit' ) ) {
// Ideally we would like to allow using a DPL query if the query istelf is coded on a template page which is protected. Then there would be no need for the article to be protected. However, how can one find out from which wiki source an extension has been invoked???
if (
Config::getSetting( 'runFromProtectedPagesOnly' ) === true &&

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Config' in method 'parse'.
Copy link

coderabbitai bot commented Feb 8, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

@@ -62,7 +62,8 @@
$text = wfMessage( 'dpl_log_' . $errorMessageId, $args )->text();
}

$this->buffer[] = '<p>Extension:DynamicPageList3 (DPL3), version ' . Hooks::getVersion() . ': ' . $text . '</p>';
$this->buffer[] = '<p>Extension:DynamicPageList3 (DPL3), version ' .
Hooks::getVersion() . ': ' . $text . '</p>';

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Hooks' in method 'msg'.
@@ -54,7 +54,10 @@
$updater = $page->newPageUpdater( User::newSystemUser( 'DynamicPageList3 extension' ) );
$content = $page->getContentHandler()->makeContent( '<noinclude>This page was automatically created. It serves as an anchor page for all \'\'\'[[Special:WhatLinksHere/Template:Extension_DPL|invocations]]\'\'\' of [https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:DynamicPageList3 Extension:DynamicPageList3].</noinclude>', $title );
$updater->setContent( SlotRecord::MAIN, $content );
$comment = CommentStoreComment::newUnsavedComment( 'Autogenerated DynamicPageList3\'s necessary template for content inclusion.' );

$comment = CommentStoreComment::newUnsavedComment(

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class '\MediaWiki\CommentStore\CommentStoreComment' in method 'doDBUpdates'.
$updater->setContent( SlotRecord::MAIN, $content );
$comment = CommentStoreComment::newUnsavedComment( 'Autogenerated DynamicPageList3\'s necessary template for content inclusion.' );
$updater = $page->newPageUpdater(
User::newSystemUser( 'DynamicPageList3 extension' )

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class '\MediaWiki\User\User' in method 'doDBUpdates'.
Universal-Omega and others added 3 commits February 7, 2025 17:34
Check commit and GitHub actions for more details
$maxLength = -1,
$page = '?page?',
$link = 'default',
$trim = false

Check warning

Code scanning / Phpmd (reported by Codacy)

You can fix this problem by extracting the logic in the boolean flag into its own class or method Warning

The method dplChapterParserFunction has a boolean flag argument $trim, which is a certain sign of a Single Responsibility Principle violation.
$parser->addTrackingCategory( 'dplchapter-parserfunc-tracking-category' );
$output = LST::extractHeadingFromText( $parser, $page, '?title?', $text, $heading, '', $sectionHeading, true, $maxLength, $link, $trim );
$output = LST::extractHeadingFromText(

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\LST' in method 'dplChapterParserFunction'.
$output = LST::extractHeadingFromText( $parser, $page, '?title?', $text, $heading, '', $sectionHeading, true, $maxLength, $link, $trim );
$output = LST::extractHeadingFromText(
$parser, $page, '?title?', $text, $heading, '',
$sectionHeading, true, $maxLength, $link, $trim

Check warning

Code scanning / Phpmd (reported by Codacy)

Detects when a variable is used that has not been defined before Warning

Avoid using undefined variables such as '$sectionHeading' which will lead to PHP notices.
$output = LST::extractHeadingFromText( $parser, $page, '?title?', $text, $heading, '', $sectionHeading, true, $maxLength, $link, $trim );
$output = LST::extractHeadingFromText(
$parser, $page, '?title?', $text, $heading, '',
$sectionHeading, true, $maxLength, $link, $trim

Check notice

Code scanning / Phpmd (reported by Codacy)

Prohibit the definition or assignment of unused local variables Note

Avoid unused local variables such as '$sectionHeading'.
@@ -416,7 +436,14 @@
* @param string $matrix
* @return string
*/
public static function dplMatrixParserFunction( &$parser, $name = '', $yes = '', $no = '', $flip = '', $matrix = '' ) {
public static function dplMatrixParserFunction(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with high cyclomatic complexity Note

The method dplMatrixParserFunction() has a Cyclomatic Complexity of 25. The configured cyclomatic complexity threshold is 10.
@@ -416,7 +436,14 @@
* @param string $matrix
* @return string
*/
public static function dplMatrixParserFunction( &$parser, $name = '', $yes = '', $no = '', $flip = '', $matrix = '' ) {
public static function dplMatrixParserFunction(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with a large number of possible paths Note

The method dplMatrixParserFunction() has an NPath complexity of 13056. The configured NPath complexity threshold is 200.
@@ -416,7 +436,14 @@
* @param string $matrix
* @return string
*/
public static function dplMatrixParserFunction( &$parser, $name = '', $yes = '', $no = '', $flip = '', $matrix = '' ) {
public static function dplMatrixParserFunction(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports excessively long methods. Note

The method dplMatrixParserFunction() has 114 lines of code. Current threshold is set to 100. Avoid really long methods.
&$parser,
$name = '',
$yes = '',
$no = '',

Check warning

Code scanning / Phpmd (reported by Codacy)

Detects when a field, local, or parameter has a very short name. Warning

Avoid variables with short names like $no. Configured minimum length is 3.
@@ -673,7 +705,10 @@
$parameter = trim( $parameter );
$namespaceId = $contLang->getNsIndex( $parameter );

if ( $namespaceId === false || ( is_array( Config::getSetting( 'allowedNamespaces' ) ) && !in_array( $parameter, Config::getSetting( 'allowedNamespaces' ) ) ) ) {
if ( $namespaceId === false || (
is_array( Config::getSetting( 'allowedNamespaces' ) ) &&

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Config' in method '_namespace'.
if ( $namespaceId === false || ( is_array( Config::getSetting( 'allowedNamespaces' ) ) && !in_array( $parameter, Config::getSetting( 'allowedNamespaces' ) ) ) ) {
if ( $namespaceId === false || (
is_array( Config::getSetting( 'allowedNamespaces' ) ) &&
!in_array( $parameter, Config::getSetting( 'allowedNamespaces' ) )

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Config' in method '_namespace'.
@@ -559,14 +602,26 @@
* @param bool $optional
* @return string
*/
private static function updateTemplateCall( &$matchCount, $text, $template, $call, $parameter, $value, $afterParm, $optional ) {
private static function updateTemplateCall(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with a large number of possible paths Note

The method updateTemplateCall() has an NPath complexity of 29880. The configured NPath complexity threshold is 200.
@@ -559,14 +602,26 @@
* @param bool $optional
* @return string
*/
private static function updateTemplateCall( &$matchCount, $text, $template, $call, $parameter, $value, $afterParm, $optional ) {
private static function updateTemplateCall(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with high cyclomatic complexity Note

The method updateTemplateCall() has a Cyclomatic Complexity of 31. The configured cyclomatic complexity threshold is 10.
@@ -559,14 +602,26 @@
* @param bool $optional
* @return string
*/
private static function updateTemplateCall( &$matchCount, $text, $template, $call, $parameter, $value, $afterParm, $optional ) {
private static function updateTemplateCall(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports excessively long methods. Note

The method updateTemplateCall() has 150 lines of code. Current threshold is set to 100. Avoid really long methods.
$parser,
$text,
$part1,
$skiphead = 0,

Check notice

Code scanning / Phpmd (reported by Codacy)

Prohibit the definition of unused parameters on methods or constructors Note

Avoid unused parameters such as '$skiphead'.
$text,
$part1,
$skiphead = 0,
$recursionCheck = true,

Check warning

Code scanning / Phpmd (reported by Codacy)

You can fix this problem by extracting the logic in the boolean flag into its own class or method Warning

The method parse has a boolean flag argument $recursionCheck, which is a certain sign of a Single Responsibility Principle violation.
$recursionCheck = true,
$maxLength = -1,
$link = '',
$trim = false,

Check warning

Code scanning / Phpmd (reported by Codacy)

You can fix this problem by extracting the logic in the boolean flag into its own class or method Warning

The method parse has a boolean flag argument $trim, which is a certain sign of a Single Responsibility Principle violation.
$parser,
$page = '',
$sec = '',
$to = '',

Check warning

Code scanning / Phpmd (reported by Codacy)

Detects when a field, local, or parameter has a very short name. Warning

Avoid variables with short names like $to. Configured minimum length is 3.
$page = '',
$sec = '',
$to = '',
$recursionCheck = true,

Check warning

Code scanning / Phpmd (reported by Codacy)

You can fix this problem by extracting the logic in the boolean flag into its own class or method Warning

The method includeSection has a boolean flag argument $recursionCheck, which is a certain sign of a Single Responsibility Principle violation.
$title,
$text,
$sec,
$to,

Check warning

Code scanning / Phpmd (reported by Codacy)

Detects when a field, local, or parameter has a very short name. Warning

Avoid variables with short names like $to. Configured minimum length is 3.
@@ -628,7 +699,19 @@
* @param string $catlist
* @return array
*/
public static function includeTemplate( $parser, Lister $lister, $dplNr, $article, $template1, $template2, $defaultTemplate, $mustMatch, $mustNotMatch, $matchParsed, $catlist ) {
public static function includeTemplate(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with high cyclomatic complexity Note

The method includeTemplate() has a Cyclomatic Complexity of 64. The configured cyclomatic complexity threshold is 10.
@@ -628,7 +699,19 @@
* @param string $catlist
* @return array
*/
public static function includeTemplate( $parser, Lister $lister, $dplNr, $article, $template1, $template2, $defaultTemplate, $mustMatch, $mustNotMatch, $matchParsed, $catlist ) {
public static function includeTemplate(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with a high number of parameters. Note

The method includeTemplate has 11 parameters. Consider reducing the number of parameters to less than 10.
@@ -628,7 +699,19 @@
* @param string $catlist
* @return array
*/
public static function includeTemplate( $parser, Lister $lister, $dplNr, $article, $template1, $template2, $defaultTemplate, $mustMatch, $mustNotMatch, $matchParsed, $catlist ) {
public static function includeTemplate(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports methods with a large number of possible paths Note

The method includeTemplate() has an NPath complexity of 25078650. The configured NPath complexity threshold is 200.
@@ -628,7 +699,19 @@
* @param string $catlist
* @return array
*/
public static function includeTemplate( $parser, Lister $lister, $dplNr, $article, $template1, $template2, $defaultTemplate, $mustMatch, $mustNotMatch, $matchParsed, $catlist ) {
public static function includeTemplate(

Check notice

Code scanning / Phpmd (reported by Codacy)

This pattern reports excessively long methods. Note

The method includeTemplate() has 328 lines of code. Current threshold is set to 100. Avoid really long methods.
$secPiece[$s] = implode( isset( $this->multiSectionSeparators[$s] ) ? $this->replaceTagCount( $this->multiSectionSeparators[$s], $filteredCount ) : '', $secPieces );

if ( $this->getDominantSectionCount() >= 0 && $s == $this->getDominantSectionCount() && count( $secPieces ) > 1 ) {
$secPieces = LST::includeSection(

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class '\MediaWiki\Extension\DynamicPageList3\LST' in method 'transcludePage'.
Repository owner deleted a comment from coderabbitai bot Feb 8, 2025
Repository owner deleted a comment from coderabbitai bot Feb 8, 2025
Repository owner deleted a comment from coderabbitai bot Feb 8, 2025
$secPieces = LST::includeHeading( $this->parser, $article->mTitle->getPrefixedText(), substr( $sSecLabel, 1 ), '', $sectionHeading, false, $maxLength, $cutLink ?? 'default', $this->getTrimIncluded(), $skipPattern ?? [] );
// Uses LST::includeHeading() from LabeledSectionTransclusion extension to
// include headings from the page
$secPieces = LST::includeHeading(

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class '\MediaWiki\Extension\DynamicPageList3\LST' in method 'transcludePage'.
$secPiece[$s] = implode( isset( $this->multiSectionSeparators[$s] ) ? $this->replaceTagCount( $this->multiSectionSeparators[$s], $filteredCount ) : '', $secPieces );

if ( $this->getDominantSectionCount() >= 0 && $s == $this->getDominantSectionCount() && count( $secPieces ) > 1 ) {
$secPieces = LST::includeTemplate(

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class '\MediaWiki\Extension\DynamicPageList3\LST' in method 'transcludePage'.
Universal-Omega and others added 3 commits February 8, 2025 11:19
Check commit and GitHub actions for more details
@@ -194,7 +207,14 @@
}

$calcRows = false;
if ( !Config::getSetting( 'allowUnlimitedResults' ) && $this->parameters->getParameter( 'goal' ) != 'categories' && strpos( $this->parameters->getParameter( 'resultsheader' ) . $this->parameters->getParameter( 'noresultsheader' ) . $this->parameters->getParameter( 'resultsfooter' ), '%TOTALPAGES%' ) !== false ) {
if (
!Config::getSetting( 'allowUnlimitedResults' ) &&

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Config' in method 'parse'.
@@ -687,108 +742,175 @@
}

// Too many categories.
if ( $totalCategories > Config::getSetting( 'maxCategoryCount' ) && !Config::getSetting( 'allowUnlimitedCategories' ) ) {
if (
$totalCategories > Config::getSetting( 'maxCategoryCount' ) &&

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Config' in method 'doQueryErrorChecks'.
if ( $totalCategories > Config::getSetting( 'maxCategoryCount' ) && !Config::getSetting( 'allowUnlimitedCategories' ) ) {
if (
$totalCategories > Config::getSetting( 'maxCategoryCount' ) &&
!Config::getSetting( 'allowUnlimitedCategories' )

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Config' in method 'doQueryErrorChecks'.
@@ -2058,15 +2095,18 @@
foreach ( $titles as $title ) {
if ( $this->parameters->getParameter( 'openreferences' ) ) {
if ( $this->parameters->getParameter( 'ignorecase' ) ) {
$_or = "LOWER(CAST(lt_title AS char)) {$comparisonType}" . strtolower( $this->dbr->addQuotes( $title ) );
$_or = "LOWER(CAST(lt_title AS char)) {$comparisonType}" .

Check notice

Code scanning / Phpmd (reported by Codacy)

Requires all variable names to use the CamelCase style Note

The variable $_or is not named in camelCase.
@@ -2090,15 +2130,18 @@
foreach ( $titles as $title ) {
if ( $this->parameters->getParameter( 'openreferences' ) ) {
if ( $this->parameters->getParameter( 'ignorecase' ) ) {
$_or = "LOWER(CAST(lt_title AS char)) {$comparisonType}" . strtolower( $this->dbr->addQuotes( $title ) );
$_or = "LOWER(CAST(lt_title AS char)) {$comparisonType}" .

Check notice

Code scanning / Phpmd (reported by Codacy)

Requires all variable names to use the CamelCase style Note

The variable $_or is not named in camelCase.
@@ -357,7 +362,9 @@
$this->sqlQuery = $query;
}
} catch ( Exception $e ) {
throw new LogicException( __METHOD__ . ': ' . wfMessage( 'dpl_query_error', Hooks::getVersion(), $this->dbr->lastError() )->text() );
throw new LogicException( __METHOD__ . ': ' . wfMessage(
'dpl_query_error', Hooks::getVersion(), $this->dbr->lastError()

Check warning

Code scanning / Phpmd (reported by Codacy)

Static access leads to hard to test code Warning

Avoid using static access to class 'MediaWiki\Extension\DynamicPageList3\Hooks' in method 'buildAndSelect'.
@Universal-Omega Universal-Omega marked this pull request as ready for review February 8, 2025 19:21
@Universal-Omega Universal-Omega merged commit e1d5790 into master Feb 8, 2025
20 of 21 checks passed
@Universal-Omega Universal-Omega deleted the Universal-Omega-patch-2 branch February 8, 2025 19:22
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.

2 participants